Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb][test] Add the ability to extract the variable value out of the summary. #72631

Merged
merged 2 commits into from
Nov 17, 2023

Conversation

santhoshe447
Copy link
Contributor

@santhoshe447 santhoshe447 commented Nov 17, 2023

Fix for #71897
When it comes to test infrastructure the test (TestDAP_variables.py: test_scopes_variables_setVariable_evaluate_with_descriptive_summaries) will fail if the variable has a summary along with value.

I just tried to add a summary to a variable before we set a value to the variable using below expression from “request_setVariable” function.
RunLLDBCommands(llvm::StringRef(), {std::string("type summary add --summary-string "{sample summary}" (const char **) argv")});

As value has nonnumeric characters where we are trying to convert into integer, python is throwing an error. We did not see this issue in upstream as we are not adding summary explicitly, by default we are getting empty summary & value for all children’s of argv parameter (even after auto summary).

The test is failing with below error:
ERROR: test_scopes_variables_setVariable_evaluate_with_descriptive_summaries (TestDAP_variables.TestDAP_variables)
Traceback (most recent call last):
File "/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py", line 372, in test_scopes_variables_setVariable_evaluate_with_descriptive_summaries
enableAutoVariableSummaries=True
File "/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py", line 266, in do_test_scopes_variables_setVariable_evaluate
argv = self.get_local_as_int("argv")
File "//llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py", line 199, in get_local_as_int
return int(value, 16)
ValueError: invalid literal for int() with base 16: '0x0000000000001234 sample summary'
Config=x86_64-//llvm/llvm-build/bin/clang

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 17, 2023

@llvm/pr-subscribers-lldb

Author: None (santhoshe447)

Changes

When it comes to test infrastructure the test (TestDAP_variables.py: test_scopes_variables_setVariable_evaluate_with_descriptive_summaries) will fail if the variable has a summary along with value.

I just tried to add a summary to a variable before we set a value to the variable using below expression from “request_setVariable” function.
RunLLDBCommands(llvm::StringRef(), {std::string("type summary add --summary-string "{sample summary}" (const char **) argv")});

As value has nonnumeric characters where we are trying to convert into integer, python is throwing an error. We did not see this issue in upstream as we are not adding summary explicitly, by default we are getting empty summary & value for all children’s of argv parameter (even after auto summary).

The test is failing with below error:
ERROR: test_scopes_variables_setVariable_evaluate_with_descriptive_summaries (TestDAP_variables.TestDAP_variables)
Traceback (most recent call last):
File "/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py", line 372, in test_scopes_variables_setVariable_evaluate_with_descriptive_summaries
enableAutoVariableSummaries=True
File "/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py", line 266, in do_test_scopes_variables_setVariable_evaluate
argv = self.get_local_as_int("argv")
File "//llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py", line 199, in get_local_as_int
return int(value, 16)
ValueError: invalid literal for int() with base 16: '0x0000000000001234 sample summary'
Config=x86_64-//llvm/llvm-build/bin/clang


Full diff: https://github.com/llvm/llvm-project/pull/72631.diff

1 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+3)
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 9d79872b029a334..0cf9d4fde49488f 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -195,6 +195,9 @@ def collect_console(self, duration):
 
     def get_local_as_int(self, name, threadId=None):
         value = self.dap_server.get_local_variable_value(name, threadId=threadId)
+        # 'value' may have the variable value and summary.
+        # Extract the variable value since summary can have nonnumeric characters.
+        value = value.split(" ")[0]
         if value.startswith("0x"):
             return int(value, 16)
         elif value.startswith("0"):

Copy link
Member

@walter-erquinigo walter-erquinigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@walter-erquinigo walter-erquinigo merged commit 06effaf into llvm:main Nov 17, 2023
4 checks passed
sr-tream pushed a commit to sr-tream/llvm-project that referenced this pull request Nov 20, 2023
… summary. (llvm#72631)

Fix for llvm#71897
When it comes to test infrastructure the test (TestDAP_variables.py:
test_scopes_variables_setVariable_evaluate_with_descriptive_summaries)
will fail if the variable has a summary along with value.

I just tried to add a summary to a variable before we set a value to the
variable using below expression from “request_setVariable” function.
RunLLDBCommands(llvm::StringRef(), {std::string("type summary add
--summary-string "{sample summary}" (const char **) argv")});

As value has nonnumeric characters where we are trying to convert into
integer, python is throwing an error. We did not see this issue in
upstream as we are not adding summary explicitly, by default we are
getting empty summary & value for all children’s of argv parameter (even
after auto summary).

The test is failing with below error:
ERROR:
test_scopes_variables_setVariable_evaluate_with_descriptive_summaries
(TestDAP_variables.TestDAP_variables)
Traceback (most recent call last):
File
"/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py",
line 372, in
test_scopes_variables_setVariable_evaluate_with_descriptive_summaries
enableAutoVariableSummaries=True
File
"/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py",
line 266, in do_test_scopes_variables_setVariable_evaluate
argv = self.get_local_as_int("argv")
File
"//llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py",
line 199, in get_local_as_int
return int(value, 16)
ValueError: invalid literal for int() with base 16: '0x0000000000001234
sample summary'
Config=x86_64-//llvm/llvm-build/bin/clang

Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com>
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
… summary. (llvm#72631)

Fix for llvm#71897
When it comes to test infrastructure the test (TestDAP_variables.py:
test_scopes_variables_setVariable_evaluate_with_descriptive_summaries)
will fail if the variable has a summary along with value.

I just tried to add a summary to a variable before we set a value to the
variable using below expression from “request_setVariable” function.
RunLLDBCommands(llvm::StringRef(), {std::string("type summary add
--summary-string "{sample summary}" (const char **) argv")});

As value has nonnumeric characters where we are trying to convert into
integer, python is throwing an error. We did not see this issue in
upstream as we are not adding summary explicitly, by default we are
getting empty summary & value for all children’s of argv parameter (even
after auto summary).

The test is failing with below error:
ERROR:
test_scopes_variables_setVariable_evaluate_with_descriptive_summaries
(TestDAP_variables.TestDAP_variables)
Traceback (most recent call last):
File
"/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py",
line 372, in
test_scopes_variables_setVariable_evaluate_with_descriptive_summaries
enableAutoVariableSummaries=True
File
"/llvm/llvm-project/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py",
line 266, in do_test_scopes_variables_setVariable_evaluate
argv = self.get_local_as_int("argv")
File
"//llvm/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py",
line 199, in get_local_as_int
return int(value, 16)
ValueError: invalid literal for int() with base 16: '0x0000000000001234
sample summary'
Config=x86_64-//llvm/llvm-build/bin/clang

Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants