[Lldb-commits] [lldb] [lldb] Remove lldbutil.get_stack_frames (NFC) (PR #117505)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione closed 
https://github.com/llvm/llvm-project/pull/117505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 0bfc951 - [lldb] Remove lldbutil.get_stack_frames (NFC) (#117505)

2024-11-24 Thread via lldb-commits

Author: Dave Lee
Date: 2024-11-24T19:02:47-08:00
New Revision: 0bfc9514715b3beb967f1a245e9db310d2aafa50

URL: 
https://github.com/llvm/llvm-project/commit/0bfc9514715b3beb967f1a245e9db310d2aafa50
DIFF: 
https://github.com/llvm/llvm-project/commit/0bfc9514715b3beb967f1a245e9db310d2aafa50.diff

LOG: [lldb] Remove lldbutil.get_stack_frames (NFC) (#117505)

`SBThread.frames` can be used instead of `get_stack_frames`.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 660a3c085a908a..07b5f8cc7d900b 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1158,17 +1158,6 @@ def GetModuleName(i):
 return list(map(GetModuleName, list(range(thread.GetNumFrames()
 
 
-def get_stack_frames(thread):
-"""
-Returns a sequence of stack frames for this thread.
-"""
-
-def GetStackFrame(i):
-return thread.GetFrameAtIndex(i)
-
-return list(map(GetStackFrame, list(range(thread.GetNumFrames()
-
-
 def print_stacktrace(thread, string_buffer=False):
 """Prints a simple stack trace of this thread."""
 

diff  --git 
a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py 
b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
index f1c23a58d1f486..dbb9576ed4d51a 100644
--- a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
+++ b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
@@ -59,7 +59,7 @@ def test_source_line_breakpoint(self):
 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
 thread = process.GetSelectedThread()
-stack_frames = lldbutil.get_stack_frames(thread)
+stack_frames = thread.frames
 self.assertGreater(len(stack_frames), 2)
 
 leaf_frame = stack_frames[0]
@@ -97,7 +97,7 @@ def test_symbolic_breakpoint(self):
 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
 thread = process.GetSelectedThread()
-stack_frames = lldbutil.get_stack_frames(thread)
+stack_frames = thread.frames
 self.assertGreater(len(stack_frames), 2)
 
 leaf_frame = stack_frames[0]



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/117500

When printing an ObjC object, which is a pointer, lldb has handled it like it 
treats any
other pointer, printing only pointer address and class name. The object is not 
expanded,
and its children are not shown.

This change updates the dwim-print to print expanded objc pointers - it is 
assumed
that's what the user meant.

Note that this is currently possible using the `--ptr-depth`/`-P` flag, but the 
default
is 0. With this change, when dwim-print prints objc objects, the default is 
effectively
changed to 1.


>From 3199d3ee3817a8551cda1f5fce6083fef1c079d9 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sat, 23 Nov 2024 18:25:22 -0800
Subject: [PATCH] [lldb] Update dwim-print to show expanded objc instances

When printing an ObjC object, which is a pointer, lldb has handled it like it 
treats any
other pointer, printing only pointer address and class name. The object is not 
expanded,
and its children are not shown.

This change updates the dwim-print to print expanded objc pointers - it is 
assumed
that's what the user meant.

Note that this is currently possible using the `--ptr-depth`/`-P` flag, but the 
default
is 0. With this change, when dwim-print prints objc objects, the default is 
effectively
changed to 1.
---
 .../lldb/DataFormatters/DumpValueObjectOptions.h |  3 +++
 lldb/source/Commands/CommandObjectDWIMPrint.cpp  |  3 ++-
 .../DataFormatters/DumpValueObjectOptions.cpp|  6 ++
 .../source/DataFormatters/ValueObjectPrinter.cpp | 14 --
 lldb/test/API/commands/dwim-print/objc/Makefile  |  3 +++
 .../dwim-print/objc/TestDWIMPrintObjC.py | 16 
 lldb/test/API/commands/dwim-print/objc/main.m| 15 +++
 7 files changed, 53 insertions(+), 7 deletions(-)
 create mode 100644 lldb/test/API/commands/dwim-print/objc/Makefile
 create mode 100644 lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
 create mode 100644 lldb/test/API/commands/dwim-print/objc/main.m

diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..7e213f29b3bc0a 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -125,6 +125,8 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true);
 
+  DumpValueObjectOptions &SetExpandPointerTypeFlags(unsigned flags);
+
   DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0);
 
   DumpValueObjectOptions &
@@ -142,6 +144,7 @@ class DumpValueObjectOptions {
   DeclPrintingHelper m_decl_printing_helper;
   ChildPrintingDecider m_child_printing_decider;
   PointerAsArraySettings m_pointer_as_array;
+  unsigned m_expand_ptr_type_flags = 0;
   bool m_use_synthetic : 1;
   bool m_scope_already_checked : 1;
   bool m_flat_output : 1;
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 62c4e74d853ad1..8bfef15036cc7e 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -87,7 +87,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 
   DumpValueObjectOptions dump_options = m_varobj_options.GetAsDumpOptions(
   m_expr_options.m_verbosity, m_format_options.GetFormat());
-  dump_options.SetHideRootName(suppress_result);
+  dump_options.SetHideRootName(suppress_result)
+  .SetExpandPointerTypeFlags(lldb::eTypeIsObjC);
 
   bool is_po = m_varobj_options.use_objc;
 
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..a4db0d3cb240f1 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -201,6 +201,12 @@ DumpValueObjectOptions::SetRevealEmptyAggregates(bool 
reveal) {
   return *this;
 }
 
+DumpValueObjectOptions &
+DumpValueObjectOptions::SetExpandPointerTypeFlags(unsigned flags) {
+  m_expand_ptr_type_flags = flags;
+  return *this;
+}
+
 DumpValueObjectOptions &
 DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
   m_pointer_as_array = PointerAsArraySettings(element_count);
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..83db9292c5e76e 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -554,12 +554,14 @@ bool ValueObjectPrinter::ShouldPrintChildren(
   return false;
 
 const bool is_root_level = m_curr_depth == 0;
-
-if (is_ref && is_root_level && print_children) {
-  // If this is the root object (depth is zero) that we are showing and
-  // it is a reference, and no pointer depth has been supplied print out

[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2024-11-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes

When printing an ObjC object, which is a pointer, lldb has handled it like it 
treats any other pointer, printing only pointer address and class name. The 
object is not expanded, and its children are not shown.

This change updates the dwim-print to print expanded objc pointers - it is 
assumed that's what the user meant.

Note that this is currently possible using the `--ptr-depth`/`-P` flag, but the 
default is 0. With this change, when dwim-print prints objc objects, the 
default is effectively changed to 1.


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


7 Files Affected:

- (modified) lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h (+3) 
- (modified) lldb/source/Commands/CommandObjectDWIMPrint.cpp (+2-1) 
- (modified) lldb/source/DataFormatters/DumpValueObjectOptions.cpp (+6) 
- (modified) lldb/source/DataFormatters/ValueObjectPrinter.cpp (+8-6) 
- (added) lldb/test/API/commands/dwim-print/objc/Makefile (+3) 
- (added) lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py (+16) 
- (added) lldb/test/API/commands/dwim-print/objc/main.m (+15) 


``diff
diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..7e213f29b3bc0a 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -125,6 +125,8 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true);
 
+  DumpValueObjectOptions &SetExpandPointerTypeFlags(unsigned flags);
+
   DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0);
 
   DumpValueObjectOptions &
@@ -142,6 +144,7 @@ class DumpValueObjectOptions {
   DeclPrintingHelper m_decl_printing_helper;
   ChildPrintingDecider m_child_printing_decider;
   PointerAsArraySettings m_pointer_as_array;
+  unsigned m_expand_ptr_type_flags = 0;
   bool m_use_synthetic : 1;
   bool m_scope_already_checked : 1;
   bool m_flat_output : 1;
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 62c4e74d853ad1..8bfef15036cc7e 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -87,7 +87,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 
   DumpValueObjectOptions dump_options = m_varobj_options.GetAsDumpOptions(
   m_expr_options.m_verbosity, m_format_options.GetFormat());
-  dump_options.SetHideRootName(suppress_result);
+  dump_options.SetHideRootName(suppress_result)
+  .SetExpandPointerTypeFlags(lldb::eTypeIsObjC);
 
   bool is_po = m_varobj_options.use_objc;
 
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..a4db0d3cb240f1 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -201,6 +201,12 @@ DumpValueObjectOptions::SetRevealEmptyAggregates(bool 
reveal) {
   return *this;
 }
 
+DumpValueObjectOptions &
+DumpValueObjectOptions::SetExpandPointerTypeFlags(unsigned flags) {
+  m_expand_ptr_type_flags = flags;
+  return *this;
+}
+
 DumpValueObjectOptions &
 DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
   m_pointer_as_array = PointerAsArraySettings(element_count);
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..83db9292c5e76e 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -554,12 +554,14 @@ bool ValueObjectPrinter::ShouldPrintChildren(
   return false;
 
 const bool is_root_level = m_curr_depth == 0;
-
-if (is_ref && is_root_level && print_children) {
-  // If this is the root object (depth is zero) that we are showing and
-  // it is a reference, and no pointer depth has been supplied print out
-  // what it references. Don't do this at deeper depths otherwise we can
-  // end up with infinite recursion...
+const bool is_expanded_ptr =
+is_ptr && m_type_flags.Test(m_options.m_expand_ptr_type_flags);
+
+if ((is_ref || is_expanded_ptr) && is_root_level && print_children) {
+  // If this is the root object (depth is zero) that we are showing and it
+  // is either a reference or a preferred type of pointer, then print it.
+  // Don't do this at deeper depths otherwise we can end up with infinite
+  // recursion...
   return true;
 }
 
diff --git a/lldb/test/API/commands/dwim-print/objc/Makefile 
b/lldb/test/API/commands/dwim-print/objc/Makefile
new file mode 100644
index 00..845553d5e3f2f3
--- /dev/null
+++ b/lldb/test/API/commands/dwim-print/objc/Makefile
@@ -0,0 

[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione edited 
https://github.com/llvm/llvm-project/pull/117500
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix TestLoadUnload.py (PR #117416)

2024-11-24 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman approved this pull request.

I have tested this patch and can confirm that it fixes the issue.

https://github.com/llvm/llvm-project/pull/117416
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2024-11-24 Thread via lldb-commits

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 
0a6d797c20f6ab53bc09fb66129f603ed6e4b524...3199d3ee3817a8551cda1f5fce6083fef1c079d9
 lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
``





View the diff from darker here.


``diff
--- TestDWIMPrintObjC.py2024-11-24 18:23:16.00 +
+++ TestDWIMPrintObjC.py2024-11-24 18:27:01.810738 +
@@ -7,10 +7,9 @@
 from lldbsuite.test.decorators import *
 import lldbsuite.test.lldbutil as lldbutil
 
 
 class TestCase(TestBase):
-
 def test(self):
 self.build()
 lldbutil.run_to_source_breakpoint(self, "break here", 
lldb.SBFileSpec("main.m"))
 self.expect("dwim-print obj", substrs=["_number = 15"])

``




https://github.com/llvm/llvm-project/pull/117500
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Set return status to Failed when Python command raises uncaught exception (PR #113996)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/113996

>From 75f96b84c9bd2b3211edb5fa8806092711133251 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Mon, 28 Oct 2024 15:49:50 -0700
Subject: [PATCH 1/6] [lldb] Set return status to Failed when Python command
 raises uncaught exception

---
 lldb/bindings/python/python-wrapper.swig  | 13 +++--
 .../script/exception/TestCommandException.py  | 27 +++
 .../command/script/exception/throw_command.py |  6 +
 3 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/test/API/commands/command/script/exception/TestCommandException.py
 create mode 100644 
lldb/test/API/commands/command/script/exception/throw_command.py

diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index b72a462d04643b..dfe762e026788a 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -592,6 +592,8 @@ void 
*lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(PyOb
   return sb_ptr;
 }
 
+#include "lldb/Interpreter/CommandReturnObject.h"
+
 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
 const char *python_function_name, const char *session_dictionary_name,
 lldb::DebuggerSP debugger, const char *args,
@@ -621,6 +623,9 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
 pfunc(debugger_arg, PythonString(args),
   SWIGBridge::ToSWIGWrapper(std::move(exe_ctx_ref_sp)), 
cmd_retobj_arg.obj(), dict);
 
+  if (PyErr_Occurred())
+cmd_retobj.SetStatus(eReturnStatusFailed);
+
   return true;
 }
 
@@ -642,6 +647,9 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), PythonString(args),
 SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
 
+  if (PyErr_Occurred())
+cmd_retobj.SetStatus(eReturnStatusFailed);
+
   return true;
 }
 
@@ -740,8 +748,6 @@ 
lldb_private::python::SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionFo
   return dict_sp;
 }
 
-#include "lldb/Interpreter/CommandReturnObject.h"
-
 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
 PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl &args_impl,
 lldb_private::CommandReturnObject &cmd_retobj,
@@ -760,6 +766,9 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
   pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), 
SWIGBridge::ToSWIGWrapper(args_impl),
 SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), 
SWIGBridge::ToSWIGWrapper(cmd_retobj).obj());
 
+  if (PyErr_Occurred())
+cmd_retobj.SetStatus(eReturnStatusFailed);
+
   return true;
 }
 
diff --git 
a/lldb/test/API/commands/command/script/exception/TestCommandException.py 
b/lldb/test/API/commands/command/script/exception/TestCommandException.py
new file mode 100644
index 00..73484137d82b3e
--- /dev/null
+++ b/lldb/test/API/commands/command/script/exception/TestCommandException.py
@@ -0,0 +1,27 @@
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test(self):
+"""
+Check that a Python command, which raises an unhandled exception, has
+its status set to failed.
+"""
+command_path = os.path.join(self.getSourceDir(), "throw_command.py")
+self.runCmd(f"command script import {command_path}")
+
+with open(os.devnull, "w") as devnull:
+self.dbg.SetErrorFileHandle(devnull, False)
+result = lldb.SBCommandReturnObject()
+self.ci.HandleCommand("throw", result)
+
+self.assertEqual(
+result.GetStatus(),
+lldb.eReturnStatusFailed,
+"command unexpectedly succeeded",
+)
diff --git a/lldb/test/API/commands/command/script/exception/throw_command.py 
b/lldb/test/API/commands/command/script/exception/throw_command.py
new file mode 100644
index 00..7c4989850cb19a
--- /dev/null
+++ b/lldb/test/API/commands/command/script/exception/throw_command.py
@@ -0,0 +1,6 @@
+import lldb
+
+
+@lldb.command()
+def throw(debugger, cmd, ctx, result, _):
+raise Exception("command failed")

>From b64f5ac38b31a1098ca31183f2bfdae4a6069306 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 29 Oct 2024 09:37:32 -0700
Subject: [PATCH 2/6] Reset error file handle

---
 .../commands/command/script/exception/TestCommandException.py| 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/commands/command/script/exception/TestCommandException.py 
b/lldb/test/API/commands/command/script/exception/TestCommandException.py
index 73484137d82b3e..6a673b7589d87e 100644
--- a/lldb/test/API/commands/command/script/exception/TestCommandException.py
+++ b/lldb/test/A

[Lldb-commits] [lldb] [lldb] Set return status to Failed when Python command raises uncaught exception (PR #113996)

2024-11-24 Thread Dave Lee via lldb-commits


@@ -642,6 +649,16 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), PythonString(args),
 SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
 
+  if (PyErr_Occurred()) {
+py_err_cleaner.~PyErr_Cleaner();

kastiglione wrote:

I replaced the explicit destructor call.

The change to `PythonCallable::operator()` sounds good, but looks like a wide 
ranging change. I'll set that aside for a future change.

https://github.com/llvm/llvm-project/pull/113996
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Set return status to Failed when Python command raises uncaught exception (PR #113996)

2024-11-24 Thread Dave Lee via lldb-commits


@@ -592,6 +592,8 @@ void 
*lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(PyOb
   return sb_ptr;
 }
 
+#include "lldb/Interpreter/CommandReturnObject.h"

kastiglione wrote:

done

https://github.com/llvm/llvm-project/pull/113996
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

2024-11-24 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/117401

>From b6051edba2a1ecae144ead48712fb511c204131a Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Fri, 22 Nov 2024 15:33:42 -0800
Subject: [PATCH 1/2] [LLDB] Fix error returns in CastToBasicType and
 CastToEnumType in ValueObject.

Update the error returns in ValueObject::CastToBasicType and
ValueObject::CastToEnumType to create new errors and return a
ValueObjectConstResult with the error, rather tnan updating the error in
(and returning) the input ValueObject.
---
 lldb/source/ValueObject/ValueObject.cpp | 87 +++--
 1 file changed, 53 insertions(+), 34 deletions(-)

diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 86172ad1b561f9..1093c4b665f4eb 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -3194,16 +3194,19 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
   GetCompilerType().IsPointerType() || GetCompilerType().IsNullPtrType();
   bool is_float = GetCompilerType().IsFloat();
   bool is_integer = GetCompilerType().IsInteger();
+  ExecutionContext exe_ctx(GetExecutionContextRef());
 
   if (!type.IsScalarType()) {
-m_error = Status::FromErrorString("target type must be a scalar");
-return GetSP();
+Status error = Status::FromErrorString("target type must be a scalar");
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 
   if (!is_scalar && !is_enum && !is_pointer) {
-m_error =
+Status error =
 Status::FromErrorString("argument must be a scalar, enum, or pointer");
-return GetSP();
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 
   lldb::TargetSP target = GetTargetSP();
@@ -3216,14 +3219,16 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 
   if (is_pointer) {
 if (!type.IsInteger() && !type.IsBoolean()) {
-  m_error =
+  Status error =
   Status::FromErrorString("target type must be an integer or boolean");
-  return GetSP();
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(), error.Clone());
 }
 if (!type.IsBoolean() && type_byte_size < val_byte_size) {
-  m_error = Status::FromErrorString(
+  Status error = Status::FromErrorString(
   "target type cannot be smaller than the pointer type");
-  return GetSP();
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(), error.Clone());
 }
   }
 
@@ -3237,10 +3242,11 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 return ValueObject::CreateValueObjectFromBool(
 target, !float_value_or_err->isZero(), "result");
   else {
-m_error = Status::FromErrorStringWithFormat(
+Status error = Status::FromErrorStringWithFormat(
 "cannot get value as APFloat: %s",
 llvm::toString(float_value_or_err.takeError()).c_str());
-return GetSP();
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 }
   }
@@ -3256,11 +3262,12 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 return ValueObject::CreateValueObjectFromAPInt(target, ext, type,
"result");
   } else {
-m_error = Status::FromErrorStringWithFormat(
+Status error = Status::FromErrorStringWithFormat(
 "cannot get value as APSInt: %s",
 llvm::toString(int_value_or_err.takeError()).c_str());
 ;
-return GetSP();
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 } else if (is_scalar && is_float) {
   llvm::APSInt integer(type_byte_size * CHAR_BIT, !type.IsSigned());
@@ -3274,10 +3281,11 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 // Casting floating point values that are out of bounds of the target
 // type is undefined behaviour.
 if (status & llvm::APFloatBase::opInvalidOp) {
-  m_error = Status::FromErrorStringWithFormat(
+  Status error = Status::FromErrorStringWithFormat(
   "invalid type cast detected: %s",
   llvm::toString(float_value_or_err.takeError()).c_str());
-  return GetSP();
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(), error.Clone());
 }
 return ValueObject::CreateValueObjectFromAPInt(target, integer, type,
"result");
@@ -3297,10 +3305,11 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
   

[Lldb-commits] [lldb] c2ffb42 - [lldb] Fix TestLoadUnload.py (#117416)

2024-11-24 Thread via lldb-commits

Author: Kazuki Sakamoto
Date: 2024-11-24T11:04:47-08:00
New Revision: c2ffb42893eb543f64169e32851e00352feaca69

URL: 
https://github.com/llvm/llvm-project/commit/c2ffb42893eb543f64169e32851e00352feaca69
DIFF: 
https://github.com/llvm/llvm-project/commit/c2ffb42893eb543f64169e32851e00352feaca69.diff

LOG: [lldb] Fix TestLoadUnload.py (#117416)

ELF core debugging fix #117070 broke TestLoadUnload.py tests due to
GetModuleSpec call, ProcessGDBRemote fetches modules from remote. Revise
the original PR, renamed FindBuildId to FindModuleUUID.

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/source/Core/DynamicLoader.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index b8c53a474ba6b9..a184e6dd891aff 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1380,6 +1380,8 @@ class Process : public 
std::enable_shared_from_this,
 
   virtual bool GetProcessInfo(ProcessInstanceInfo &info);
 
+  virtual lldb_private::UUID FindModuleUUID(const llvm::StringRef path);
+
   /// Get the exit status for a process.
   ///
   /// \return

diff  --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index 3c6c6bd365706e..acc84dbf016fbe 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -157,11 +157,9 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP 
module) const {
 ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) {
   Target &target = m_process->GetTarget();
   ModuleSpec module_spec(file, target.GetArchitecture());
-  ModuleSpec module_spec_from_process;
-  // Process may be able to augment the module_spec with UUID, e.g. ELF core.
-  if (m_process->GetModuleSpec(file, target.GetArchitecture(),
-   module_spec_from_process)) {
-module_spec = module_spec_from_process;
+  if (UUID uuid = m_process->FindModuleUUID(file.GetPath())) {
+// Process may be able to augment the module_spec with UUID, e.g. ELF core.
+module_spec.GetUUID() = uuid;
   }
 
   if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec))

diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 57b12f07b5e0be..b3916cc913f7db 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -286,20 +286,12 @@ void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
   }
 }
 
-bool ProcessElfCore::GetModuleSpec(const FileSpec &module_file_spec,
-   const ArchSpec &arch,
-   ModuleSpec &module_spec) {
-  module_spec.Clear();
-  for (NT_FILE_Entry &entry : m_nt_file_entries) {
-if (module_file_spec.GetPath() == entry.path) {
-  module_spec.GetFileSpec() = module_file_spec;
-  module_spec.GetArchitecture() = arch;
-  module_spec.GetUUID() = entry.uuid;
-  return true;
-}
-  }
-
-  return false;
+UUID ProcessElfCore::FindModuleUUID(const llvm::StringRef path) {
+  // Returns the gnu uuid from matched NT_FILE entry
+  for (NT_FILE_Entry &entry : m_nt_file_entries)
+if (path == entry.path)
+  return entry.uuid;
+  return UUID();
 }
 
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {

diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index a7b1822ccf01ff..a91c04a277f601 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -163,9 +163,7 @@ class ProcessElfCore : public 
lldb_private::PostMortemProcess {
   // Populate gnu uuid for each NT_FILE entry
   void UpdateBuildIdForNTFileEntries();
 
-  bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
- const lldb_private::ArchSpec &arch,
- lldb_private::ModuleSpec &module_spec) override;
+  lldb_private::UUID FindModuleUUID(const llvm::StringRef path) override;
 
   // Returns the value of certain type of note of a given start address
   lldb_private::UUID FindBuidIdInCoreMemory(lldb::addr_t address);

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 9125ceca74a003..db33525978a16a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6080,6 +6080,10 @@ bool Process::GetProcessInfo(ProcessInstanceInfo &info) {
   return platform_sp->GetProcessInfo(GetID(), info);
 }
 
+lldb_private::UUID Process::FindModuleUUID(const llvm::StringRef path) {
+  return lldb_private::UUID();
+}
+
 ThreadCollectionSP Process::Get

[Lldb-commits] [lldb] [lldb] Remove lldbutil.get_stack_frames (NFC) (PR #117505)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/117505

None

>From eda4536f9e9edcb36c64592f4afd7820c81d65f3 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sun, 24 Nov 2024 11:10:35 -0800
Subject: [PATCH] [lldb] Remove lldbutil.get_stack_frames (NFC)

---
 lldb/packages/Python/lldbsuite/test/lldbutil.py   | 11 ---
 .../shared_library/TestSharedLibOnDemand.py   |  4 ++--
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 660a3c085a908a..07b5f8cc7d900b 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1158,17 +1158,6 @@ def GetModuleName(i):
 return list(map(GetModuleName, list(range(thread.GetNumFrames()
 
 
-def get_stack_frames(thread):
-"""
-Returns a sequence of stack frames for this thread.
-"""
-
-def GetStackFrame(i):
-return thread.GetFrameAtIndex(i)
-
-return list(map(GetStackFrame, list(range(thread.GetNumFrames()
-
-
 def print_stacktrace(thread, string_buffer=False):
 """Prints a simple stack trace of this thread."""
 
diff --git 
a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py 
b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
index f1c23a58d1f486..dbb9576ed4d51a 100644
--- a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
+++ b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
@@ -59,7 +59,7 @@ def test_source_line_breakpoint(self):
 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
 thread = process.GetSelectedThread()
-stack_frames = lldbutil.get_stack_frames(thread)
+stack_frames = thread.frames
 self.assertGreater(len(stack_frames), 2)
 
 leaf_frame = stack_frames[0]
@@ -97,7 +97,7 @@ def test_symbolic_breakpoint(self):
 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
 thread = process.GetSelectedThread()
-stack_frames = lldbutil.get_stack_frames(thread)
+stack_frames = thread.frames
 self.assertGreater(len(stack_frames), 2)
 
 leaf_frame = stack_frames[0]

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove lldbutil.get_stack_frames (NFC) (PR #117505)

2024-11-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes

`SBThread.frames` can be used instead of `get_stack_frames`.

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


2 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbutil.py (-11) 
- (modified) 
lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py (+2-2) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 660a3c085a908a..07b5f8cc7d900b 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1158,17 +1158,6 @@ def GetModuleName(i):
 return list(map(GetModuleName, list(range(thread.GetNumFrames()
 
 
-def get_stack_frames(thread):
-"""
-Returns a sequence of stack frames for this thread.
-"""
-
-def GetStackFrame(i):
-return thread.GetFrameAtIndex(i)
-
-return list(map(GetStackFrame, list(range(thread.GetNumFrames()
-
-
 def print_stacktrace(thread, string_buffer=False):
 """Prints a simple stack trace of this thread."""
 
diff --git 
a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py 
b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
index f1c23a58d1f486..dbb9576ed4d51a 100644
--- a/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
+++ b/lldb/test/API/symbol_ondemand/shared_library/TestSharedLibOnDemand.py
@@ -59,7 +59,7 @@ def test_source_line_breakpoint(self):
 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
 thread = process.GetSelectedThread()
-stack_frames = lldbutil.get_stack_frames(thread)
+stack_frames = thread.frames
 self.assertGreater(len(stack_frames), 2)
 
 leaf_frame = stack_frames[0]
@@ -97,7 +97,7 @@ def test_symbolic_breakpoint(self):
 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
 thread = process.GetSelectedThread()
-stack_frames = lldbutil.get_stack_frames(thread)
+stack_frames = thread.frames
 self.assertGreater(len(stack_frames), 2)
 
 leaf_frame = stack_frames[0]

``




https://github.com/llvm/llvm-project/pull/117505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove lldbutil.get_stack_frames (NFC) (PR #117505)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione edited 
https://github.com/llvm/llvm-project/pull/117505
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (PR #117504)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/117504

`Mode::Always` and `Mode::Default` are handled identically. `Mode::Never` is 
the same as
having a count of 0.


>From 92e1118f6f62aae0c98485fecc8598a95dc44ab7 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sun, 24 Nov 2024 11:01:06 -0800
Subject: [PATCH] [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC)

`Mode::Always` and `Mode::Default` are handled identically. `Mode::Never` is 
the same as
having a count of 0.
---
 .../lldb/DataFormatters/DumpValueObjectOptions.h   | 10 --
 lldb/source/DataFormatters/DumpValueObjectOptions.cpp  | 10 --
 lldb/source/DataFormatters/ValueObjectPrinter.cpp  |  9 +
 .../Interpreter/OptionGroupValueObjectDisplay.cpp  |  3 +--
 4 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..ce15963ab5662c 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -22,13 +22,12 @@ namespace lldb_private {
 class DumpValueObjectOptions {
 public:
   struct PointerDepth {
-enum class Mode { Always, Default, Never } m_mode;
-uint32_t m_count;
+uint32_t m_count = 0;
 
 PointerDepth Decremented() const {
   if (m_count > 0)
-return PointerDepth{m_mode, m_count - 1};
-  return PointerDepth{m_mode, m_count};
+return {m_count - 1};
+  return *this;
 }
 
 bool CanAllowExpansion() const;
@@ -65,8 +64,7 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions(ValueObject &valobj);
 
-  DumpValueObjectOptions &
-  SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
+  DumpValueObjectOptions &SetMaximumPointerDepth(uint32_t depth);
 
   DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default);
 
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..b952fb643f13ef 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -14,10 +14,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 DumpValueObjectOptions::DumpValueObjectOptions()
-: m_summary_sp(), m_root_valobj_name(),
-  m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
-  m_decl_printing_helper(), m_child_printing_decider(),
-  m_pointer_as_array(), m_use_synthetic(true),
+: m_summary_sp(), m_root_valobj_name(), m_decl_printing_helper(),
+  m_child_printing_decider(), m_pointer_as_array(), m_use_synthetic(true),
   m_scope_already_checked(false), m_flat_output(false), 
m_ignore_cap(false),
   m_show_types(false), m_show_location(false), m_use_objc(false),
   m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
@@ -33,8 +31,8 @@ DumpValueObjectOptions::DumpValueObjectOptions(ValueObject 
&valobj)
 }
 
 DumpValueObjectOptions &
-DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
-  m_max_ptr_depth = depth;
+DumpValueObjectOptions::SetMaximumPointerDepth(uint32_t depth) {
+  m_max_ptr_depth = {depth};
   return *this;
 }
 
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..01e604e019f25f 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -503,14 +503,7 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool 
value_printed,
 }
 
 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
-  switch (m_mode) {
-  case Mode::Always:
-  case Mode::Default:
-return m_count > 0;
-  case Mode::Never:
-return false;
-  }
-  return false;
+  return m_count > 0;
 }
 
 bool ValueObjectPrinter::ShouldPrintChildren(
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp 
b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 0e8c1f4b5f1d9a..d633c469e603ec 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -190,8 +190,7 @@ DumpValueObjectOptions 
OptionGroupValueObjectDisplay::GetAsDumpOptions(
 LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity,
 lldb::Format format, lldb::TypeSummaryImplSP summary_sp) {
   DumpValueObjectOptions options;
-  options.SetMaximumPointerDepth(
-  {DumpValueObjectOptions::PointerDepth::Mode::Always, ptr_depth});
+  options.SetMaximumPointerDepth(ptr_depth);
   if (use_objc)
 options.SetShowSummary(false);
   else

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (PR #117504)

2024-11-24 Thread Dave Lee via lldb-commits

https://github.com/kastiglione edited 
https://github.com/llvm/llvm-project/pull/117504
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix TestLoadUnload.py (PR #117416)

2024-11-24 Thread Kazuki Sakamoto via lldb-commits

https://github.com/splhack closed 
https://github.com/llvm/llvm-project/pull/117416
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (PR #117504)

2024-11-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes

`Mode::Always` and `Mode::Default` are handled identically. `Mode::Never` is 
the same as having a count of 0.


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


4 Files Affected:

- (modified) lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h (+4-6) 
- (modified) lldb/source/DataFormatters/DumpValueObjectOptions.cpp (+4-6) 
- (modified) lldb/source/DataFormatters/ValueObjectPrinter.cpp (+1-8) 
- (modified) lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp (+1-2) 


``diff
diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..ce15963ab5662c 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -22,13 +22,12 @@ namespace lldb_private {
 class DumpValueObjectOptions {
 public:
   struct PointerDepth {
-enum class Mode { Always, Default, Never } m_mode;
-uint32_t m_count;
+uint32_t m_count = 0;
 
 PointerDepth Decremented() const {
   if (m_count > 0)
-return PointerDepth{m_mode, m_count - 1};
-  return PointerDepth{m_mode, m_count};
+return {m_count - 1};
+  return *this;
 }
 
 bool CanAllowExpansion() const;
@@ -65,8 +64,7 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions(ValueObject &valobj);
 
-  DumpValueObjectOptions &
-  SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
+  DumpValueObjectOptions &SetMaximumPointerDepth(uint32_t depth);
 
   DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default);
 
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..b952fb643f13ef 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -14,10 +14,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 DumpValueObjectOptions::DumpValueObjectOptions()
-: m_summary_sp(), m_root_valobj_name(),
-  m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
-  m_decl_printing_helper(), m_child_printing_decider(),
-  m_pointer_as_array(), m_use_synthetic(true),
+: m_summary_sp(), m_root_valobj_name(), m_decl_printing_helper(),
+  m_child_printing_decider(), m_pointer_as_array(), m_use_synthetic(true),
   m_scope_already_checked(false), m_flat_output(false), 
m_ignore_cap(false),
   m_show_types(false), m_show_location(false), m_use_objc(false),
   m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
@@ -33,8 +31,8 @@ DumpValueObjectOptions::DumpValueObjectOptions(ValueObject 
&valobj)
 }
 
 DumpValueObjectOptions &
-DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
-  m_max_ptr_depth = depth;
+DumpValueObjectOptions::SetMaximumPointerDepth(uint32_t depth) {
+  m_max_ptr_depth = {depth};
   return *this;
 }
 
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..01e604e019f25f 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -503,14 +503,7 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool 
value_printed,
 }
 
 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
-  switch (m_mode) {
-  case Mode::Always:
-  case Mode::Default:
-return m_count > 0;
-  case Mode::Never:
-return false;
-  }
-  return false;
+  return m_count > 0;
 }
 
 bool ValueObjectPrinter::ShouldPrintChildren(
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp 
b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 0e8c1f4b5f1d9a..d633c469e603ec 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -190,8 +190,7 @@ DumpValueObjectOptions 
OptionGroupValueObjectDisplay::GetAsDumpOptions(
 LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity,
 lldb::Format format, lldb::TypeSummaryImplSP summary_sp) {
   DumpValueObjectOptions options;
-  options.SetMaximumPointerDepth(
-  {DumpValueObjectOptions::PointerDepth::Mode::Always, ptr_depth});
+  options.SetMaximumPointerDepth(ptr_depth);
   if (use_objc)
 options.SetShowSummary(false);
   else

``




https://github.com/llvm/llvm-project/pull/117504
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits