diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /packages/Python/lldbsuite/test/tools/lldb-server/main.cpp | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/tools/lldb-server/main.cpp')
-rw-r--r-- | packages/Python/lldbsuite/test/tools/lldb-server/main.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp index a574b41abf670..ca032c120bebd 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp @@ -48,6 +48,8 @@ static const char *const THREAD_COMMAND_NEW = "new"; static const char *const THREAD_COMMAND_PRINT_IDS = "print-ids"; static const char *const THREAD_COMMAND_SEGFAULT = "segfault"; +static const char *const PRINT_PID_COMMAND = "print-pid"; + static bool g_print_thread_ids = false; static pthread_mutex_t g_print_mutex = PTHREAD_MUTEX_INITIALIZER; static bool g_threads_do_segfault = false; @@ -61,6 +63,10 @@ static char g_message[256]; static volatile char g_c1 = '0'; static volatile char g_c2 = '1'; +static void print_pid() { + fprintf(stderr, "PID: %d\n", getpid()); +} + static void print_thread_id() { // Put in the right magic here for your platform to spit out the thread id (tid) // that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else @@ -303,18 +309,22 @@ int main(int argc, char **argv) { printf("code address: %p\n", func_p); pthread_mutex_unlock(&g_print_mutex); } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) { + void (*func_p)() = nullptr; + // Defaut to providing the address of main. if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0) - hello(); + func_p = hello; else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "swap_chars") == 0) - swap_chars(); + func_p = swap_chars; else { pthread_mutex_lock(&g_print_mutex); printf("unknown function: %s\n", argv[i] + strlen(CALL_FUNCTION_PREFIX)); pthread_mutex_unlock(&g_print_mutex); } + if (func_p) + func_p(); } else if (std::strstr(argv[i], THREAD_PREFIX)) { // Check if we're creating a new thread. if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) { @@ -345,6 +355,8 @@ int main(int argc, char **argv) { // At this point we don't do anything else with threads. // Later use thread index and send command to thread. } + } else if (std::strstr(argv[i], PRINT_PID_COMMAND)) { + print_pid(); } else { // Treat the argument as text for stdout. printf("%s\n", argv[i]); |