diff --git a/gtests/net/packetdrill/packetdrill.c b/gtests/net/packetdrill/packetdrill.c index d95c6aaa3bc49211a6f1a21de245c6254f853904..990e0a457885a22774daf18d5065bd6c3caf5e40 100644 --- a/gtests/net/packetdrill/packetdrill.c +++ b/gtests/net/packetdrill/packetdrill.c @@ -27,6 +27,10 @@ #include <arpa/inet.h> #include <assert.h> #include <getopt.h> +#include <pthread.h> +#if defined(__FreeBSD__) +#include <pthread_np.h> +#endif #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -64,9 +68,19 @@ static void run_init_scripts(struct config *config) int main(int argc, char *argv[]) { struct config config; + char **arg; + +#if defined(__APPLE__) + pthread_setname_np("main thread"); +#elif defined(linux) + prctl(PR_SET_NAME, "main thread"); +#elif defined(__FreeBSD__) + pthread_set_name_np(pthread_self(), "main thread"); +#endif + set_default_config(&config); /* Get command line options and list of test scripts. */ - char **arg = parse_command_line_options(argc, argv, &config); + arg = parse_command_line_options(argc, argv, &config); /* If we're running as a server, just listen for connections forever. */ if (config.is_wire_server) { diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index 072dc959d4ed27c3d130874485c3a94a4a2360e0..5809c1ea95e08a3249df733a6c6753c8a4548fe3 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -32,6 +32,9 @@ #include <netinet/in.h> #include <poll.h> #include <pthread.h> +#if defined(__FreeBSD__) +#include <pthread_np.h> +#endif #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -6174,6 +6177,13 @@ static void *system_call_thread(void *arg) struct syscall_spec *syscall = NULL; bool done = false; +#if defined(__APPLE__) + pthread_setname_np("syscall thread"); +#elif defined(linux) + prctl(PR_SET_NAME, "syscall thread"); +#elif defined(__FreeBSD__) + pthread_set_name_np(pthread_self(), "syscall thread"); +#endif DEBUGP("syscall thread: starting and locking\n"); run_lock(state);