| 50 | |
| 51 | #if 1 |
| 52 | __attribute__((constructor)) static void ctor() { |
| 53 | void *func = NULL; |
| 54 | log_set_level(1); |
| 55 | |
| 56 | func_map = new std::map<void *, const char *>(); |
| 57 | |
| 58 | for (int i = 0; i < sizeof(func_array) / sizeof(char *); ++i) { |
| 59 | func = DobbySymbolResolver(NULL, func_array[i]); |
| 60 | if (func == NULL) { |
| 61 | LOG(1, "func %s not resolve", func_array[i]); |
| 62 | continue; |
| 63 | } |
| 64 | func_map->insert(std::pair<void *, const char *>(func, func_array[i])); |
| 65 | } |
| 66 | |
| 67 | for (auto i = func_map->begin(), e = func_map->end(); i != e; i++) { |
| 68 | DobbyInstrument(i->first, common_handler); |
| 69 | } |
| 70 | |
| 71 | DobbyGlobalOffsetTableReplace(NULL, "_pthread_create", (void *)fake_pthread_create, (void **)&orig_pthread_create); |
| 72 | |
| 73 | pthread_t socket_server; |
| 74 | uint64_t socket_demo_server(void *ctx); |
| 75 | pthread_create(&socket_server, NULL, (void *(*)(void *))socket_demo_server, NULL); |
| 76 | |
| 77 | usleep(1000); |
| 78 | pthread_t socket_client; |
| 79 | uint64_t socket_demo_client(void *ctx); |
| 80 | pthread_create(&socket_client, NULL, (void *(*)(void *))socket_demo_client, NULL); |
| 81 | |
| 82 | pthread_join(socket_client, 0); |
| 83 | pthread_join(socket_server, 0); |
| 84 | } |
| 85 | |
| 86 | #include <sys/socket.h> |
| 87 | #include <netinet/in.h> |
nothing calls this directly
no test coverage detected