From cd90f878d4156ef1a732cdd64bc67aa88e7ac2ec Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Fri, 6 Apr 2018 04:28:12 +0000 Subject: [debugserver] Fix LC_BUILD_VERSION load command handling. Summary: In one of the 2 places the LC_BUILD_VERSION load command is handled, there is a bug preventing us from actually handling them (the address where to read the load command was not updated). This patch factors reading the deployment target load commands into a helper and adds testing for the 2 code paths calling the helper. The testing is a little bit complicated because the only times those load commands matter is when debugging a simulator process. I added a new decorator to check that a specific SDK is available. The actual testing was fairly easy once I knew how to run a simulated process. Reviewers: jasonmolenda, labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D45298 llvm-svn: 329374 --- lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp') diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp index 399c1d35ae6..ca032c120be 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp +++ b/lldb/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 @@ -349,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]); -- cgit v1.2.3