[Lldb-commits] [PATCH] D117288: [LLDB][NFC] Fix a typo in comment

2022-01-14 Thread Celeste Liu via Phabricator via lldb-commits
CoelacanthusHex created this revision.
CoelacanthusHex requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

fix typo in comment: libcstd++ -> libstdc++


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117288

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py


Index: lldb/examples/synthetic/gnu_libstdcpp.py
===
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -2,7 +2,7 @@
 import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
-# As there are many versions of the libcstd++, you are encouraged to look at 
the STL
+# As there are many versions of the libstdc++, you are encouraged to look at 
the STL
 # implementation for your platform before relying on these formatters to do 
the right
 # thing for your setup
 


Index: lldb/examples/synthetic/gnu_libstdcpp.py
===
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -2,7 +2,7 @@
 import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
-# As there are many versions of the libcstd++, you are encouraged to look at the STL
+# As there are many versions of the libstdc++, you are encouraged to look at the STL
 # implementation for your platform before relying on these formatters to do the right
 # thing for your setup
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3dc858f - [LLDB] Skip TestIOHandlerPythonREPLSigint.py on Arm/Linux

2022-01-14 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2022-01-14T15:46:54+05:00
New Revision: 3dc858f9847d1c2dc02e92ad703060b1bfa90ad0

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

LOG: [LLDB] Skip TestIOHandlerPythonREPLSigint.py on Arm/Linux

TestIOHandlerPythonREPLSigint.py is failing on Arm/Linux buildbot. I am
marking it as skip for now.

Added: 


Modified: 
lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py

Removed: 




diff  --git a/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py 
b/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py
index a1a27c2baded8..20d18ca974744 100644
--- a/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py
+++ b/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py
@@ -25,6 +25,7 @@ def start_python_repl(self):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfWindows
+@skipIf(oslist=["linux"], archs=["arm"])
 def test_while_evaluating_code(self):
 """ Tests SIGINT handling while Python code is being evaluated."""
 self.start_python_repl()



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


[Lldb-commits] [PATCH] D117299: [lldb] Ignore non-address bits in "memory find" arguments

2022-01-14 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This removes the non-address bits before we try to use
the addresses.

Meaning that when results are shown, those results won't
show non-address bits either. This follows what "memory read"
has done. On the grounds that non-address bits are a property
of a pointer, not the memory pointed to.

I've added testing and merged the find and read tests into one
file.

Note that there are no API side changes because "memory find"
does not have an equivalent API call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117299

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/API/linux/aarch64/tagged_memory_access/Makefile
  
lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
  lldb/test/API/linux/aarch64/tagged_memory_access/main.c
  lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
  
lldb/test/API/linux/aarch64/tagged_memory_read/TestAArch64LinuxTaggedMemoryRead.py
  lldb/test/API/linux/aarch64/tagged_memory_read/main.c

Index: lldb/test/API/linux/aarch64/tagged_memory_access/main.c
===
--- lldb/test/API/linux/aarch64/tagged_memory_access/main.c
+++ lldb/test/API/linux/aarch64/tagged_memory_access/main.c
@@ -5,11 +5,15 @@
   return (char *)((size_t)ptr | (tag << 56));
 }
 
-int main(int argc, char const *argv[]) {
-  char buf[32];
+// Global to zero init
+char buf[32];
 
+int main(int argc, char const *argv[]) {
   char *ptr1 = set_non_address_bits(buf, 0x34);
   char *ptr2 = set_non_address_bits(buf, 0x56);
 
+  // Target value for "memory find"
+  buf[15] = '?';
+
   return 0; // Set break point at this line.
 }
Index: lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
===
--- lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
+++ lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
@@ -1,6 +1,9 @@
 """
-Test that "memory read" removes non address bits from
-memory read arguments.
+Test that "memory read" and "memory find" remove non address bits from
+address arguments.
+
+These tests use the top byte ignore feature of AArch64. Which Linux
+always enables.
 """
 
 
@@ -17,10 +20,7 @@
 
 NO_DEBUG_INFO_TESTCASE = True
 
-# AArch64 Linux always enables top byte ignore
-@skipUnlessArch("aarch64")
-@skipUnlessPlatform(["linux"])
-def test_tagged_memory_read(self):
+def setup_test(self):
 self.build()
 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
@@ -37,6 +37,11 @@
 substrs=['stopped',
  'stop reason = breakpoint'])
 
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+def test_tagged_memory_read(self):
+self.setup_test()
+
 # If we do not remove non address bits, this can fail in two ways.
 # 1. We attempt to read much more than 16 bytes, probably more than
 #the default 1024 byte read size. Which will error.
@@ -53,3 +58,26 @@
 # Would fail if we don't remove non address bits because 0x56... > 0x34...
 self.expect("memory read ptr2 ptr1+16", patterns=[tagged_addr_pattern], matching=False)
 self.expect("memory read", patterns=[tagged_addr_pattern], matching=False)
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+def test_tagged_memory_find(self):
+self.setup_test()
+
+# If memory find doesn't remove non-address bits one of two
+# things happen.
+# 1. It tries to search a gigantic amount of memory.
+#We're not going to to test for this because a failure
+#would take a very long time and perhaps even find the
+#target value randomly.
+# 2. It thinks high address <= low address, which we check below.
+
+self.runCmd("memory find -s '?' ptr2 ptr1+32")
+
+self.assertTrue(self.res.Succeeded())
+out = self.res.GetOutput()
+# memory find does not fail when it doesn't find the data.
+# First check we actually got something.
+self.assertRegexpMatches(out, "data found at location: 0x[0-9A-Fa-f]+")
+# Then that the location found does not display the tag bits.
+self.assertNotRegexpMatches(out, "data found at location: 0x(34|56)[0-9A-Fa-f]+")
Index: lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
@@ -1,3 +0,0 @@
-C_SOURCES := main.c
-
-include Makefile.rules
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
-

[Lldb-commits] [PATCH] D117288: [LLDB][NFC] Fix a typo in comment

2022-01-14 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117288/new/

https://reviews.llvm.org/D117288

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


[Lldb-commits] [lldb] 1dab5f6 - [LLDB][NFC] Fix a typo in comment

2022-01-14 Thread via lldb-commits

Author: Coelacanthus
Date: 2022-01-14T22:01:18+08:00
New Revision: 1dab5f6c83a7745852743a39809ff6115159ed1d

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

LOG: [LLDB][NFC] Fix a typo in comment

fix typo in comment: libcstd++ -> libstdc++

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D117288

Added: 


Modified: 
lldb/examples/synthetic/gnu_libstdcpp.py

Removed: 




diff  --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 022071322d05..a371a77c6c74 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -2,7 +2,7 @@
 import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
-# As there are many versions of the libcstd++, you are encouraged to look at 
the STL
+# As there are many versions of the libstdc++, you are encouraged to look at 
the STL
 # implementation for your platform before relying on these formatters to do 
the right
 # thing for your setup
 



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


[Lldb-commits] [PATCH] D117288: [LLDB][NFC] Fix a typo in comment

2022-01-14 Thread Celeste Liu via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1dab5f6c83a7: [LLDB][NFC] Fix a typo in comment (authored by 
CoelacanthusHex).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117288/new/

https://reviews.llvm.org/D117288

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py


Index: lldb/examples/synthetic/gnu_libstdcpp.py
===
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -2,7 +2,7 @@
 import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
-# As there are many versions of the libcstd++, you are encouraged to look at 
the STL
+# As there are many versions of the libstdc++, you are encouraged to look at 
the STL
 # implementation for your platform before relying on these formatters to do 
the right
 # thing for your setup
 


Index: lldb/examples/synthetic/gnu_libstdcpp.py
===
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -2,7 +2,7 @@
 import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
-# As there are many versions of the libcstd++, you are encouraged to look at the STL
+# As there are many versions of the libstdc++, you are encouraged to look at the STL
 # implementation for your platform before relying on these formatters to do the right
 # thing for your setup
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D114668: [lldb][NFC] Move generic DWARFASTParser code out of Clang-specific code

2022-01-14 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

Ping @shafik @bulbazord . Can you re-review?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114668/new/

https://reviews.llvm.org/D114668

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


[Lldb-commits] [PATCH] D117071: [lldb/Plugins] Add support of multiple ScriptedThreads in a ScriptedProcess

2022-01-14 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp:49
 
+  void *instance_obj = nullptr;
+  if (script_object)

mib wrote:
> labath wrote:
> > This is when things start to get fuzzy, as this function seems to support 
> > both a nullptr and a non-nullptr argument. Not necessarily bad, but it 
> > makes reasoning about anything harder. It'd be better if this function 
> > could always be called with a valid object.
> I understand but even if it might be possible to do it for ScriptedThreads, 
> we want to give the user multiple way of creating them (in lldb or directly 
> from python).
While not ideal, I don't think this is a big deal. I might consider passing the 
`script_object` to the `CreatePluginObject` though -- it would make a typed 
interface, and avoid a branch here.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp:56
   m_object_instance_sp =
-  StructuredData::GenericSP(new StructuredPythonObject(ret_val));
+  StructuredData::GenericSP(new StructuredPythonObject(instance_obj));
 

mib wrote:
> labath wrote:
> > now this maybe-owned reference gets passed into a `StructuredPythonObject` 
> > which assumes it is getting a borrowed reference (it does an incref).
> > 
> > That seems correct in the instance_obj@entry != nullptr case, but not in 
> > the other one (=> leak).
> I might be missing something but I don't understand why does the 
> `StructuredPythonObject` **expects** a borrowed reference ?
> Why can't it wrap an owned reference ?
> 
> I think checking the `PyObject` type (Borrowed/Owned) on the 
> `StructuredPythonObject` constructor would allow us to `incref` it only in 
> the case of a borrowed ref, and fix the leak in the case of an owned ref, 
> right ?
> Why can't it wrap an owned reference ?
There's no reason it *can't* do that. It's just that it doesn't do that now.

> checking the PyObject type (Borrowed/Owned)
borrowedness/ownedness is not a real property of the PyObject. It's just an 
abstract notion describing the relationship between a reference (PyObject 
instance) and code handling that reference. If some code "owns" a reference it 
is responsible for (eventually) freeing (decreffing) it (or passing the 
ownership onto someone else, etc.) If some code "borrows" a reference, then it 
must not free it, and it must be careful to not use it after the actual owner 
frees it.

The reference received through the `instance_obj` is borrowed since the 
`thread_info_sp` destructor will eventually free it. The reference created 
through `LLDBSwigPythonCreateScriptedThread` is owned. The fact that you have 
owning and non-owning code paths converging means one of them is incorrect.

The fix is actually pretty straightforward -- you can change a borrowed 
reference into an owned one by increffing it yourself. Ideally the PythonObject 
helper class, as that way the ownership will be explicitly managed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117071/new/

https://reviews.llvm.org/D117071

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


[Lldb-commits] [PATCH] D117074: [lldb/Plugins] Enrich ScriptedThreads Stop Reasons with Exceptions

2022-01-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp:177
 lldb::break_id_t break_id;
+lldb::break_id_t break_loc_id;
 data_dict->GetValueForKeyAsInteger("break_id", break_id,

This seems unused?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117074/new/

https://reviews.llvm.org/D117074

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


[Lldb-commits] [lldb] df13239 - [LLDB] Skip TestIOHandlerPythonREPLSigint.py on AArch64/Linux

2022-01-14 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2022-01-15T03:24:26+05:00
New Revision: df13239c1177c1c73fcd3422023f9d1224f57545

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

LOG: [LLDB] Skip TestIOHandlerPythonREPLSigint.py on AArch64/Linux

TestIOHandlerPythonREPLSigint.py is running falky on AArch64/Linux
buildbot failing randomly. Skipping it for AArch64/Linux as well.

Added: 


Modified: 

lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py

Removed: 




diff  --git 
a/lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
 
b/lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
index d6d8cca2f439f..996353d927ca7 100644
--- 
a/lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
+++ 
b/lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
@@ -23,6 +23,7 @@ def test_watchpoint_before_thread_start(self):
 """Test that we can hit a watchpoint we set before starting another 
thread"""
 self.do_watchpoint_test("Before running the thread")
 
+@skipIfWindows # This test is flaky on Windows
 def test_watchpoint_after_thread_launch(self):
 """Test that we can hit a watchpoint we set after launching another 
thread"""
 self.do_watchpoint_test("After launching the thread")

diff  --git a/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py 
b/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py
index 20d18ca974744..79ffb2a7e300c 100644
--- a/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py
+++ b/lldb/test/API/iohandler/sigint/TestIOHandlerPythonREPLSigint.py
@@ -25,7 +25,7 @@ def start_python_repl(self):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfWindows
-@skipIf(oslist=["linux"], archs=["arm"])
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
 def test_while_evaluating_code(self):
 """ Tests SIGINT handling while Python code is being evaluated."""
 self.start_python_repl()



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


[Lldb-commits] [PATCH] D117071: [lldb/Plugins] Add support of multiple ScriptedThreads in a ScriptedProcess

2022-01-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 400148.
mib marked an inline comment as done.
mib added a comment.

Address @labath feedbacks:

- Pass `StructuredData::Generic *script_object` to 
`ScriptedInterface::CreatePluginObject`.
- `IncRef` the borrowed reference to make it an owned reference.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117071/new/

https://reviews.llvm.org/D117071

Files:
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedInterface.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
  lldb/test/API/functionalities/scripted_process/Makefile
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
  lldb/test/API/functionalities/scripted_process/main.c
  lldb/test/API/functionalities/scripted_process/main.cpp
  lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Index: lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -1,4 +1,4 @@
-import os,struct,signal
+import os,json,struct,signal
 
 from typing import Any, Dict
 
@@ -21,6 +21,14 @@
 idx = int(self.backing_target_idx.GetStringValue(100))
 self.corefile_target = target.GetDebugger().GetTargetAtIndex(idx)
 self.corefile_process = self.corefile_target.GetProcess()
+for corefile_thread in self.corefile_process:
+structured_data = lldb.SBStructuredData()
+structured_data.SetFromJSON(json.dumps({
+"backing_target_idx" : idx,
+"thread_idx" : corefile_thread.GetIndexID()
+}))
+
+self.threads[corefile_thread.GetThreadID()] = StackCoreScriptedThread(self, structured_data)
 
 def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
 mem_region = lldb.SBMemoryRegionInfo()
@@ -70,23 +78,43 @@
 class StackCoreScriptedThread(ScriptedThread):
 def __init__(self, process, args):
 super().__init__(process, args)
-self.backing_target_idx = args.GetValueForKey("backing_target_idx")
+backing_target_idx = args.GetValueForKey("backing_target_idx")
+thread_idx = args.GetValueForKey("thread_idx")
+
+def extract_value_from_structured_data(data, default_val):
+if data and data.IsValid():
+if data.GetType() == lldb.eStructuredDataTypeInteger:
+return data.GetIntegerValue(default_val)
+if data.GetType() == lldb.eStructuredDataTypeString:
+return int(data.GetStringValue(100))
+return None
+
+#TODO: Change to Walrus operator (:=) with oneline if assignment
+# Requires python 3.8
+val = extract_value_from_structured_data(thread_idx, 0)
+if val is not None:
+self.idx = val
 
 self.corefile_target = None
 self.corefile_process = None
-if (self.backing_target_idx and self.backing_target_idx.IsValid()):
-if self.backing_target_idx.GetType() == lldb.eStructuredDataTypeInteger:
-idx = self.backing_target_idx.GetIntegerValue(42)
-if self.backing_target_idx.GetType() == lldb.eStructuredDataTypeString:
-idx = int(self.backing_target_idx.GetStringValue(100))
-self.corefile_target = self.target.GetDebugger().GetTargetAtIndex(idx)
+self.corefile_thread = None
+
+#TODO: Change to Walrus operator (:=) with oneline if assignment
+# Requires python 3.8
+val = extract_value_from_structured_data(backing_target_idx, 42)
+if val is not None:
+self.corefile_target = self.target.GetDebugger().GetTargetAtIndex(val)
 self.corefile_process = self.corefile_target.GetProcess()
+self.corefile_thread = self.corefile_process.GetThreadByIndexID(self.idx)
+
+if self.corefile_thread:
+self.id = self.corefile_thread.GetThreadID()
 
 def get_thread_id(self) -> int:
-return 0x19
+return self.id
 
 def get_name(self) -> str:
-return StackCoreScriptedThre

[Lldb-commits] [PATCH] D117237: [lldb] Use __lldb_init_module instead of "if lldb.debugger" idiom

2022-01-14 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Thanks for doing this!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117237/new/

https://reviews.llvm.org/D117237

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


[Lldb-commits] [lldb] 8faca2e - [lldb] Fix platform selection on Apple Silicon

2022-01-14 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-01-14T16:03:49-08:00
New Revision: 8faca2ed6adebffa76c6eb506f15dfd38ab512a7

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

LOG: [lldb] Fix platform selection on Apple Silicon

Currently, when connecting to a remote iOS device from the command line
on Apple Silicon, we end up using the host platform (PlatfromMacOSX)
instead of remote-ios (PlatformRemoteiOS). This happens because
PlatfromMacOSX includes arm64-apple-ios and arm64e-apple-ios as
compatible architectures, presumably to support debugging iOS Apps on
Apple Silicon [1].

This is a problem for debugging remote ios devices, because the host
platform doesn't look for an expanded shared cache on disk and as a
result we end up reading everything from memory, incurring a significant
performance hit.

The crux of this patch is to make PlatfromMacOSX *not* compatible with
arm64(e)-apple-ios. This also means that we now use remote-ios
(PlatformRemoteiOS) as the platform for debugging iOS apps on Apple
Silicon. This has the (unintended) side effect that unlike we do for the
host platform, we no longer check our local shared cache, and incur a
performance hit on debugging these apps.

To avoid that, PlatformRemoteiOS now also check the local cache to
support this use case, which is cheap enough to do unconditionally for
PlatformRemoteiOS.

[1] 
https://support.apple.com/guide/app-store/iphone-ipad-apps-mac-apple-silicon-fird2c7092da/mac

Differential revision: https://reviews.llvm.org/D117340

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index de64426d7b647..29d2d82136018 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -237,7 +237,7 @@ lldb_private::Status 
PlatformDarwin::GetSharedModuleWithLocalCache(
 
   Status err;
 
-  if (IsHost()) {
+  if (CheckLocalSharedCache()) {
 // When debugging on the host, we are most likely using the same shared
 // cache as our inferior. The dylibs from the shared cache might not
 // exist on the filesystem, so let's use the images in our own memory
@@ -644,7 +644,7 @@ const char 
*PlatformDarwin::GetCompatibleArch(ArchSpec::Core core, size_t idx) {
 /// distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f
 /// processor.
 void PlatformDarwin::ARMGetSupportedArchitectures(
-std::vector &archs) {
+std::vector &archs, llvm::Optional os) {
   const ArchSpec system_arch = GetSystemArchitecture();
   const ArchSpec::Core system_core = system_arch.GetCore();
 
@@ -654,6 +654,8 @@ void PlatformDarwin::ARMGetSupportedArchitectures(
 llvm::Triple triple;
 triple.setArchName(compatible_arch);
 triple.setVendor(llvm::Triple::VendorType::Apple);
+if (os)
+  triple.setOS(*os);
 archs.push_back(ArchSpec(triple));
   }
 }

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index bbb2a336c56e0..57617ae58c89d 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -60,7 +60,9 @@ class PlatformDarwin : public PlatformPOSIX {
   bool ModuleIsExcludedForUnconstrainedSearches(
   lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
 
-  void ARMGetSupportedArchitectures(std::vector 
&archs);
+  void
+  ARMGetSupportedArchitectures(std::vector &archs,
+   llvm::Optional os = {});
 
   void x86GetSupportedArchitectures(std::vector 
&archs);
 
@@ -141,6 +143,8 @@ class PlatformDarwin : public PlatformPOSIX {
   const lldb_private::FileSpecList *module_search_paths_ptr,
   llvm::SmallVectorImpl *old_modules, bool 
*did_create_ptr);
 
+  virtual bool CheckLocalSharedCache() const { return IsHost(); }
+
   struct SDKEnumeratorInfo {
 lldb_private::FileSpec found_path;
 lldb_private::XcodeSDK::Type sdk_type;

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 3f2fb53ad654d..afe321538b179 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -137,15 +137,13 @@ std::vector 
PlatformMacOSX::GetSupportedArchitectur

[Lldb-commits] [PATCH] D117340: [lldb] Fix platform selection on Apple Silicon

2022-01-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8faca2ed6ade: [lldb] Fix platform selection on Apple Silicon 
(authored by JDevlieghere).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117340/new/

https://reviews.llvm.org/D117340

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h

Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
@@ -42,6 +42,8 @@
   std::vector GetSupportedArchitectures() override;
 
 protected:
+  bool CheckLocalSharedCache() const override;
+
   llvm::StringRef GetDeviceSupportDirectoryName() override;
   llvm::StringRef GetPlatformName() override;
 };
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
@@ -135,10 +135,17 @@
 
 std::vector PlatformRemoteiOS::GetSupportedArchitectures() {
   std::vector result;
-  ARMGetSupportedArchitectures(result);
+  ARMGetSupportedArchitectures(result, llvm::Triple::IOS);
   return result;
 }
 
+bool PlatformRemoteiOS::CheckLocalSharedCache() const {
+  // You can run iPhone and iPad apps on Mac with Apple Silicon. At the
+  // platform level there's no way to distinguish them from remote iOS
+  // applications. Make sure we still read from our own shared cache.
+  return true;
+}
+
 llvm::StringRef PlatformRemoteiOS::GetDeviceSupportDirectoryName() {
   return "iOS DeviceSupport";
 }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
@@ -127,7 +127,7 @@
 std::vector PlatformRemoteMacOSX::GetSupportedArchitectures() {
   // macOS for ARM64 support both native and translated x86_64 processes
   std::vector result;
-  ARMGetSupportedArchitectures(result);
+  ARMGetSupportedArchitectures(result, llvm::Triple::MacOSX);
 
   // We can't use x86GetSupportedArchitectures() because it uses
   // the system architecture for some of its return values and also
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -137,15 +137,13 @@
   std::vector result;
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
   // macOS for ARM64 support both native and translated x86_64 processes
-  ARMGetSupportedArchitectures(result);
+  ARMGetSupportedArchitectures(result, llvm::Triple::MacOSX);
 
   // We can't use x86GetSupportedArchitectures() because it uses
   // the system architecture for some of its return values and also
   // has a 32bits variant.
   result.push_back(ArchSpec("x86_64-apple-macosx"));
   result.push_back(ArchSpec("x86_64-apple-ios-macabi"));
-  result.push_back(ArchSpec("arm64-apple-ios"));
-  result.push_back(ArchSpec("arm64e-apple-ios"));
 #else
   x86GetSupportedArchitectures(result);
 #endif
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -60,7 +60,9 @@
   bool ModuleIsExcludedForUnconstrainedSearches(
   lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
 
-  void ARMGetSupportedArchitectures(std::vector &archs);
+  void
+  ARMGetSupportedArchitectures(std::vector &archs,
+   llvm::Optional os = {});
 
   void x86GetSupportedArchitectures(std::vector &archs);
 
@@ -141,6 +143,8 @@
   const lldb_private::FileSpecList *module_search_paths_ptr,
   llvm::SmallVectorImpl *old_modules, bool *did_create_ptr);
 
+  virtual bool CheckLocalSharedCache() const { return IsHost(); }
+
   struct SDKEnumeratorInfo {
 lldb_private::FileSpec found_path;
 lldb_private::XcodeSDK::Type sdk_type;
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/Pla

[Lldb-commits] [lldb] a10692c - [lldb] Only promote -Wignored-attributes to an error

2022-01-14 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-01-14T16:19:16-08:00
New Revision: a10692c734faff9ef28bc725703a0eacea78eeca

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

LOG: [lldb] Only promote -Wignored-attributes to an error

Avoid other warnings from failing the test, such as
-Wunused-command-line-argument in the downstream Swift fork.

Added: 


Modified: 
lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py

Removed: 




diff  --git 
a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py 
b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
index 6fd60c22cea4f..f37331e2cd254 100644
--- a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
+++ b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
@@ -20,7 +20,7 @@ def build_and_run(self, test_file):
 try:
 self.build(dictionary={
 "C_SOURCES" : test_file,
-"CFLAGS_EXTRAS" : "-Werror"
+"CFLAGS_EXTRAS" : "-Werror=ignored-attributes"
 })
 except BuildError as e:
  # Test source failed to build. Check if it failed because the



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


[Lldb-commits] [lldb] 258cd02 - [lldb/doc] Rephrase tutorial paragraph (NFC)

2022-01-14 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-01-14T16:23:26-08:00
New Revision: 258cd02c6a7aa71945a89b8d0d07e1eac49b5868

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

LOG: [lldb/doc] Rephrase tutorial paragraph (NFC)

Fixes #52694

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/docs/use/tutorial.rst

Removed: 




diff  --git a/lldb/docs/use/tutorial.rst b/lldb/docs/use/tutorial.rst
index 3c552a341e024..d4da0bae5aaf0 100644
--- a/lldb/docs/use/tutorial.rst
+++ b/lldb/docs/use/tutorial.rst
@@ -509,9 +509,9 @@ running anything you type will go to the STDIN of the 
inferior process. To
 interrupt your inferior program, type CTRL+C.
 
 If you attach to a process, or launch a process with the "--no-stdin" option,
-the command interpreter is always available to enter commands. This might be a
-little disconcerting to gdb users when always have an (lldb) prompt. This
-allows you to set a breakpoint, etc without having to explicitly interrupt the
+the command interpreter is always available to enter commands. It might be a
+little disconcerting to gdb users to always have an (lldb) prompt. This allows
+you to set a breakpoint, etc without having to explicitly interrupt the
 program you are debugging:
 
 ::



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


[Lldb-commits] [PATCH] D117076: [lldb/Plugins] Fix ScriptedThread IndexID reporting

2022-01-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 400194.
mib edited the summary of this revision.
mib added a reviewer: labath.
mib set the repository for this revision to rG LLVM Github Monorepo.
mib added a comment.

Changed the implementation to defer constructing the `ScriptedThread` until we 
have a valid `tid`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117076/new/

https://reviews.llvm.org/D117076

Files:
  lldb/include/lldb/Target/Thread.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h

Index: lldb/source/Plugins/Process/scripted/ScriptedThread.h
===
--- lldb/source/Plugins/Process/scripted/ScriptedThread.h
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.h
@@ -26,8 +26,14 @@
 
 class ScriptedThread : public lldb_private::Thread {
 public:
-  ScriptedThread(ScriptedProcess &process, Status &error,
- StructuredData::Generic *script_object = nullptr);
+  static std::shared_ptr
+  Create(ScriptedProcess &process, Status &error,
+ StructuredData::Generic *script_object = nullptr);
+
+  ScriptedThread(ScriptedProcess &process,
+ lldb::ScriptedThreadInterfaceSP interface_sp, Status &error,
+ lldb::tid_t tid,
+ StructuredData::GenericSP script_object_sp = nullptr);
 
   ~ScriptedThread() override;
 
@@ -61,8 +67,8 @@
 
   const ScriptedProcess &m_scripted_process;
   lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr;
+  lldb_private::StructuredData::GenericSP m_script_object_sp = nullptr;
   std::shared_ptr m_register_info_sp = nullptr;
-  lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr;
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -28,52 +28,61 @@
   lldbassert(GetInterface() && "Invalid Scripted Thread Interface.");
 }
 
-ScriptedThread::ScriptedThread(ScriptedProcess &process, Status &error,
-   StructuredData::Generic *script_object)
-: Thread(process, LLDB_INVALID_THREAD_ID), m_scripted_process(process),
-  m_scripted_thread_interface_sp(
-  m_scripted_process.GetInterface().CreateScriptedThreadInterface()) {
+std::shared_ptr
+ScriptedThread::Create(ScriptedProcess &process, Status &error,
+   StructuredData::Generic *script_object) {
   if (!process.IsValid()) {
 error.SetErrorString("Invalid scripted process");
-return;
+return nullptr;
   }
 
   process.CheckInterpreterAndScriptObject();
 
-  auto scripted_thread_interface = GetInterface();
-  if (!scripted_thread_interface) {
-error.SetErrorString("Failed to get scripted thread interface.");
-return;
-  }
+  auto scripted_thread_interface =
+  process.GetInterface().CreateScriptedThreadInterface();
+  if (!scripted_thread_interface)
+return process.GetInterface()
+.ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Failed to create scripted thread interface.",
+error);
 
   llvm::Optional class_name =
   process.GetInterface().GetScriptedThreadPluginName();
-  if (!class_name || class_name->empty()) {
-error.SetErrorString("Failed to get scripted thread class name.");
-return;
-  }
+  if (!class_name || class_name->empty())
+return process.GetInterface()
+.ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Failed to get scripted thread class name.",
+error);
 
   ExecutionContext exe_ctx(process);
-
-  m_script_object_sp = scripted_thread_interface->CreatePluginObject(
-  class_name->c_str(), exe_ctx, process.m_scripted_process_info.GetArgsSP(),
-  script_object);
-
-  if (!m_script_object_sp) {
-error.SetErrorString("Failed to create script object");
-return;
-  }
-
-  if (!m_script_object_sp->IsValid()) {
-m_script_object_sp = nullptr;
-error.SetErrorString("Created script object is invalid");
-return;
-  }
+  StructuredData::GenericSP owned_script_object_sp =
+  scripted_thread_interface->CreatePluginObject(
+  class_name->c_str(), exe_ctx,
+  process.m_scripted_process_info.GetArgsSP(), script_object);
+
+  if (!owned_script_object_sp)
+return process.GetInterface()
+.ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Failed to create script object", error);
+  if (!owned_script_object_sp->IsValid())
+return process.GetInterface()
+.ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Created script object is invalid", error);
 
   lldb::tid_t tid = scripted_thread_interface->GetThreadID();
-  SetID(tid);
+
+  return std::make_share

[Lldb-commits] [PATCH] D117374: [lldb/Interpreter] Make `ScriptedInterface::ErrorWithMessage` static (NFC)

2022-01-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch changes the `ScriptedInterface::ErrorWithMessage` method to
make it `static` which makes it easier to call.

The patch also updates its various call sites to reflect this change.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117374

Files:
  lldb/include/lldb/Interpreter/ScriptedInterface.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -41,18 +41,16 @@
   auto scripted_thread_interface =
   process.GetInterface().CreateScriptedThreadInterface();
   if (!scripted_thread_interface)
-return process.GetInterface()
-.ErrorWithMessage>(
-LLVM_PRETTY_FUNCTION, "Failed to create scripted thread interface.",
-error);
+return ScriptedInterface::ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Failed to create scripted thread interface.",
+error);
 
   llvm::Optional class_name =
   process.GetInterface().GetScriptedThreadPluginName();
   if (!class_name || class_name->empty())
-return process.GetInterface()
-.ErrorWithMessage>(
-LLVM_PRETTY_FUNCTION, "Failed to get scripted thread class name.",
-error);
+return ScriptedInterface::ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Failed to get scripted thread class name.",
+error);
 
   ExecutionContext exe_ctx(process);
   StructuredData::GenericSP owned_script_object_sp =
@@ -61,13 +59,11 @@
   process.m_scripted_process_info.GetArgsSP(), script_object);
 
   if (!owned_script_object_sp)
-return process.GetInterface()
-.ErrorWithMessage>(
-LLVM_PRETTY_FUNCTION, "Failed to create script object", error);
+return ScriptedInterface::ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Failed to create script object", error);
   if (!owned_script_object_sp->IsValid())
-return process.GetInterface()
-.ErrorWithMessage>(
-LLVM_PRETTY_FUNCTION, "Created script object is invalid", error);
+return ScriptedInterface::ErrorWithMessage>(
+LLVM_PRETTY_FUNCTION, "Created script object is invalid", error);
 
   lldb::tid_t tid = scripted_thread_interface->GetThreadID();
 
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -222,8 +222,8 @@
 size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
  Status &error) {
   if (!m_interpreter)
-return GetInterface().ErrorWithMessage(LLVM_PRETTY_FUNCTION,
-   "No interpreter.", error);
+return ScriptedInterface::ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "No interpreter.", error);
 
   lldb::DataExtractorSP data_extractor_sp =
   GetInterface().ReadMemoryAtAddress(addr, size, error);
@@ -235,7 +235,7 @@
   0, data_extractor_sp->GetByteSize(), buf, size, GetByteOrder());
 
   if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET)
-return GetInterface().ErrorWithMessage(
+return ScriptedInterface::ErrorWithMessage(
 LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error);
 
   return size;
@@ -293,7 +293,7 @@
   ScriptLanguage language = m_interpreter->GetLanguage();
 
   if (language != eScriptLanguagePython)
-return GetInterface().ErrorWithMessage(
+return ScriptedInterface::ErrorWithMessage(
 LLVM_PRETTY_FUNCTION,
 llvm::Twine("ScriptInterpreter language (" +
 llvm::Twine(m_interpreter->LanguageToString(language)) +
@@ -304,7 +304,7 @@
   StructuredData::DictionarySP thread_info_sp = GetInterface().GetThreadsInfo();
 
   if (!thread_info_sp)
-return GetInterface().ErrorWithMessage(
+return ScriptedInterface::ErrorWithMessage(
 LLVM_PRETTY_FUNCTION,
 "Couldn't fetch thread list from Scripted Process.", error);
 
@@ -312,13 +312,13 @@
   [this, &old_thread_list, &error,
&new_thread_list](ConstString key, StructuredData::Object *val) -> bool {
 if (!val)
-  return GetInterface().ErrorWithMessage(
+  return ScriptedInterface::ErrorWithMessage(
   LLVM_PRETTY_FUNCTION, "Invalid thread info object", error);
 
 lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
 if (!llvm::to_integer(key.AsCString(), tid))
-  return GetInterface().ErrorWithMessage(LLVM_PR

[Lldb-commits] [PATCH] D117074: [lldb/Plugins] Enrich ScriptedThreads Stop Reasons with Exceptions

2022-01-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 400202.
mib marked an inline comment as done.
mib added a comment.

Remove dead-code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117074/new/

https://reviews.llvm.org/D117074

Files:
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Index: lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -117,9 +117,21 @@
 return StackCoreScriptedThread.__name__ + ".thread-" + str(self.id)
 
 def get_stop_reason(self) -> Dict[str, Any]:
-return { "type": lldb.eStopReasonSignal, "data": {
-"signal": signal.SIGINT
-} }
+stop_reason = { "type": lldb.eStopReasonInvalid, "data": {  }}
+
+if self.corefile_thread and self.corefile_thread.IsValid:
+stop_reason["type"] = self.corefile_thread.GetStopReason()
+
+if self.corefile_thread.GetStopReasonDataCount() > 0:
+if stop_reason["type"] == lldb.eStopReasonBreakpoint:
+stop_reason["data"]["break_id"] = self.corefile_thread.GetStopReasonDataAtIndex(0)
+stop_reason["data"]["break_loc_id"] = self.corefile_thread.GetStopReasonDataAtIndex(1)
+elif stop_reason["type"] == lldb.eStopReasonSignal:
+stop_reason["data"]["signal"] = signal.SIGINT
+elif stop_reason["type"] == lldb.eStopReasonException:
+stop_reason["data"]["desc"] = self.corefile_thread.GetStopDescription(100)
+
+return stop_reason
 
 def get_stackframes(self):
 class ScriptedStackFrame:
Index: lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -190,11 +190,11 @@
 self.assertEqual(process.GetNumThreads(), 3)
 thread = process.GetSelectedThread()
 self.assertTrue(thread, "Invalid thread.")
-self.assertEqual(thread.GetName(), "StackCoreScriptedThread.thread-0")
+self.assertEqual(thread.GetName(), "StackCoreScriptedThread.thread-2")
 
-self.assertEqual(thread.GetNumFrames(), 2)
+self.assertEqual(thread.GetNumFrames(), 6)
 frame = thread.GetSelectedFrame()
 self.assertTrue(frame, "Invalid frame.")
-# self.assertEqual(frame.GetFunctionName(), "bar")
-# self.assertEqual(int(frame.FindValue("i", lldb.eValueTypeVariableArgument).GetValue()), 42)
-# self.assertEqual(int(frame.FindValue("j", lldb.eValueTypeVariableLocal).GetValue()), 42 * 42)
+self.assertIn("bar", frame.GetFunctionName())
+self.assertEqual(int(frame.FindValue("i", lldb.eValueTypeVariableArgument).GetValue()), 42)
+self.assertEqual(int(frame.FindValue("j", lldb.eValueTypeVariableLocal).GetValue()), 42 * 42)
Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -145,6 +145,11 @@
   StructuredData::DictionarySP dict_sp = GetInterface()->GetStopReason();
 
   Status error;
+  if (!dict_sp)
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to get scripted thread stop info.", error,
+LIBLLDB_LOG_THREAD);
+
   lldb::StopInfoSP stop_info_sp;
   lldb::StopReason stop_reason_type;
 
@@ -158,7 +163,7 @@
   if (!dict_sp->GetValueForKeyAsDictionary("data", data_dict))
 return GetInterface()->ErrorWithMessage(
 LLVM_PRETTY_FUNCTION,
-"Couldn't find value for key 'type' in stop reason dictionary.", error,
+"Couldn't find value for key 'data' in stop reason dictionary.", error,
 LIBLLDB_LOG_THREAD);
 
   switch (stop_reason_type) {
@@ -180,6 +185,13 @@
 stop_info_sp =
 StopInfo::CreateStopReasonWithSignal(*this, signal, description.data());
   } break;
+  case lldb::eStopReasonException: {
+llvm::StringRef description;
+data_dict->GetValueForKeyAsString("desc", description);
+
+stop_info_sp =
+StopInfo::CreateStopReasonWithException(*this, description.data());
+  } break;
   default:
 return GetInterface()->ErrorWithMessage(
 LLVM_PRETTY_FUNCTION,
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===

[Lldb-commits] [PATCH] D117074: [lldb/Plugins] Enrich ScriptedThreads Stop Reasons with Exceptions

2022-01-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117074/new/

https://reviews.llvm.org/D117074

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


[Lldb-commits] [PATCH] D117383: [lldb] From unordered_map synthetic provider, return std::pair children

2022-01-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Change the behavior of the libc++ `unordered_map` synthetic provider to present
children as `std::pair` values, just like `std::map` does.

The synthetic provider for libc++ `std::unordered_map` has returned children
that expose a level of internal structure (over top of the key/value pair). For
example, given an unordered map initialized with `{{1,2}, {3, 4}}`, the output
is:

  (std::unordered_map, std::equal_to, 
std::allocator > >) map = size=2 {
[0] = {
  __cc = (first = 3, second = 4)
}
[1] = {
  __cc = (first = 1, second = 2)
}
  }

It's not ideal/necessary to have the numbered children embdedded in the `__cc`
field.

Note: the numbered children have type
`std::__hash_node, void *>::__node_value_type`,
and the `__cc` fields have type `std::__hash_value_type::value_type`.

Compare this output to `std::map`:

  (std::map, std::allocator 
> >) map = size=2 {
[0] = (first = 1, second = 2)
[1] = (first = 3, second = 4)

Where the numbered children have type `std::pair`.

This changes the behavior of the synthetic provider for `unordered_map` to also
present children as `pairs`, just like `std::map`.

It appears the synthetic provider implementation for `unordered_map` was meant
to provide this behavior, but was maybe incomplete (see
d22a94377f7554a7e9df050f6dfc3ee42384e3fe). It has both an `m_node_type` and an
`m_element_type`, but uses only the former. The latter is exactly the type
needed for the children pairs. With this existing code, it's not much of a
change to make this work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117383

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -48,12 +48,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+
 self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 
'second = "this"',
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -118,10 +118,16 @@
 m_element_type = m_element_type.GetPointeeType();
 m_node_type = m_element_type;
 m_element_type = m_element_type.GetTypeTemplateArgument(0);
-std::string name;
-m_element_type =
-m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
-m_element_type = m_element_type.GetTypedefedType();
+if (m_element_type.GetNumFields() > 0) {
+ // Check for - and use - the underlying key/value container type used
+ // within std::unordered_map.
+  std::string name;
+  auto key_value_type =
+  m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, 
nullptr);
+  // __cc is a field of __hash_value_type, which is a typedef.
+  if (name == "__cc")
+m_element_type = key_value_type.GetTypedefedType();
+}
   }
   if (!m_node_type)
 return nullptr;
@@ -153,7 +159,7 @@
   ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
   thread_and_frame_only_if_stopped);
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetCompilerType());
+   m_element_type);
 }
 
 bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::


Index: lldb/test/API/f

[Lldb-commits] [PATCH] D117383: [lldb] From unordered_map synthetic provider, return std::pair children

2022-01-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 400234.
kastiglione added a comment.
Herald added a subscriber: JDevlieghere.

some tabs snuck in


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117383/new/

https://reviews.llvm.org/D117383

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -48,12 +48,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+
 self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 
'second = "this"',
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -118,10 +118,16 @@
 m_element_type = m_element_type.GetPointeeType();
 m_node_type = m_element_type;
 m_element_type = m_element_type.GetTypeTemplateArgument(0);
-std::string name;
-m_element_type =
-m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
-m_element_type = m_element_type.GetTypedefedType();
+if (m_element_type.GetNumFields() > 0) {
+  // Check for - and use - the underlying key/value container type used
+  // within std::unordered_map.
+  std::string name;
+  auto key_value_type =
+  m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, 
nullptr);
+  // __cc is a field of __hash_value_type, which is a typedef.
+  if (name == "__cc")
+m_element_type = key_value_type.GetTypedefedType();
+}
   }
   if (!m_node_type)
 return nullptr;
@@ -153,7 +159,7 @@
   ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
   thread_and_frame_only_if_stopped);
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetCompilerType());
+   m_element_type);
 }
 
 bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -48,12 +48,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+
 self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp

[Lldb-commits] [PATCH] D117383: [lldb] From unordered_map synthetic provider, return std::pair children

2022-01-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp:128
+  // __cc is a field of __hash_value_type, which is a typedef.
+  if (name == "__cc")
+m_element_type = key_value_type.GetTypedefedType();

This block of changes is needed to support `unordered_set`, because this 
synthetic provider is shared by `unordered_set` and `unordered_map`.

For `unordered_map`, the element type is an internal hash node. For 
`unoredered_set`, it's the type `T` from `unordered_set`. This part of the 
code needs to know whether there's a hash node here, and to step down through 
the `__cc` field.

I am not sure what the best way to do this is. I could do a string prefix check 
against `std::__hash_value_type`. I could do a smarter full string equality 
check, but could that possibly have false negatives if the wrong string type 
name is constructed. As it currently is, I assume if there's a one or more 
fields, and if the first one is named `__cc`, then it's assumed to be an 
internal hash node.

Suggestions welcome.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp:162
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetCompilerType());
+   m_element_type);
 }

This change is the fix needed to get `unordered_map` working.



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py:51
 
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
+

This regex checks that the string `__cc = ` is not in the output.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117383/new/

https://reviews.llvm.org/D117383

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


[Lldb-commits] [PATCH] D116853: [CMake][LLDB] Resolve install conflict when `LLDB_BUILD_FRAMEWORK=ON`

2022-01-14 Thread LJC via Phabricator via lldb-commits
paperchalice added a comment.

Could you help me commit this change? Because I don't have permission. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116853/new/

https://reviews.llvm.org/D116853

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