From b9923f049e3641ab57cd29ce90a31916740c1534 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 8 Mar 2018 15:41:13 +0000 Subject: [PATCH] [LLDB][PPC64] Fix single step and LldbGdbServer tests Summary: On PPC64, the tested functions were being entered through their local entry point, while the tests expected the program to stop at the function start address, that, for PPC64, corresponds to the global entry point. To fix the issue, the test program was modified to call the functions to be tested through function pointers, which, on PPC64, force the calls through the global entry point, while not affecting the test on other platforms. Reviewers: clayborg, labath Reviewed By: labath Subscribers: alexandreyy, lbianc Differential Revision: https://reviews.llvm.org/D43768 Patch by Leandro Lupori . llvm-svn: 327013 --- .../Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py | 2 +- .../Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py | 7 ++++--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp | 8 ++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py index 2a79b74..82e76ca 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py @@ -331,7 +331,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod self.assertTrue('pc' in generic_regs) # Ensure we have a frame pointer register. PPC64le's FP is the same as SP - if(self.getArchitecture() != 'powerpc64le'): + if self.getArchitecture() != 'powerpc64le': self.assertTrue('fp' in generic_regs) # Ensure we have a stack pointer register. diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 6a56b23..4dbf642 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -1008,9 +1008,10 @@ class GdbRemoteTestCaseBase(TestBase): reg_info["name"] in PREFERRED_REGISTER_NAMES): # We found a preferred register. Use it. return reg_info["lldb_register_index"] - if ("generic" in reg_info) and (reg_info["generic"] == "fp"): - # A frame pointer register will do as a register to modify - # temporarily. + if ("generic" in reg_info) and (reg_info["generic"] == "fp" or + reg_info["generic"] == "arg1"): + # A frame pointer or first arg register will do as a + # register to modify temporarily. alternative_register_index = reg_info["lldb_register_index"] # We didn't find a preferred register. Return whatever alternative register 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 a574b41..399c1d3 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp @@ -303,18 +303,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)) { -- 2.7.4