[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
walter-erquinigo wrote: I thought you were meaning UI changes via the fblldb extension, but if you are modying your fork of VSCode, there's nothing to be done then. https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 closed https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
jeffreytan81 wrote: > lgtm. It would be nice if new UI features could be added in the typescript > code of lldb-dap, so that all users benefit from them. @walter-erquinigo , do you mean upstream to VSCode? Yeah, we would like to upstream the changes if Microsoft is willing to take them. https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/walter-erquinigo approved this pull request. lgtm. It would be nice if new UI features could be added in the typescript code of lldb-dap, so that all users benefit from them. https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90799 >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH 1/4] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count +if is_hex is not None: +args_dict["format"] = {"hex": is_hex} command_dict = { "command": "variables", "type": "request", diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index d886d0776ce58b..51e851abf8a54e 100644 ---
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jeffreytan81) Changes While adding a UI feature in VSCode to toggle hex/dec in variables view window. I noticed that it does not work after second toggle. Then I noticed that there is a bug that we only explicitly set hex format not reset back to default during further toggle. The new test demonstrates the bug. This PR resets the format back to default if not using hex. One complexity is that, we explicitly set registers value format to AddressInfo, which shouldn't be overridden by default or hex settings. --- Full diff: https://github.com/llvm/llvm-project/pull/90799.diff 3 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py (+21-13) - (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (+40) - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+7-3) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..e2126d67a5fe77 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,28 +486,32 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables( +frameIndex=frameIndex, threadId=threadId, is_hex=is_hex +) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child( +self, name, child_name, frameIndex=0, threadId=None, is_hex=None +): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ -"variables" -] +children = self.request_variables(local["variablesReference"], is_hex=is_hex)[ +"body" +]["variables"] for child in children: if child["name"] == child_name: return child @@ -1035,12 +1039,16 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables( +self, variablesReference, start=None, count=None, is_hex=None +): args_dict = {"variablesReference":
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 ready_for_review https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90799 >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH 1/3] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count +if is_hex is not None: +args_dict["format"] = {"hex": is_hex} command_dict = { "command": "variables", "type": "request", diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index d886d0776ce58b..51e851abf8a54e 100644 ---
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90799 >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH 1/2] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count +if is_hex is not None: +args_dict["format"] = {"hex": is_hex} command_dict = { "command": "variables", "type": "request", diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index d886d0776ce58b..51e851abf8a54e 100644 ---
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r cf3c714e4bd7b8a68793f2827080fe3388ae8bb1...2daf4aeaee1ce9062dfa964f3baeef0d7477479c lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py `` View the diff from darker here. ``diff --- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-01 23:35:18.00 + +++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-01 23:41:05.012150 + @@ -485,11 +485,13 @@ return self.get_scope_variables( "Registers", frameIndex=frameIndex, threadId=threadId ) def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) +locals = self.get_local_variables( +frameIndex=frameIndex, threadId=threadId, is_hex=is_hex +) for local in locals: if "name" in local and local["name"] == name: return local return None @@ -499,17 +501,19 @@ ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): +def get_local_variable_child( +self, name, child_name, frameIndex=0, threadId=None, is_hex=None +): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ -"variables" -] +children = self.request_variables(local["variablesReference"], is_hex=is_hex)[ +"body" +]["variables"] for child in children: if child["name"] == child_name: return child return None @@ -1033,11 +1037,13 @@ thread[key] = thread_stop_info[key] else: self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None, is_hex=None): +def request_variables( +self, variablesReference, start=None, count=None, is_hex=None +): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count --- test/API/tools/lldb-dap/variables/TestDAP_variables.py 2024-05-01 23:35:18.00 + +++ test/API/tools/lldb-dap/variables/TestDAP_variables.py 2024-05-01 23:41:05.291722 + @@ -765,17 +765,17 @@ program = self.getBuildArtifact("a.out") self.build_and_launch(program) source = "main.cpp" breakpoint1_line = line_number(source, "// breakpoint 1") lines = [breakpoint1_line] - + breakpoint_ids = self.set_source_breakpoints(source, lines) self.assertEqual( len(breakpoint_ids), len(lines), "expect correct number of breakpoints" ) self.continue_to_breakpoints(breakpoint_ids) - + # Verify locals value format decimal is_hex = False var_pt_x = self.dap_server.get_local_variable_child("pt", "x", is_hex=is_hex) self.assertEquals(var_pt_x["value"], "11") var_pt_y = self.dap_server.get_local_variable_child("pt", "y", is_hex=is_hex) @@ -785,11 +785,11 @@ is_hex = True var_pt_x = self.dap_server.get_local_variable_child("pt", "x", is_hex=is_hex) self.assertEquals(var_pt_x["value"], "0x000b") var_pt_y = self.dap_server.get_local_variable_child("pt", "y", is_hex=is_hex) self.assertEquals(var_pt_y["value"], "0x0016") - + # Toggle and verify locals value format decimal again is_hex = False var_pt_x = self.dap_server.get_local_variable_child("pt", "x", is_hex=is_hex) self.assertEquals(var_pt_x["value"], "11") var_pt_y = self.dap_server.get_local_variable_child("pt", "y", is_hex=is_hex) `` https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff cf3c714e4bd7b8a68793f2827080fe3388ae8bb1 2daf4aeaee1ce9062dfa964f3baeef0d7477479c -- lldb/tools/lldb-dap/JSONUtils.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 55feab600a..206d08addf 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -988,7 +988,8 @@ VariableDescription::VariableDescription(lldb::SBValue v, bool format_hex, !raw_display_type_name.empty() ? raw_display_type_name : NO_TYPENAME; // Only format hex/default if there is no existing special format. - if (v.GetFormat() == lldb::eFormatDefault || v.GetFormat() == lldb::eFormatHex) { + if (v.GetFormat() == lldb::eFormatDefault || + v.GetFormat() == lldb::eFormatHex) { if (format_hex) v.SetFormat(lldb::eFormatHex); else `` https://github.com/llvm/llvm-project/pull/90799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 created https://github.com/llvm/llvm-project/pull/90799 While adding a UI feature in VSCode to toggle hex/dec in variables view window. I noticed that it does not work after second toggle. Then I noticed that there is a bug that we only explicitly set hex format not reset back to default during further toggle. The new test demonstrates the bug. This PR resets the format back to default if not using hex. One complexity is that, we explicitly set registers value format to AddressInfo, which shouldn't be overridden by default or hex settings. >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: