diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-04-30 21:54:02 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-04-30 21:54:02 +0000 |
commit | ce05952943d958c984cbd9fdbd45036e4c1cd6be (patch) | |
tree | 0c369bd2a2da5b75c18138d9f2a795336d97f133 /lldb/packages/Python/lldbsuite/test | |
parent | 32f2d0e5643b5ab58486810050320a678862ae04 (diff) | |
download | bcm5719-llvm-ce05952943d958c984cbd9fdbd45036e4c1cd6be.tar.gz bcm5719-llvm-ce05952943d958c984cbd9fdbd45036e4c1cd6be.zip |
Remove premature caching of the global variables list in CompileUnit.
This fixes a bug where
(lldb) target var g_ptr
would populate the global variables list with exactly one entry
because SymbolFileDWARF::ParseVariables() was invoked with a list of
DIEs pre-filtered by name, such that a subsequent call to
(lldb) fr var --show-globals
would only list that one variable, because CompileUnit::m_variables
was already initialized, fooling CompileUnit::GetVariableList().
CompileUnit::GetVariableList() grabs the *complete* list of variables
via (SymbolFileDWARF, ...)::ParseVariablesForContext and that still
calls CompileUnit::SetVariableList(variables) which acts as the
caching mechanism.
Differential Revision: https://reviews.llvm.org/D46220
llvm-svn: 331230
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py | 21 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c | 3 |
2 files changed, 20 insertions, 4 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py b/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py index 0d95bcefb85..4219eb083d1 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py +++ b/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py @@ -39,6 +39,12 @@ class GlobalVariablesTestCase(TestBase): environment = self.registerSharedLibrariesWithTarget( target, self.shlib_names) + # Test that static initialized variables can be inspected without process. + self.expect("target variable g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int *)']) + self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['42']) + # Now launch the process, and do not stop at entry point. process = target.LaunchSimple( None, environment, self.get_process_working_directory()) @@ -54,17 +60,21 @@ class GlobalVariablesTestCase(TestBase): substrs=[' resolved, hit count = 1']) # Check that GLOBAL scopes are indicated for the variables. + self.runCmd("frame variable --show-types --scope --show-globals --no-args") self.expect( "frame variable --show-types --scope --show-globals --no-args", VARIABLES_DISPLAYED_CORRECTLY, substrs=[ - 'GLOBAL: (int) g_file_global_int = 42', 'STATIC: (const int) g_file_static_int = 2', + 'STATIC: (const char *) g_func_static_cstr', 'GLOBAL: (const char *) g_file_global_cstr', '"g_file_global_cstr"', + 'GLOBAL: (int) g_file_global_int = 42', + 'GLOBAL: (int) g_common_1 = 21', + 'GLOBAL: (int *) g_ptr', 'STATIC: (const char *) g_file_static_cstr', - '"g_file_static_cstr"', - 'GLOBAL: (int) g_common_1 = 21']) + '"g_file_static_cstr"' + ]) # 'frame variable' should support address-of operator. self.runCmd("frame variable &g_file_global_int") @@ -95,3 +105,8 @@ class GlobalVariablesTestCase(TestBase): VARIABLES_DISPLAYED_CORRECTLY, matching=False, substrs=["can't be resolved"]) + + # Test that the statically initialized variable can also be + # inspected *with* a process. + self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['42']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c b/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c index 499b2504774..b37c97bad9d 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c +++ b/lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c @@ -13,6 +13,7 @@ int g_file_global_int = 42; static const int g_file_static_int = 2; const char *g_file_global_cstr = "g_file_global_cstr"; static const char *g_file_static_cstr = "g_file_static_cstr"; +int *g_ptr = &g_file_global_int; extern int g_a; int main (int argc, char const *argv[]) @@ -20,5 +21,5 @@ int main (int argc, char const *argv[]) g_common_1 = g_file_global_int / g_file_static_int; static const char *g_func_static_cstr = "g_func_static_cstr"; printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr); - return g_file_global_int + g_a + g_common_1; // Set break point at this line. //// break $source:$line; continue; var -global g_a -global g_global_int + return g_file_global_int + g_a + g_common_1 + *g_ptr; // Set break point at this line. //// break $source:$line; continue; var -global g_a -global g_global_int } |