[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

In D112973#3122496 , 
@stella.stamenova wrote:

> Windows buildbot is broken:
>
> https://lab.llvm.org/buildbot/#/builders/83/builds/11865

eek, sorry.

fix is here: https://reviews.llvm.org/D113650


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

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


[Lldb-commits] [PATCH] D113650: [lldb] fix -print-script-interpreter-info on windows

2021-11-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: jasonmolenda, JDevlieghere, jingham.
lawrence_danna requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Apparently "{sys.prefix}/bin/python3" isn't where you find the
python interpreter on windows, so the test I wrote for
-print-script-interpreter-info is failing.

I'm not thrilled with this solution, as it requires a posix-specific
rule and a windows-specific rule, but as far as I can tell there's
not a better way to do it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113650

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -410,30 +410,40 @@
   return g_spec;
 }
 
+static const char GetInterpreterInfoScript[] = R"(
+import os
+import sysconfig
+import sys
+
+def main(lldb_python_dir):
+  info = {
+"lldb-pythonpath": lldb_python_dir,
+"language": "python",
+"prefix": sys.prefix,
+  }
+  sc = sysconfig.get_config_vars()
+  if os.name == 'nt':
+  if sc['EXT_SUFFIX'].startswith("_d"):
+  exename = "python_d.exe"
+  else:
+  exename = "python.exe"
+  info['executable'] = os.path.normpath(os.path.join(sys.prefix, exename))
+  elif os.name == 'posix':
+  exename = "python" + str(sys.version_info[0])
+  info['executable'] = os.path.join(sys.prefix, 'bin', exename)
+  return info
+
+)";
+
+
 StructuredData::DictionarySP ScriptInterpreterPython::GetInterpreterInfo() {
   GIL gil;
   FileSpec python_dir_spec = GetPythonDir();
   if (!python_dir_spec)
 return nullptr;
   PythonString python_dir(python_dir_spec.GetPath());
-  PythonDictionary info(PyInitialValue::Empty);
-  llvm::Error error = info.SetItem("lldb-pythonpath", python_dir);
-  if (error)
-return nullptr;
-  static const char script[] = R"(
-def main(info):
-  import sys
-  import os
-  name = 'python' + str(sys.version_info.major)
-  info.update({
-"language": "python",
-"prefix": sys.prefix,
-"executable": os.path.join(sys.prefix, "bin", name),
-  })
-  return info
-)";
-  PythonScript get_info(script);
-  auto info_json = unwrapIgnoringErrors(As(get_info(info)));
+  PythonScript get_info(GetInterpreterInfoScript);
+  auto info_json = 
unwrapIgnoringErrors(As(get_info(python_dir)));
   if (!info_json)
 return nullptr;
   return info_json.CreateStructuredDictionary();


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -410,30 +410,40 @@
   return g_spec;
 }
 
+static const char GetInterpreterInfoScript[] = R"(
+import os
+import sysconfig
+import sys
+
+def main(lldb_python_dir):
+  info = {
+"lldb-pythonpath": lldb_python_dir,
+"language": "python",
+"prefix": sys.prefix,
+  }
+  sc = sysconfig.get_config_vars()
+  if os.name == 'nt':
+  if sc['EXT_SUFFIX'].startswith("_d"):
+  exename = "python_d.exe"
+  else:
+  exename = "python.exe"
+  info['executable'] = os.path.normpath(os.path.join(sys.prefix, exename))
+  elif os.name == 'posix':
+  exename = "python" + str(sys.version_info[0])
+  info['executable'] = os.path.join(sys.prefix, 'bin', exename)
+  return info
+
+)";
+
+
 StructuredData::DictionarySP ScriptInterpreterPython::GetInterpreterInfo() {
   GIL gil;
   FileSpec python_dir_spec = GetPythonDir();
   if (!python_dir_spec)
 return nullptr;
   PythonString python_dir(python_dir_spec.GetPath());
-  PythonDictionary info(PyInitialValue::Empty);
-  llvm::Error error = info.SetItem("lldb-pythonpath", python_dir);
-  if (error)
-return nullptr;
-  static const char script[] = R"(
-def main(info):
-  import sys
-  import os
-  name = 'python' + str(sys.version_info.major)
-  info.update({
-"language": "python",
-"prefix": sys.prefix,
-"executable": os.path.join(sys.prefix, "bin", name),
-  })
-  return info
-)";
-  PythonScript get_info(script);
-  auto info_json = unwrapIgnoringErrors(As(get_info(info)));
+  PythonScript get_info(GetInterpreterInfoScript);
+  auto info_json = unwrapIgnoringErrors(As(get_info(python_dir)));
   if (!info_json)
 return nullptr;
   return info_json.CreateStructuredDictionary();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D110578: [lldb] Add support for D programming language

2021-11-10 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D110578#3123164 , @ljmf00 wrote:

> @dblaikie Maybe you can land this?

Nah, might need someone with more lldb context than me - I don't seem to have a 
clean check-lldb build right now (so don't have a good baseline to validate 
that the patch doesn't regress anything before I commit) & no idea why... :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110578

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


[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/source/Target/Process.cpp:2496-2497
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (!exe_module) {
-error.SetErrorString("executable module does not exist");
-return error;
-  }
-
   char local_exec_file_path[PATH_MAX];
   char platform_exec_file_path[PATH_MAX];
+

clayborg wrote:
> maybe switch these over to std::string values and then use the 
> FileSpec::GetPath() that returns a std::string below? It would be nice to 
> remove any PATH_MAX stuff from our generic code if possible.
Turns out that the remote path string wasn't used at all, and the local one was 
only used for error reporting.  So I deleted the one, and moved the other to 
where we report the error (and used a std::string)...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113521

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


[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 386375.
jingham added a comment.

Address Greg's review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113521

Files:
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/Process.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
@@ -0,0 +1,88 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestNoLocalFile(GDBRemoteTestBase):
+""" Test the case where there is NO local copy of the file
+being debugged.  We shouldn't immediately error out, but
+rather lldb should ask debugserver if it knows about the file. """
+
+
+@skipIfXmlSupportMissing
+def test(self):
+self.absent_file = '/nosuch_dir/nosuch_subdir/nosuch_executable'
+self.a_packet_file = None
+class MyResponder(MockGDBServerResponder):
+def __init__(self, testcase):
+MockGDBServerResponder.__init__(self)
+self.after_launch = False
+self.testcase = testcase
+self.current_thread = 0
+
+def A(self, packet):
+# This is the main test, we want to see that lldb DID send the
+# A packet to get debugserver to load the file.
+# Skip the length and second length:
+a_arr = packet.split(",")
+self.testcase.a_packet_file = bytearray.fromhex(a_arr[2]).decode()
+return "OK"
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+  i386:x86-64
+  
+
+  
+""", False
+else:
+return None, False
+
+def qC(self):
+if not self.after_launch:
+return "QC0"
+return "0"
+
+def qfThreadInfo(self):
+if not self.after_launch:
+return "OK"
+return "m0"
+
+def qsThreadInfo(self):
+if not self.after_launch:
+return "OK"
+return "l"
+
+def qLaunchSuccess(self):
+return "OK"
+
+def qProcessInfo(self):
+return "$pid:10b70;parent-pid:10b20;real-uid:1f6;real-gid:14;effective-uid:1f6;effective-gid:14;cputype:107;cpusubtype:8;ptrsize:8;ostype:macosx;vendor:apple;endian:little;"
+
+
+error = lldb.SBError()
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTarget(None, "x86_64-apple-macosx", "remote-macosx", False, error)
+self.assertSuccess(error, "Made a valid target")
+launch_info = target.GetLaunchInfo()
+launch_info.SetExecutableFile(lldb.SBFileSpec(self.absent_file), True)
+flags = launch_info.GetLaunchFlags()
+flags |= lldb.eLaunchFlagStopAtEntry
+launch_info.SetLaunchFlags(flags)
+
+process = self.connect(target)
+self.assertTrue(process.IsValid(), "Process is valid")
+
+# We need to fetch the connected event:
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateConnected])
+
+self.server.responder.after_launch = True
+
+process = target.Launch(launch_info, error)
+self.assertSuccess(error, "Successfully launched.")
+self.assertEqual(process.GetState(), lldb.eStateStopped, "Should be stopped at entry")
+self.assertIsNotNone(self.a_packet_file, "A packet was sent")
+self.assertEqual(self.absent_file, self.a_packet_file, "The A packet file was correct")
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2493,118 +2493,125 @@
   m_process_input_reader.reset();
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (!exe_module) {
-error.SetErrorString("executable module does not exist");
-return error;
-  }
 
-  char local_exec_file_path[PATH_MAX];
-  char platform_exec_file_path[PATH_MAX];
-  exe_module->GetFileSpec().GetPath(local_exec_file_path,
-sizeof(local_exec_file_path));
-  exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
- 

[Lldb-commits] [PATCH] D113634: [lldb] Add support for DW_TAG_immutable_type

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 planned changes to this revision.
ljmf00 added a comment.

I still need to add tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113634

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


[Lldb-commits] [PATCH] D113634: [lldb] Add support for DW_TAG_immutable_type

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 created this revision.
Herald added a reviewer: shafik.
ljmf00 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113634

Files:
  lldb/include/lldb/Symbol/Type.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -268,6 +268,9 @@
   case DW_TAG_const_type:
 s.PutCString("const ");
 break;
+  case DW_TAG_immutable_type:
+s.PutCString("immutable ");
+break;
   case DW_TAG_enumeration_type:
 s.PutCString("enum ");
 break;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -496,6 +496,7 @@
   case DW_TAG_reference_type:
   case DW_TAG_rvalue_reference_type:
   case DW_TAG_const_type:
+  case DW_TAG_immutable_type:
   case DW_TAG_restrict_type:
   case DW_TAG_volatile_type:
   case DW_TAG_atomic_type:
@@ -646,6 +647,9 @@
   case DW_TAG_const_type:
 encoding_data_type = Type::eEncodingIsConstUID;
 break;
+  case DW_TAG_immutable_type:
+encoding_data_type = Type::eEncodingIsImmutableUID;
+break;
   case DW_TAG_restrict_type:
 encoding_data_type = Type::eEncodingIsRestrictUID;
 break;
Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -89,6 +89,9 @@
 eEncodingIsRValueReferenceUID,
 /// This type is the type whose UID is m_encoding_uid as an atomic type.
 eEncodingIsAtomicUID,
+/// This type is the type whose UID is m_encoding_uid with the immutable
+/// qualifier added.
+eEncodingIsImmutableUID,
 /// This type is the synthetic type whose UID is m_encoding_uid.
 eEncodingIsSyntheticUID
   };


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -268,6 +268,9 @@
   case DW_TAG_const_type:
 s.PutCString("const ");
 break;
+  case DW_TAG_immutable_type:
+s.PutCString("immutable ");
+break;
   case DW_TAG_enumeration_type:
 s.PutCString("enum ");
 break;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -496,6 +496,7 @@
   case DW_TAG_reference_type:
   case DW_TAG_rvalue_reference_type:
   case DW_TAG_const_type:
+  case DW_TAG_immutable_type:
   case DW_TAG_restrict_type:
   case DW_TAG_volatile_type:
   case DW_TAG_atomic_type:
@@ -646,6 +647,9 @@
   case DW_TAG_const_type:
 encoding_data_type = Type::eEncodingIsConstUID;
 break;
+  case DW_TAG_immutable_type:
+encoding_data_type = Type::eEncodingIsImmutableUID;
+break;
   case DW_TAG_restrict_type:
 encoding_data_type = Type::eEncodingIsRestrictUID;
 break;
Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -89,6 +89,9 @@
 eEncodingIsRValueReferenceUID,
 /// This type is the type whose UID is m_encoding_uid as an atomic type.
 eEncodingIsAtomicUID,
+/// This type is the type whose UID is m_encoding_uid with the immutable
+/// qualifier added.
+eEncodingIsImmutableUID,
 /// This type is the synthetic type whose UID is m_encoding_uid.
 eEncodingIsSyntheticUID
   };
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D113605: [lldb] Fix documentation for EncodingDataType

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 updated this revision to Diff 386362.
ljmf00 retitled this revision from "[lldb] Add documentation for 
eEncodingIsSyntheticUID" to "[lldb] Fix documentation for EncodingDataType".

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

https://reviews.llvm.org/D113605

Files:
  lldb/include/lldb/Symbol/Type.h


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -66,6 +66,7 @@
 class Type : public std::enable_shared_from_this, public UserID {
 public:
   enum EncodingDataType {
+/// Invalid encoding
 eEncodingInvalid,
 /// This type is the type whose UID is m_encoding_uid.
 eEncodingIsUID,
@@ -78,7 +79,7 @@
 /// This type is the type whose UID is m_encoding_uid with the volatile
 /// qualifier added.
 eEncodingIsVolatileUID,
-/// This type is pointer to a type whose UID is m_encoding_uid.
+/// This type is alias to a type whose UID is m_encoding_uid.
 eEncodingIsTypedefUID,
 /// This type is pointer to a type whose UID is m_encoding_uid.
 eEncodingIsPointerUID,
@@ -88,6 +89,7 @@
 eEncodingIsRValueReferenceUID,
 /// This type is the type whose UID is m_encoding_uid as an atomic type.
 eEncodingIsAtomicUID,
+/// This type is the synthetic type whose UID is m_encoding_uid.
 eEncodingIsSyntheticUID
   };
 


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -66,6 +66,7 @@
 class Type : public std::enable_shared_from_this, public UserID {
 public:
   enum EncodingDataType {
+/// Invalid encoding
 eEncodingInvalid,
 /// This type is the type whose UID is m_encoding_uid.
 eEncodingIsUID,
@@ -78,7 +79,7 @@
 /// This type is the type whose UID is m_encoding_uid with the volatile
 /// qualifier added.
 eEncodingIsVolatileUID,
-/// This type is pointer to a type whose UID is m_encoding_uid.
+/// This type is alias to a type whose UID is m_encoding_uid.
 eEncodingIsTypedefUID,
 /// This type is pointer to a type whose UID is m_encoding_uid.
 eEncodingIsPointerUID,
@@ -88,6 +89,7 @@
 eEncodingIsRValueReferenceUID,
 /// This type is the type whose UID is m_encoding_uid as an atomic type.
 eEncodingIsAtomicUID,
+/// This type is the synthetic type whose UID is m_encoding_uid.
 eEncodingIsSyntheticUID
   };
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D113521#3123051 , @clayborg wrote:

> In D113521#3122654 , @jingham wrote:
>
>> In D113521#3120703 , @labath wrote:
>>
>>> I have two high-level questions about this:
>>>
>>> - what should be the relative priority of executable ModuleSP vs the launch 
>>> info? IIUC, in the current implementation the module takes precedence, but 
>>> it seems to me it would be more natural if the launch info came out on top. 
>>> One of the reasons I'm thinking about this is because you currently cannot 
>>> re-run executables that use exec(2) (I mean, you can, but it will rarely 
>>> produce the desired results). This happens because we use the post-exec 
>>> executable, but the rest of the launch info refers to the main one. If the 
>>> executable module was not the primary source of truth here, then maybe the 
>>> we could somehow use this mechanism to improve the exec story as well (by 
>>> storing the original executable in the launch info or something).
>>
>> As you point out indirectly above, there are really three entities in play 
>> here.  There's the Target's ExecutableModule; there's the GetExecutableFile 
>> in a user-provided ProcessLaunchInfo passed to SBTarget::Launch, for 
>> instance; and there's the ProcessLaunchInfo that's stored in the 
>> TargetProperties held by the target.
>> So we need to decide what it means when these three entities differ.
>
> Shouldn't the target;s launch info get a full copy of the user-provided 
> ProcessLaunchInfo upon launch? If that is the case, then we always can refer 
> to the target's launch info as the truth as far as ProcessLaunchInfo goes? 
> Then the only question we have is what to do if the target has a module
>
>> First let's address the externally supplied LaunchInfo.  Why would you make 
>> a Target with an executable module A, and then tell it to launch with a 
>> LaunchInfo whose GetExecutableFile is a different FileSpec from the one in 
>> the Executable Module? The only case where this seems useful is if there is 
>> no executable module.  That's bourne out by the implementation, where if the 
>> Target has an executable module the one in the LaunchInfo is ignored.  So 
>> maybe the right solution for this divergence is to make it an error to use a 
>> SBLaunchInfo with a different ExecutableFile.  Or maybe we could use the 
>> LaunchInfo's FileSpec as the remote file in the case where they've already 
>> given us a local file?  That's sort of coherent with the case where there 
>> was no local file.  In my patch I'm really using the GetExecutableFile to 
>> hold the remote path that we would have in the Module except that we don't 
>> have a way to make an Executable Module for the target that just has a 
>> remote file spec and nothing else.
>
> Maybe you don't have the platform implemented to install a binary and you 
> have a local copy of the binary at "/local/a.out" and then you want the 
> remote to launch "/remote/a.out" using this path from the launch info?
>
>> In the case of exec, I don't think we want to use values of the Executable 
>> Module stuffed into a user-provided LaunchInfo and then passed to 
>> Target::Launch or Process::Launch to make re-run work.  That would mean the 
>> user would have to keep around the ProcessLaunchInfo with the original 
>> binary and then feed it back to the target to get the launch to work, which 
>> seems awkward, and I don't see how you would do that well on the command 
>> line.
>
> It depends on what we currently do with the target's launch info. If it is 
> still setup like it was before, then re-running should just work. If we allow 
> the executable module in the target to take precedence, then we can't use it.
>
>> So you might think you should solve this by leaving the original launch 
>> information in the TargetProperties LaunchInfo, and then re-run would always 
>> use that.  But this has the problem that even though you KNOW on re-run 
>> you're first going to be debugging the initial binary, that won't be the 
>> main executable between runs, so setting breakpoints - if you want some to 
>> take in the initial binary - is going to be confusing.  To handle this 
>> situation gracefully, I think we'd need to reset the ExecutableModule in the 
>> target when the exec-ed binary exits, not just squirrel the binary FileSpec 
>> away in the TargetProperties ProcessLaunchInfo.
>
> Not sure I agree with that.
>
>> Anyway, I think you are asking the question "What should we do if the 
>> Target's ProcessLaunchInfo::GetExecutableFile differs from the one in the 
>> Target's Executable Module".  Or rather, should we keep the Target's 
>> ProcessLaunchInfo as the truth of what that target wants to launch, rather 
>> than looking at the Executable module.
>>
>> That question is orthogonal to the one this patch is determining, which is 
>> just about the 

[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

Can you check now? If looks good, can you land it please?




Comment at: lldb/include/lldb/Symbol/Type.h:86
 eEncodingIsAtomicUID,  ///< This type is the type whose UID is
/// m_encoding_uid as an atomic type.
 eEncodingIsSyntheticUID

teemperor wrote:
> teemperor wrote:
> > FWIW, we usually update the comments to something less >squished< such as:
> > ```
> > ///< This type is the type whose UID is m_encoding_uid
> > eEcodingIsUID.
> > /// This type is the type whose UID is m_encoding_uid with the const 
> > qualifier added
> > eEncodingIsConstUID,
> > ```
> > 
> > I think this patch is good as-is, but there would be bonus points for 
> > fixing up the comment style :)
> I meant
> ```
> lang=c++
> /// This type is the type whose UID is m_encoding_uid
> eEcodingIsUID.
> /// This type is the type whose UID is m_encoding_uid with the const 
> qualifier added
> eEncodingIsConstUID,
> ```
Done


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

https://reviews.llvm.org/D113604

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


[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 updated this revision to Diff 386361.

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

https://reviews.llvm.org/D113604

Files:
  lldb/include/lldb/Symbol/Type.h


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -67,23 +67,27 @@
 public:
   enum EncodingDataType {
 eEncodingInvalid,
-eEncodingIsUID,  ///< This type is the type whose UID is m_encoding_uid
-eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid
- /// with the const qualifier added
-eEncodingIsRestrictUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the restrict qualifier 
added
-eEncodingIsVolatileUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the volatile qualifier 
added
-eEncodingIsTypedefUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
-eEncodingIsPointerUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
-eEncodingIsLValueReferenceUID, ///< This type is L value reference to a 
type
-   /// whose UID is m_encoding_uid
-eEncodingIsRValueReferenceUID, ///< This type is R value reference to a 
type
-   /// whose UID is m_encoding_uid,
-eEncodingIsAtomicUID,  ///< This type is the type whose UID is
-   /// m_encoding_uid as an atomic type.
+/// This type is the type whose UID is m_encoding_uid.
+eEncodingIsUID,
+/// This type is the type whose UID is m_encoding_uid with the const
+/// qualifier added.
+eEncodingIsConstUID,
+/// This type is the type whose UID is m_encoding_uid with the restrict
+/// qualifier added.
+eEncodingIsRestrictUID,
+/// This type is the type whose UID is m_encoding_uid with the volatile
+/// qualifier added.
+eEncodingIsVolatileUID,
+/// This type is pointer to a type whose UID is m_encoding_uid.
+eEncodingIsTypedefUID,
+/// This type is pointer to a type whose UID is m_encoding_uid.
+eEncodingIsPointerUID,
+/// This type is L value reference to a type whose UID is m_encoding_uid.
+eEncodingIsLValueReferenceUID,
+/// This type is R value reference to a type whose UID is m_encoding_uid.
+eEncodingIsRValueReferenceUID,
+/// This type is the type whose UID is m_encoding_uid as an atomic type.
+eEncodingIsAtomicUID,
 eEncodingIsSyntheticUID
   };
 
@@ -197,7 +201,7 @@
 
   // From a fully qualified typename, split the type into the type basename and
   // the remaining type scope (namespaces/classes).
-  static bool GetTypeScopeAndBasename(const llvm::StringRef& name,
+  static bool GetTypeScopeAndBasename(const llvm::StringRef ,
   llvm::StringRef ,
   llvm::StringRef ,
   lldb::TypeClass _class);
@@ -473,8 +477,8 @@
 public:
   TypeEnumMemberImpl() : m_integer_type_sp(), m_name(""), m_value() {}
 
-  TypeEnumMemberImpl(const lldb::TypeImplSP _type_sp,
- ConstString name, const llvm::APSInt );
+  TypeEnumMemberImpl(const lldb::TypeImplSP _type_sp, ConstString name,
+ const llvm::APSInt );
 
   TypeEnumMemberImpl(const TypeEnumMemberImpl ) = default;
 


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -67,23 +67,27 @@
 public:
   enum EncodingDataType {
 eEncodingInvalid,
-eEncodingIsUID,  ///< This type is the type whose UID is m_encoding_uid
-eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid
- /// with the const qualifier added
-eEncodingIsRestrictUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the restrict qualifier added
-eEncodingIsVolatileUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the volatile qualifier added
-eEncodingIsTypedefUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
-eEncodingIsPointerUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
-eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type
-   /// whose UID is m_encoding_uid
-eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type
-   /// whose UID is m_encoding_uid,
-eEncodingIsAtomicUID,  ///< This type is the type whose UID is
- 

[Lldb-commits] [PATCH] D110578: [lldb] Add support for D programming language

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a subscriber: dblaikie.
ljmf00 added a comment.

@dblaikie Maybe you can land this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110578

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


[Lldb-commits] [PATCH] D111409: proposed support for Java interface to Scripting Bridge

2021-11-10 Thread David Millar via Phabricator via lldb-commits
d-millar added a comment.

Apologies in advance - this may be a repeat message.  Our server went down for 
maintenance mid-send.

So, looking at https://llvm.org/docs/HowToAddABuilder.html, I think I need some 
clarification on your request regarding a build bot.  Are you asking for 
dedicated physical resources for running nightly builds?  That I cannot 
provide.  Our build systems are non-public and firewalled in a way that would 
make them unsuitable for your build process.  (Also, they're government 
resources.)   Do you really have a separate build machines for the Python and 
Lua scripting environments?

Dave



From: David Millar via Phabricator 
Sent: Wednesday, November 10, 2021 3:17:38 PM
To: David Millar; jo...@devlieghere.com
Subject: [PATCH] D111409 : proposed support 
for Java interface to Scripting Bridge

d-millar added a comment.

Hi Jonas,

Apologies for the non-build - I did a fetch/rebase this morning before creating 
the patch.  Do I need to be on a different branch re StringRef vs ConstString?  
(Have seen that discussion in passing but confess I did not follow it in 
detail.)  Any pointers appreciated.

Re testing, I basically duplicated the test set from Lua and ran it using 
"ninja check-lldb-unit" and "ninja check-lldb-shell".  I'm not really 
conversant with your testing infrastructure.  Can you point me to something 
that might be suggest what I'd need to do to generate a bot?  I'll give it a 
shot if I have a starting point.

Also am happy to maintain the code in general and have a few folks in our 
project that can backstop me in case I get run over by a bus or something.  

Best,

Dave



From: Jonas Devlieghere via Phabricator 
Sent: Wednesday, November 10, 2021 1:57:51 PM
To: David Millar; anoro...@apple.com; fallk...@yahoo.com; kkle...@redhat.com; 
teempe...@gmail.com; medismail.benn...@gmail.com; tedw...@quicinc.com; 
jmole...@apple.com; syaghm...@apple.com; jing...@apple.com; v...@apple.com; 
boris.ulasev...@gmail.com; lldb-commits@lists.llvm.org; h.imai@nitech.jp; 
bruce.mitche...@gmail.com; david.spick...@linaro.org; 
quic_soura...@quicinc.com; djordje.todoro...@syrmia.com; 
serhiy.re...@gmail.com; liburd1...@outlook.com
Cc: mgo...@gentoo.org
Subject: [PATCH] D111409  
https://reviews.llvm.org/D111409: proposed support for Java interface to 
Scripting Bridge

JDevlieghere added a comment.

Hi David, this looks really comprehensive. As far as the code is concerned, it 
has all the parts that we'd want to support another scripting language in LLDB. 
That leaves us with the last remaining questions:

- Testing: having a bot that actually builds & tests this configuration.
- Maintainership: having a commitment from you (or someone else) to maintain 
this code.

Are you willing and able to sign up for those things?

PS: I installed Java and applied your patch on top-of-tree. Things didn't built 
because of the recent change to the plugin manager that now expects 
`StringRef`s instead of `ConstString`s. Please let me know if you've rebased 
the patch and I'd love to give it a try.

Comment at: lldb/cmake/modules/FindJavaAndSwig.cmake:13
+find_package(Java 11.0)
+find_package(JNI REQUIRED)

+if(JAVA_FOUND AND SWIG_FOUND)
--

This can't be `REQUIRED` because that will fail the CMake configuration stage 
when Java isn't found which is not what you want when doing autodetection (the 
default). Making it required is handled at a higher level for `FindJavaAndSwig` 
as a whole.

Repository:

  rLLDB LLDB

CHANGES SINCE LAST ACTION

  https://reviews.llvm.org/D111409/new/

https://reviews.llvm.org/D111409

Repository:

  rLLDB LLDB

CHANGES SINCE LAST ACTION

  https://reviews.llvm.org/D111409/new/

https://reviews.llvm.org/D111409


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D111409

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


[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/source/Commands/CommandObjectProcess.cpp:268-269
+  exe_module_sp = target->GetExecutableModule();
+if (!exe_module_sp) {
+  result.AppendError("Could not get executable module after launch.");
+  return false;

clayborg wrote:
> I agree with Pavel here, unless you have a case where you need this to work 
> this way?
If we couldn't get the executable module, that would mean that we queried a 
process stopped in the remote server after launch, and the dynamic loader 
wasn't able to determine the main executable.  That's something we do all the 
time, so it would be weird if we couldn't do that.  I don't know why that would 
happen or how well the debug session is going to go on from here.  But leaving 
it around in the hopes that it's useful is fine by me.



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py:30
+ascii = bytearray.fromhex(a_arr[2]).decode()
+self.testcase.assertEqual(ascii, self.testcase.absent_file, 
"We sent the right path")
+return "OK"

labath wrote:
> the responder will run on a separate thread, so a failing assertion will not 
> immediately terminate the test, but rather confuse the hell out of everyone. 
> It be better to just record the data here, and do the assertion on the main 
> thread.
Got it.  I just preserve the file name from the A packet and test it later.



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py:69
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTargetWithFileAndArch(None, "x86_64")
+launch_info = target.GetLaunchInfo()

labath wrote:
> I would use the CreateTarget overload which takes a platform name argument. 
> Otherwise, this will pick a random platform on non-darwin hosts and then it 
> may get confused by the darwin-specific responses.
Good catch.



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py:79-83
+# We need to fetch the connected event:
+event = lldb.SBEvent()
+got_event = self.dbg.GetListener().WaitForEventForBroadcaster(30, 
process.GetBroadcaster(), event)
+self.assertTrue(got_event, "Got an initial event after connect")
+self.assertEqual(process.GetState(), lldb.eStateConnected, "Unexpected 
state.")

labath wrote:
> we have `lldbutil.expect_state_changes` for this
I hadn't noticed that, nice...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113521

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


[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 386339.
jingham added a comment.

Address Pavel's review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113521

Files:
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/Process.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
@@ -0,0 +1,88 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestNoLocalFile(GDBRemoteTestBase):
+""" Test the case where there is NO local copy of the file
+being debugged.  We shouldn't immediately error out, but
+rather lldb should ask debugserver if it knows about the file. """
+
+
+@skipIfXmlSupportMissing
+def test(self):
+self.absent_file = '/nosuch_dir/nosuch_subdir/nosuch_executable'
+self.a_packet_file = None
+class MyResponder(MockGDBServerResponder):
+def __init__(self, testcase):
+MockGDBServerResponder.__init__(self)
+self.after_launch = False
+self.testcase = testcase
+self.current_thread = 0
+
+def A(self, packet):
+# This is the main test, we want to see that lldb DID send the
+# A packet to get debugserver to load the file.
+# Skip the length and second length:
+a_arr = packet.split(",")
+self.testcase.a_packet_file = bytearray.fromhex(a_arr[2]).decode()
+return "OK"
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+  i386:x86-64
+  
+
+  
+""", False
+else:
+return None, False
+
+def qC(self):
+if not self.after_launch:
+return "QC0"
+return "0"
+
+def qfThreadInfo(self):
+if not self.after_launch:
+return "OK"
+return "m0"
+
+def qsThreadInfo(self):
+if not self.after_launch:
+return "OK"
+return "l"
+
+def qLaunchSuccess(self):
+return "OK"
+
+def qProcessInfo(self):
+return "$pid:10b70;parent-pid:10b20;real-uid:1f6;real-gid:14;effective-uid:1f6;effective-gid:14;cputype:107;cpusubtype:8;ptrsize:8;ostype:macosx;vendor:apple;endian:little;"
+
+
+error = lldb.SBError()
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTarget(None, "x86_64-apple-macosx", "remote-macosx", False, error)
+self.assertSuccess(error, "Made a valid target")
+launch_info = target.GetLaunchInfo()
+launch_info.SetExecutableFile(lldb.SBFileSpec(self.absent_file), True)
+flags = launch_info.GetLaunchFlags()
+flags |= lldb.eLaunchFlagStopAtEntry
+launch_info.SetLaunchFlags(flags)
+
+process = self.connect(target)
+self.assertTrue(process.IsValid(), "Process is valid")
+
+# We need to fetch the connected event:
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateConnected])
+
+self.server.responder.after_launch = True
+
+process = target.Launch(launch_info, error)
+self.assertSuccess(error, "Successfully launched.")
+self.assertEqual(process.GetState(), lldb.eStateStopped, "Should be stopped at entry")
+self.assertIsNotNone(self.a_packet_file, "A packet was sent")
+self.assertEqual(self.absent_file, self.a_packet_file, "The A packet file was correct")
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2493,113 +2493,130 @@
   m_process_input_reader.reset();
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (!exe_module) {
-error.SetErrorString("executable module does not exist");
-return error;
-  }
-
   char local_exec_file_path[PATH_MAX];
   char platform_exec_file_path[PATH_MAX];
-  exe_module->GetFileSpec().GetPath(local_exec_file_path,
-sizeof(local_exec_file_path));
-  exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
- 

[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D113521#3122654 , @jingham wrote:

> In D113521#3120703 , @labath wrote:
>
>> I have two high-level questions about this:
>>
>> - what should be the relative priority of executable ModuleSP vs the launch 
>> info? IIUC, in the current implementation the module takes precedence, but 
>> it seems to me it would be more natural if the launch info came out on top. 
>> One of the reasons I'm thinking about this is because you currently cannot 
>> re-run executables that use exec(2) (I mean, you can, but it will rarely 
>> produce the desired results). This happens because we use the post-exec 
>> executable, but the rest of the launch info refers to the main one. If the 
>> executable module was not the primary source of truth here, then maybe the 
>> we could somehow use this mechanism to improve the exec story as well (by 
>> storing the original executable in the launch info or something).
>
> As you point out indirectly above, there are really three entities in play 
> here.  There's the Target's ExecutableModule; there's the GetExecutableFile 
> in a user-provided ProcessLaunchInfo passed to SBTarget::Launch, for 
> instance; and there's the ProcessLaunchInfo that's stored in the 
> TargetProperties held by the target.
> So we need to decide what it means when these three entities differ.

Shouldn't the target;s launch info get a full copy of the user-provided 
ProcessLaunchInfo upon launch? If that is the case, then we always can refer to 
the target's launch info as the truth as far as ProcessLaunchInfo goes? Then 
the only question we have is what to do if the target has a module

> First let's address the externally supplied LaunchInfo.  Why would you make a 
> Target with an executable module A, and then tell it to launch with a 
> LaunchInfo whose GetExecutableFile is a different FileSpec from the one in 
> the Executable Module? The only case where this seems useful is if there is 
> no executable module.  That's bourne out by the implementation, where if the 
> Target has an executable module the one in the LaunchInfo is ignored.  So 
> maybe the right solution for this divergence is to make it an error to use a 
> SBLaunchInfo with a different ExecutableFile.  Or maybe we could use the 
> LaunchInfo's FileSpec as the remote file in the case where they've already 
> given us a local file?  That's sort of coherent with the case where there was 
> no local file.  In my patch I'm really using the GetExecutableFile to hold 
> the remote path that we would have in the Module except that we don't have a 
> way to make an Executable Module for the target that just has a remote file 
> spec and nothing else.

Maybe you don't have the platform implemented to install a binary and you have 
a local copy of the binary at "/local/a.out" and then you want the remote to 
launch "/remote/a.out" using this path from the launch info?

> In the case of exec, I don't think we want to use values of the Executable 
> Module stuffed into a user-provided LaunchInfo and then passed to 
> Target::Launch or Process::Launch to make re-run work.  That would mean the 
> user would have to keep around the ProcessLaunchInfo with the original binary 
> and then feed it back to the target to get the launch to work, which seems 
> awkward, and I don't see how you would do that well on the command line.

It depends on what we currently do with the target's launch info. If it is 
still setup like it was before, then re-running should just work. If we allow 
the executable module in the target to take precedence, then we can't use it.

> So you might think you should solve this by leaving the original launch 
> information in the TargetProperties LaunchInfo, and then re-run would always 
> use that.  But this has the problem that even though you KNOW on re-run 
> you're first going to be debugging the initial binary, that won't be the main 
> executable between runs, so setting breakpoints - if you want some to take in 
> the initial binary - is going to be confusing.  To handle this situation 
> gracefully, I think we'd need to reset the ExecutableModule in the target 
> when the exec-ed binary exits, not just squirrel the binary FileSpec away in 
> the TargetProperties ProcessLaunchInfo.

Not sure I agree with that.

> Anyway, I think you are asking the question "What should we do if the 
> Target's ProcessLaunchInfo::GetExecutableFile differs from the one in the 
> Target's Executable Module".  Or rather, should we keep the Target's 
> ProcessLaunchInfo as the truth of what that target wants to launch, rather 
> than looking at the Executable module.
>
> That question is orthogonal to the one this patch is determining, which is 
> just about the case where there isn't an executable file in the target so 
> that the user needs to provide this info from the outside.  So while I agree 
> that yours is an interesting 

[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/include/lldb/Symbol/Type.h:86
 eEncodingIsAtomicUID,  ///< This type is the type whose UID is
/// m_encoding_uid as an atomic type.
 eEncodingIsSyntheticUID

teemperor wrote:
> FWIW, we usually update the comments to something less >squished< such as:
> ```
> ///< This type is the type whose UID is m_encoding_uid
> eEcodingIsUID.
> /// This type is the type whose UID is m_encoding_uid with the const 
> qualifier added
> eEncodingIsConstUID,
> ```
> 
> I think this patch is good as-is, but there would be bonus points for fixing 
> up the comment style :)
I meant
```
lang=c++
/// This type is the type whose UID is m_encoding_uid
eEcodingIsUID.
/// This type is the type whose UID is m_encoding_uid with the const qualifier 
added
eEncodingIsConstUID,
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113604

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


[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

I guess that's just clang-format ran over the file? If yes, then LGTM




Comment at: lldb/include/lldb/Symbol/Type.h:86
 eEncodingIsAtomicUID,  ///< This type is the type whose UID is
/// m_encoding_uid as an atomic type.
 eEncodingIsSyntheticUID

FWIW, we usually update the comments to something less >squished< such as:
```
///< This type is the type whose UID is m_encoding_uid
eEcodingIsUID.
/// This type is the type whose UID is m_encoding_uid with the const qualifier 
added
eEncodingIsConstUID,
```

I think this patch is good as-is, but there would be bonus points for fixing up 
the comment style :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113604

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


[Lldb-commits] [PATCH] D112167: [lldb/Plugins] Refactor ScriptedThread register context creation

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG676576b6f027: [lldb/Plugins] Refactor ScriptedThread 
register context creation (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112167

Files:
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  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
@@ -64,32 +64,6 @@
   m_script_object_sp = object_sp;
 
   SetID(scripted_thread_interface->GetThreadID());
-
-  llvm::Optional reg_data =
-  scripted_thread_interface->GetRegisterContext();
-  if (!reg_data) {
-error.SetErrorString("Failed to get scripted thread registers data.");
-return;
-  }
-
-  DataBufferSP data_sp(
-  std::make_shared(reg_data->c_str(), reg_data->size()));
-
-  if (!data_sp->GetByteSize()) {
-error.SetErrorString("Failed to copy raw registers data.");
-return;
-  }
-
-  std::shared_ptr reg_ctx_memory =
-  std::make_shared(
-  *this, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS);
-  if (!reg_ctx_memory) {
-error.SetErrorString("Failed to create a register context.");
-return;
-  }
-
-  reg_ctx_memory->SetAllRegisterData(data_sp);
-  m_reg_context_sp = reg_ctx_memory;
 }
 
 ScriptedThread::~ScriptedThread() { DestroyThread(); }
@@ -115,21 +89,48 @@
 void ScriptedThread::ClearStackFrames() { Thread::ClearStackFrames(); }
 
 RegisterContextSP ScriptedThread::GetRegisterContext() {
-  if (!m_reg_context_sp) {
-m_reg_context_sp = std::make_shared(
-*this, LLDB_INVALID_ADDRESS);
-GetInterface()->GetRegisterContext();
-  }
+  if (!m_reg_context_sp)
+m_reg_context_sp = CreateRegisterContextForFrame(nullptr);
   return m_reg_context_sp;
 }
 
 RegisterContextSP
 ScriptedThread::CreateRegisterContextForFrame(StackFrame *frame) {
-  uint32_t concrete_frame_idx = frame ? frame->GetConcreteFrameIndex() : 0;
+  const uint32_t concrete_frame_idx =
+  frame ? frame->GetConcreteFrameIndex() : 0;
+
+  if (concrete_frame_idx)
+return GetUnwinder().CreateRegisterContextForFrame(frame);
+
+  lldb::RegisterContextSP reg_ctx_sp;
+  Status error;
+
+  llvm::Optional reg_data = GetInterface()->GetRegisterContext();
+  if (!reg_data)
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers data.",
+error, LIBLLDB_LOG_THREAD);
+
+  DataBufferSP data_sp(
+  std::make_shared(reg_data->c_str(), reg_data->size()));
+
+  if (!data_sp->GetByteSize())
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to copy raw registers data.", error,
+LIBLLDB_LOG_THREAD);
 
-  if (concrete_frame_idx == 0)
-return GetRegisterContext();
-  return GetUnwinder().CreateRegisterContextForFrame(frame);
+  std::shared_ptr reg_ctx_memory =
+  std::make_shared(
+  *this, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS);
+  if (!reg_ctx_memory)
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to create a register context.", error,
+LIBLLDB_LOG_THREAD);
+
+  reg_ctx_memory->SetAllRegisterData(data_sp);
+  m_reg_context_sp = reg_ctx_memory;
+
+  return m_reg_context_sp;
 }
 
 bool ScriptedThread::CalculateStopInfo() {
@@ -142,13 +143,15 @@
   if (!dict_sp->GetValueForKeyAsInteger("type", stop_reason_type))
 return GetInterface()->ErrorWithMessage(
 LLVM_PRETTY_FUNCTION,
-"Couldn't find value for key 'type' in stop reason dictionary.", error);
+"Couldn't find value for key 'type' in stop reason dictionary.", error,
+LIBLLDB_LOG_THREAD);
 
   StructuredData::Dictionary *data_dict;
   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 'type' in stop reason dictionary.", error,
+LIBLLDB_LOG_THREAD);
 
   switch (stop_reason_type) {
   case lldb::eStopReasonNone:
@@ -175,7 +178,7 @@
 llvm::Twine("Unsupported stop reason type (" +
 llvm::Twine(stop_reason_type) + llvm::Twine(")."))
 .str(),
-error);
+error, LIBLLDB_LOG_THREAD);
   }
 
   SetStopInfo(stop_info_sp);
@@ -183,9 +186,7 @@
 }
 
 void ScriptedThread::RefreshStateAfterStop() {
-  // TODO: Implement
-  if (m_reg_context_sp)
-m_reg_context_sp->InvalidateAllRegisters();
+  GetRegisterContext()->InvalidateIfNeeded(/*force=*/false);

[Lldb-commits] [lldb] 676576b - [lldb/Plugins] Refactor ScriptedThread register context creation

2021-11-10 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-11-11T00:13:58+01:00
New Revision: 676576b6f027516c8ea1b45f6da3cd1b94a851a2

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

LOG: [lldb/Plugins] Refactor ScriptedThread register context creation

This patch changes the ScriptedThread class to create the register
context when Process::RefreshStateAfterStop is called rather than
doing it in the thread constructor.

This is required to update the thread state for execution control.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 23659bdb8a47..15d3d43d9993 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -20,7 +20,6 @@
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/RegisterContext.h"
-
 #include "lldb/Utility/State.h"
 
 #include 
@@ -291,6 +290,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList 
_thread_list,
   // actually new threads will get added to new_thread_list.
 
   CheckInterpreterAndScriptObject();
+  m_thread_plans.ClearThreadCache();
 
   Status error;
   ScriptLanguage language = m_interpreter->GetLanguage();
@@ -316,6 +316,12 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList 
_thread_list,
   return new_thread_list.GetSize(false) > 0;
 }
 
+void ScriptedProcess::RefreshStateAfterStop() {
+  // Let all threads recover from stopping and do any clean up based on the
+  // previous thread state (if any).
+  m_thread_list.RefreshStateAfterStop();
+}
+
 bool ScriptedProcess::GetProcessInfo(ProcessInstanceInfo ) {
   info.Clear();
   info.SetProcessID(GetID());

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index 3f8d53908339..c8355f35548a 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -75,7 +75,7 @@ class ScriptedProcess : public Process {
 
   Status DoDestroy() override;
 
-  void RefreshStateAfterStop() override{};
+  void RefreshStateAfterStop() override;
 
   bool IsAlive() override;
 

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
index dbe9e5019ff8..1adbd4e7799d 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -64,32 +64,6 @@ ScriptedThread::ScriptedThread(ScriptedProcess , 
Status )
   m_script_object_sp = object_sp;
 
   SetID(scripted_thread_interface->GetThreadID());
-
-  llvm::Optional reg_data =
-  scripted_thread_interface->GetRegisterContext();
-  if (!reg_data) {
-error.SetErrorString("Failed to get scripted thread registers data.");
-return;
-  }
-
-  DataBufferSP data_sp(
-  std::make_shared(reg_data->c_str(), reg_data->size()));
-
-  if (!data_sp->GetByteSize()) {
-error.SetErrorString("Failed to copy raw registers data.");
-return;
-  }
-
-  std::shared_ptr reg_ctx_memory =
-  std::make_shared(
-  *this, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS);
-  if (!reg_ctx_memory) {
-error.SetErrorString("Failed to create a register context.");
-return;
-  }
-
-  reg_ctx_memory->SetAllRegisterData(data_sp);
-  m_reg_context_sp = reg_ctx_memory;
 }
 
 ScriptedThread::~ScriptedThread() { DestroyThread(); }
@@ -115,21 +89,48 @@ void ScriptedThread::WillResume(StateType resume_state) {}
 void ScriptedThread::ClearStackFrames() { Thread::ClearStackFrames(); }
 
 RegisterContextSP ScriptedThread::GetRegisterContext() {
-  if (!m_reg_context_sp) {
-m_reg_context_sp = std::make_shared(
-*this, LLDB_INVALID_ADDRESS);
-GetInterface()->GetRegisterContext();
-  }
+  if (!m_reg_context_sp)
+m_reg_context_sp = CreateRegisterContextForFrame(nullptr);
   return m_reg_context_sp;
 }
 
 RegisterContextSP
 ScriptedThread::CreateRegisterContextForFrame(StackFrame *frame) {
-  uint32_t concrete_frame_idx = frame ? frame->GetConcreteFrameIndex() : 0;
+  const uint32_t concrete_frame_idx =
+  frame ? frame->GetConcreteFrameIndex() : 0;
+
+  if (concrete_frame_idx)
+return GetUnwinder().CreateRegisterContextForFrame(frame);
+
+  lldb::RegisterContextSP reg_ctx_sp;
+  Status error;
+
+  llvm::Optional reg_data = 

[Lldb-commits] [PATCH] D113608: [lldb] Simplify specifying of platform supported architectures

2021-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/Target/Platform.h:330-331
+  /// NB: This implementation is mutually recursive with
+  /// GetSupportedArchitectureAtIndex. Subclasses should implement at least one
+  /// of them.
+  virtual std::vector GetSupportedArchitectures();

Do you expect any platform to implement both?



Comment at: lldb/source/Target/Platform.cpp:1217-1218
+std::vector
+Platform::CreateArchList(llvm::Triple::OSType os,
+ llvm::ArrayRef archs) {
+  std::vector list;

In PlatformDarwin we set the vendor too. Could we have this take an optional 
OSType and Vendor maybe that sets the ones that are not None? That would also 
make migrating PlatformDarwin easier where we currently share the code and 
don't set the OS. Later we could move this out of PlatformDarwin into the child 
classes and have the OS set correctly. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113608

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


[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D113521#3120703 , @labath wrote:

> I have two high-level questions about this:
>
> - what should be the relative priority of executable ModuleSP vs the launch 
> info? IIUC, in the current implementation the module takes precedence, but it 
> seems to me it would be more natural if the launch info came out on top. One 
> of the reasons I'm thinking about this is because you currently cannot re-run 
> executables that use exec(2) (I mean, you can, but it will rarely produce the 
> desired results). This happens because we use the post-exec executable, but 
> the rest of the launch info refers to the main one. If the executable module 
> was not the primary source of truth here, then maybe the we could somehow use 
> this mechanism to improve the exec story as well (by storing the original 
> executable in the launch info or something).

As you point out indirectly above, there are really three entities in play 
here.  There's the Target's ExecutableModule; there's the GetExecutableFile in 
a user-provided ProcessLaunchInfo passed to SBTarget::Launch, for instance; and 
there's the ProcessLaunchInfo that's stored in the TargetProperties held by the 
target.

So we need to decide what it means when these three entities differ.

First let's address the externally supplied LaunchInfo.  Why would you make a 
Target with an executable module A, and then tell it to launch with a 
LaunchInfo whose GetExecutableFile is a different FileSpec from the one in the 
Executable Module?  The only case where this seems useful is if there is no 
executable module.  That's bourne out by the implementation, where if the 
Target has an executable module the one in the LaunchInfo is ignored.  So maybe 
the right solution for this divergence is to make it an error to use a 
SBLaunchInfo with a different ExecutableFile.  Or maybe we could use the 
LaunchInfo's FileSpec as the remote file in the case where they've already 
given us a local file?  That's sort of coherent with the case where there was 
no local file.  In my patch I'm really using the GetExecutableFile to hold the 
remote path that we would have in the Module except that we don't have a way to 
make an Executable Module for the target that just has a remote file spec and 
nothing else.

In the case of exec, I don't think we want to use values of the Executable 
Module stuffed into a user-provided LaunchInfo and then passed to 
Target::Launch or Process::Launch to make re-run work.  That would mean the 
user would have to keep around the ProcessLaunchInfo with the original binary 
and then feed it back to the target to get the launch to work, which seems 
awkward, and I don't see how you would do that well on the command line.

So you might think you should solve this by leaving the original launch 
information in the TargetProperties LaunchInfo, and then re-run would always 
use that.  But this has the problem that even though you KNOW on re-run you're 
first going to be debugging the initial binary, that won't be the main 
executable between runs, so setting breakpoints - if you want some to take in 
the initial binary - is going to be confusing.  To handle this situation 
gracefully, I think we'd need to reset the ExecutableModule in the target when 
the exec-ed binary exits, not just squirrel the binary FileSpec away in the 
TargetProperties ProcessLaunchInfo.

Anyway, I think you are asking the question "What should we do if the Target's 
ProcessLaunchInfo::GetExecutableFile differs from the one in the Target's 
Executable Module".  Or rather, should we keep the Target's ProcessLaunchInfo 
as the truth of what that target wants to launch, rather than looking at the 
Executable module.

That question is orthogonal to the one this patch is determining, which is just 
about the case where there isn't an executable file in the target so that the 
user needs to provide this info from the outside.  So while I agree that yours 
is an interesting question, it isn't directly germane to this patch.

> - what happens if the launch_info path happens to refer to a host executable? 
> Will we still launch the remote one or will we try to copy the local one 
> instead? I'm not sure of the current behavior, but I would like to avoid the 
> behavior depending on the presence of local files.

Everything in Process::Launch, which is what does the real work for this part 
of the Launch, all the "host side" work uses the return from 
GetTarget().GetExecutableModulePointer() returns null.  That's always going to 
be true in the scenario I'm adding support for.  So we won't look at the local 
file system again till the process stops and we start querying the dynamic 
loader for executables, and go looking for local copies like we always do.

I'll reply to the individual comments after lunch...


Repository:
  rG LLVM Github Monorepo

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


[Lldb-commits] [PATCH] D113608: [lldb] Simplify specifying of platform supported architectures

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/include/lldb/Target/Platform.h:332
+  /// of them.
+  virtual std::vector GetSupportedArchitectures();
 

If all platforms (as I expect them to) implement this by maintaining a vector 
of supported architectures, this could be changed into an ArrayRef, 
but returning a value type for now simplifies the rollout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113608

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


[Lldb-commits] [PATCH] D113608: [lldb] Simplify specifying of platform supported architectures

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, jasonmolenda.
Herald added subscribers: krytarowski, arichardson, emaste.
labath requested review of this revision.
Herald added a project: LLDB.

The GetSupportedArchitectureAtIndex pattern forces the use of
complicated patterns in both the implementations of the function and in
the various callers.

This patch creates a new method (GetSupportedArchitectures), which
returns a list (vector) of architectures. The
GetSupportedArchitectureAtIndex is kept in order to enable incremental
rollout. Base Platform class contains implementations of both of these
methods, using the other method as the source of truth. Platforms
without infinite stacks should implement at least one of them.

This patch also ports Linux, FreeBSD and NetBSD platforms to the new
API. A new helper function (CreateArchList) is added to simplify the
common task of creating a list of ArchSpecs with the same OS but
different architectures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113608

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Target/Platform.cpp

Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1213,6 +1213,35 @@
   return platform_sp;
 }
 
+std::vector
+Platform::CreateArchList(llvm::Triple::OSType os,
+ llvm::ArrayRef archs) {
+  std::vector list;
+  for(auto arch : archs) {
+llvm::Triple triple;
+triple.setOS(os);
+triple.setArch(arch);
+list.push_back(ArchSpec(triple));
+  }
+  return list;
+}
+
+bool Platform::GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec ) {
+  const auto  = GetSupportedArchitectures();
+  if (idx > archs.size())
+return false;
+  arch = archs[idx];
+  return true;
+}
+
+std::vector Platform::GetSupportedArchitectures() {
+  std::vector result;
+  ArchSpec arch;
+  for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(idx, arch); ++idx)
+result.push_back(arch);
+  return result;
+}
+
 /// Lets a platform answer if it is compatible with a given
 /// architecture and the target triple contained within.
 bool Platform::IsCompatibleArchitecture(const ArchSpec ,
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
===
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -42,7 +42,7 @@
 
   void GetStatus(Stream ) override;
 
-  bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec ) override;
+  std::vector GetSupportedArchitectures() override;
 
   uint32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo _info) override;
 
@@ -54,6 +54,8 @@
   lldb::addr_t length, unsigned prot,
   unsigned flags, lldb::addr_t fd,
   lldb::addr_t offset) override;
+
+  std::vector m_supported_architectures;
 };
 
 } // namespace platform_netbsd
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
===
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -100,54 +100,24 @@
 /// Default Constructor
 PlatformNetBSD::PlatformNetBSD(bool is_host)
 : PlatformPOSIX(is_host) // This is the local host platform
-{}
-
-bool PlatformNetBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
- ArchSpec ) {
-  if (IsHost()) {
+{
+  if (is_host) {
 ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-if (hostArch.GetTriple().isOSNetBSD()) {
-  if (idx == 0) {
-arch = hostArch;
-return arch.IsValid();
-  } else if (idx == 1) {
-// If the default host architecture is 64-bit, look for a 32-bit
-// variant
-if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) {
-  arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
-  return arch.IsValid();
-}
-  }
+m_supported_architectures.push_back(hostArch);
+if (hostArch.GetTriple().isArch64Bit()) {
+  m_supported_architectures.push_back(
+  HostInfo::GetArchitecture(HostInfo::eArchKind32));
 }
   } else {
-if (m_remote_platform_sp)
-  return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
-
-llvm::Triple triple;
-// Set the OS to NetBSD
-triple.setOS(llvm::Triple::NetBSD);
-// Set the 

[Lldb-commits] [PATCH] D113605: [lldb] Add documentation for eEncodingIsSyntheticUID

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 created this revision.
ljmf00 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113605

Files:
  lldb/include/lldb/Symbol/Type.h


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -84,7 +84,8 @@
/// whose UID is m_encoding_uid,
 eEncodingIsAtomicUID,  ///< This type is the type whose UID is
/// m_encoding_uid as an atomic type.
-eEncodingIsSyntheticUID
+eEncodingIsSyntheticUID///< This type is the synthetic type whose 
UID is
+   /// m_encoding_uid
   };
 
   enum class ResolveState : unsigned char {


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -84,7 +84,8 @@
/// whose UID is m_encoding_uid,
 eEncodingIsAtomicUID,  ///< This type is the type whose UID is
/// m_encoding_uid as an atomic type.
-eEncodingIsSyntheticUID
+eEncodingIsSyntheticUID///< This type is the synthetic type whose UID is
+   /// m_encoding_uid
   };
 
   enum class ResolveState : unsigned char {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-10 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 created this revision.
ljmf00 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113604

Files:
  lldb/include/lldb/Symbol/Type.h


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -67,17 +67,17 @@
 public:
   enum EncodingDataType {
 eEncodingInvalid,
-eEncodingIsUID,  ///< This type is the type whose UID is m_encoding_uid
-eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid
- /// with the const qualifier added
-eEncodingIsRestrictUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the restrict qualifier 
added
-eEncodingIsVolatileUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the volatile qualifier 
added
-eEncodingIsTypedefUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
-eEncodingIsPointerUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
+eEncodingIsUID,///< This type is the type whose UID is 
m_encoding_uid
+eEncodingIsConstUID,   ///< This type is the type whose UID is 
m_encoding_uid
+   /// with the const qualifier added
+eEncodingIsRestrictUID,///< This type is the type whose UID is
+   /// m_encoding_uid with the restrict 
qualifier added
+eEncodingIsVolatileUID,///< This type is the type whose UID is
+   /// m_encoding_uid with the volatile 
qualifier added
+eEncodingIsTypedefUID, ///< This type is pointer to a type whose 
UID is
+   /// m_encoding_uid
+eEncodingIsPointerUID, ///< This type is pointer to a type whose 
UID is
+   /// m_encoding_uid
 eEncodingIsLValueReferenceUID, ///< This type is L value reference to a 
type
/// whose UID is m_encoding_uid
 eEncodingIsRValueReferenceUID, ///< This type is R value reference to a 
type
@@ -197,7 +197,7 @@
 
   // From a fully qualified typename, split the type into the type basename and
   // the remaining type scope (namespaces/classes).
-  static bool GetTypeScopeAndBasename(const llvm::StringRef& name,
+  static bool GetTypeScopeAndBasename(const llvm::StringRef ,
   llvm::StringRef ,
   llvm::StringRef ,
   lldb::TypeClass _class);
@@ -473,8 +473,8 @@
 public:
   TypeEnumMemberImpl() : m_integer_type_sp(), m_name(""), m_value() {}
 
-  TypeEnumMemberImpl(const lldb::TypeImplSP _type_sp,
- ConstString name, const llvm::APSInt );
+  TypeEnumMemberImpl(const lldb::TypeImplSP _type_sp, ConstString name,
+ const llvm::APSInt );
 
   TypeEnumMemberImpl(const TypeEnumMemberImpl ) = default;
 


Index: lldb/include/lldb/Symbol/Type.h
===
--- lldb/include/lldb/Symbol/Type.h
+++ lldb/include/lldb/Symbol/Type.h
@@ -67,17 +67,17 @@
 public:
   enum EncodingDataType {
 eEncodingInvalid,
-eEncodingIsUID,  ///< This type is the type whose UID is m_encoding_uid
-eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid
- /// with the const qualifier added
-eEncodingIsRestrictUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the restrict qualifier added
-eEncodingIsVolatileUID, ///< This type is the type whose UID is
-/// m_encoding_uid with the volatile qualifier added
-eEncodingIsTypedefUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
-eEncodingIsPointerUID,  ///< This type is pointer to a type whose UID is
-/// m_encoding_uid
+eEncodingIsUID,///< This type is the type whose UID is m_encoding_uid
+eEncodingIsConstUID,   ///< This type is the type whose UID is m_encoding_uid
+   /// with the const qualifier added
+eEncodingIsRestrictUID,///< This type is the type whose UID is
+   /// m_encoding_uid with the restrict qualifier added
+eEncodingIsVolatileUID,///< This type is the type whose UID is
+   /// m_encoding_uid with the volatile qualifier added
+eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is
+   

[Lldb-commits] [lldb] 0d62e31 - [LLDB][NFC] Fix test that broke due to libc++ std::vector changes

2021-11-10 Thread Shafik Yaghmour via lldb-commits

Author: Shafik Yaghmour
Date: 2021-11-10T12:29:08-08:00
New Revision: 0d62e31c458526e1db37d11da947e61768c7b522

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

LOG: [LLDB][NFC] Fix test that broke due to libc++ std::vector changes

D112976 moved most of the guts of __vector_base into vector, this broke
some LLDB tests by changing the result types that LLDB sees. This updates
the test to reflect the new structure.

Added: 


Modified: 

lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py

lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index e0b511c91bd0f..8c8dfe01a2deb 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -23,7 +23,7 @@ def test(self):
 vector_type = "std::vector"
 vector_of_vector_type = "std::vector<" + vector_type + " >"
 size_type = vector_of_vector_type + "::size_type"
-value_type = "std::__vector_base 
>::value_type"
+value_type = "std::vector::value_type"
 
 self.runCmd("settings set target.import-std-module true")
 

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
index a03c347a728fa..32a254ed218d7 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
@@ -24,7 +24,7 @@ def test(self):
 
 vector_type = "std::vector"
 size_type = vector_type + "::size_type"
-value_type = "std::__vector_base 
>::value_type"
+value_type = "std::vector::value_type"
 iterator = vector_type + "::iterator"
 # LLDB's formatter provides us with a artificial 'item' member.
 iterator_children = [ValueCheck(name="item")]



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


[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

Windows buildbot is broken:

https://lab.llvm.org/buildbot/#/builders/83/builds/11865


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

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


Re: [Lldb-commits] [PATCH] D111409: proposed support for Java interface to Scripting Bridge

2021-11-10 Thread David Millar via lldb-commits
Hi Jonas,


Apologies for the non-build - I did a fetch/rebase this morning before creating 
the patch.  Do I need to be on a different branch re StringRef vs ConstString?  
(Have seen that discussion in passing but confess I did not follow it in 
detail.)  Any pointers appreciated.


Re testing, I basically duplicated the test set from Lua and ran it using 
"ninja check-lldb-unit" and "ninja check-lldb-shell".  I'm not really 
conversant with your testing infrastructure.  Can you point me to something 
that might be suggest what I'd need to do to generate a bot?  I'll give it a 
shot if I have a starting point.


Also am happy to maintain the code in general and have a few folks in our 
project that can backstop me in case I get run over by a bus or something.  


Best,

Dave


From: Jonas Devlieghere via Phabricator 
Sent: Wednesday, November 10, 2021 1:57:51 PM
To: David Millar; anoro...@apple.com; fallk...@yahoo.com; kkle...@redhat.com; 
teempe...@gmail.com; medismail.benn...@gmail.com; tedw...@quicinc.com; 
jmole...@apple.com; syaghm...@apple.com; jing...@apple.com; v...@apple.com; 
boris.ulasev...@gmail.com; lldb-commits@lists.llvm.org; h.imai@nitech.jp; 
bruce.mitche...@gmail.com; david.spick...@linaro.org; 
quic_soura...@quicinc.com; djordje.todoro...@syrmia.com; 
serhiy.re...@gmail.com; liburd1...@outlook.com
Cc: mgo...@gentoo.org
Subject: [PATCH] D111409: proposed support for Java interface to Scripting 
Bridge

JDevlieghere added a comment.

Hi David, this looks really comprehensive. As far as the code is concerned, it 
has all the parts that we'd want to support another scripting language in LLDB. 
That leaves us with the last remaining questions:

- Testing: having a bot that actually builds & tests this configuration.
- Maintainership: having a commitment from you (or someone else) to maintain 
this code.

Are you willing and able to sign up for those things?

PS: I installed Java and applied your patch on top-of-tree. Things didn't built 
because of the recent change to the plugin manager that now expects 
`StringRef`s instead of `ConstString`s. Please let me know if you've rebased 
the patch and I'd love to give it a try.




Comment at: lldb/cmake/modules/FindJavaAndSwig.cmake:13
+find_package(Java 11.0)
+find_package(JNI REQUIRED)
+if(JAVA_FOUND AND SWIG_FOUND)

This can't be `REQUIRED` because that will fail the CMake configuration stage 
when Java isn't found which is not what you want when doing autodetection (the 
default). Making it required is handled at a higher level for `FindJavaAndSwig` 
as a whole.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D111409

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


[Lldb-commits] [PATCH] D112167: [lldb/Plugins] Refactor ScriptedThread register context creation

2021-11-10 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


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

https://reviews.llvm.org/D112167

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


[Lldb-commits] [PATCH] D113598: [debugserver] Remove unused variable

2021-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18d883cc0a06: [debugserver] Remove varaible `ldb_set` which 
is set but not used. (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113598

Files:
  lldb/tools/debugserver/source/RNBRemote.cpp


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -4921,7 +4921,6 @@
   const char *gdb_type = default_gdb_type;
   const char *default_lldb_format = "hex";
   const char *lldb_format = default_lldb_format;
-  const char *lldb_set = NULL;
 
   switch (reg.nub_info.type) {
   case Uint:
@@ -4989,8 +4988,6 @@
 lldb_format = "vector-uint128";
 break;
   };
-  if (reg_set_info && reg.nub_info.set < num_reg_sets)
-lldb_set = reg_set_info[reg.nub_info.set].name;
 
   uint32_t indent = 2;
 


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -4921,7 +4921,6 @@
   const char *gdb_type = default_gdb_type;
   const char *default_lldb_format = "hex";
   const char *lldb_format = default_lldb_format;
-  const char *lldb_set = NULL;
 
   switch (reg.nub_info.type) {
   case Uint:
@@ -4989,8 +4988,6 @@
 lldb_format = "vector-uint128";
 break;
   };
-  if (reg_set_info && reg.nub_info.set < num_reg_sets)
-lldb_set = reg_set_info[reg.nub_info.set].name;
 
   uint32_t indent = 2;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 18d883c - [debugserver] Remove varaible `ldb_set` which is set but not used.

2021-11-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-11-10T11:56:59-08:00
New Revision: 18d883cc0a0623f6a1b9a4fdbd0c21b3a70a88a0

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

LOG: [debugserver] Remove varaible `ldb_set` which is set but not used.

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

Added: 


Modified: 
lldb/tools/debugserver/source/RNBRemote.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index 93a0f76c387c5..8b83506e9660b 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -4921,7 +4921,6 @@ void GenerateTargetXMLRegister(std::ostringstream , 
const uint32_t reg_num,
   const char *gdb_type = default_gdb_type;
   const char *default_lldb_format = "hex";
   const char *lldb_format = default_lldb_format;
-  const char *lldb_set = NULL;
 
   switch (reg.nub_info.type) {
   case Uint:
@@ -4989,8 +4988,6 @@ void GenerateTargetXMLRegister(std::ostringstream , 
const uint32_t reg_num,
 lldb_format = "vector-uint128";
 break;
   };
-  if (reg_set_info && reg.nub_info.set < num_reg_sets)
-lldb_set = reg_set_info[reg.nub_info.set].name;
 
   uint32_t indent = 2;
 



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


[Lldb-commits] [PATCH] D112167: [lldb/Plugins] Refactor ScriptedThread register context creation

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 386274.
mib marked an inline comment as done.
mib added a comment.

Addressed @JDevlieghere & @shafik comments.


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

https://reviews.llvm.org/D112167

Files:
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  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
@@ -64,32 +64,6 @@
   m_script_object_sp = object_sp;
 
   SetID(scripted_thread_interface->GetThreadID());
-
-  llvm::Optional reg_data =
-  scripted_thread_interface->GetRegisterContext();
-  if (!reg_data) {
-error.SetErrorString("Failed to get scripted thread registers data.");
-return;
-  }
-
-  DataBufferSP data_sp(
-  std::make_shared(reg_data->c_str(), reg_data->size()));
-
-  if (!data_sp->GetByteSize()) {
-error.SetErrorString("Failed to copy raw registers data.");
-return;
-  }
-
-  std::shared_ptr reg_ctx_memory =
-  std::make_shared(
-  *this, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS);
-  if (!reg_ctx_memory) {
-error.SetErrorString("Failed to create a register context.");
-return;
-  }
-
-  reg_ctx_memory->SetAllRegisterData(data_sp);
-  m_reg_context_sp = reg_ctx_memory;
 }
 
 ScriptedThread::~ScriptedThread() { DestroyThread(); }
@@ -115,21 +89,48 @@
 void ScriptedThread::ClearStackFrames() { Thread::ClearStackFrames(); }
 
 RegisterContextSP ScriptedThread::GetRegisterContext() {
-  if (!m_reg_context_sp) {
-m_reg_context_sp = std::make_shared(
-*this, LLDB_INVALID_ADDRESS);
-GetInterface()->GetRegisterContext();
-  }
+  if (!m_reg_context_sp)
+m_reg_context_sp = CreateRegisterContextForFrame(nullptr);
   return m_reg_context_sp;
 }
 
 RegisterContextSP
 ScriptedThread::CreateRegisterContextForFrame(StackFrame *frame) {
-  uint32_t concrete_frame_idx = frame ? frame->GetConcreteFrameIndex() : 0;
+  const uint32_t concrete_frame_idx =
+  frame ? frame->GetConcreteFrameIndex() : 0;
+
+  if (concrete_frame_idx)
+return GetUnwinder().CreateRegisterContextForFrame(frame);
+
+  lldb::RegisterContextSP reg_ctx_sp;
+  Status error;
+
+  llvm::Optional reg_data = GetInterface()->GetRegisterContext();
+  if (!reg_data)
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers data.",
+error, LIBLLDB_LOG_THREAD);
+
+  DataBufferSP data_sp(
+  std::make_shared(reg_data->c_str(), reg_data->size()));
+
+  if (!data_sp->GetByteSize())
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to copy raw registers data.", error,
+LIBLLDB_LOG_THREAD);
 
-  if (concrete_frame_idx == 0)
-return GetRegisterContext();
-  return GetUnwinder().CreateRegisterContextForFrame(frame);
+  std::shared_ptr reg_ctx_memory =
+  std::make_shared(
+  *this, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS);
+  if (!reg_ctx_memory)
+return GetInterface()->ErrorWithMessage(
+LLVM_PRETTY_FUNCTION, "Failed to create a register context.", error,
+LIBLLDB_LOG_THREAD);
+
+  reg_ctx_memory->SetAllRegisterData(data_sp);
+  m_reg_context_sp = reg_ctx_memory;
+
+  return m_reg_context_sp;
 }
 
 bool ScriptedThread::CalculateStopInfo() {
@@ -142,13 +143,15 @@
   if (!dict_sp->GetValueForKeyAsInteger("type", stop_reason_type))
 return GetInterface()->ErrorWithMessage(
 LLVM_PRETTY_FUNCTION,
-"Couldn't find value for key 'type' in stop reason dictionary.", error);
+"Couldn't find value for key 'type' in stop reason dictionary.", error,
+LIBLLDB_LOG_THREAD);
 
   StructuredData::Dictionary *data_dict;
   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 'type' in stop reason dictionary.", error,
+LIBLLDB_LOG_THREAD);
 
   switch (stop_reason_type) {
   case lldb::eStopReasonNone:
@@ -175,7 +178,7 @@
 llvm::Twine("Unsupported stop reason type (" +
 llvm::Twine(stop_reason_type) + llvm::Twine(")."))
 .str(),
-error);
+error, LIBLLDB_LOG_THREAD);
   }
 
   SetStopInfo(stop_info_sp);
@@ -183,9 +186,7 @@
 }
 
 void ScriptedThread::RefreshStateAfterStop() {
-  // TODO: Implement
-  if (m_reg_context_sp)
-m_reg_context_sp->InvalidateAllRegisters();
+  GetRegisterContext()->InvalidateIfNeeded(/*force=*/false);
 }
 
 lldb::ScriptedThreadInterfaceSP ScriptedThread::GetInterface() const {
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h

[Lldb-commits] [PATCH] D112167: [lldb/Plugins] Refactor ScriptedThread register context creation

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib requested review of this revision.
mib marked 2 inline comments as done.
mib added inline comments.



Comment at: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp:105
+  lldb::RegisterContextSP reg_ctx_sp;
+  Status error;
+

JDevlieghere wrote:
> It looks like this error is set but never used/returned? Should this return 
> an `Expected` with the caller dealing with the error? 
This follows the `Thread::CreateRegisterContextForFrame` base definition, 
returning a `RegisterContextSP` and not taking a `Status&` as an argument. I 
agree this should be refactored but that should be done on a separate patch.

For now, I refactored the code to log the error on the thread channel.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112167

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


[Lldb-commits] [PATCH] D113598: [debugserver] Remove unused variable

2021-11-10 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D113598

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


[Lldb-commits] [PATCH] D113598: [debugserver] Remove unused variable

2021-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: jasonmolenda.
JDevlieghere requested review of this revision.

https://reviews.llvm.org/D113598

Files:
  lldb/tools/debugserver/source/RNBRemote.cpp


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -4921,7 +4921,6 @@
   const char *gdb_type = default_gdb_type;
   const char *default_lldb_format = "hex";
   const char *lldb_format = default_lldb_format;
-  const char *lldb_set = NULL;
 
   switch (reg.nub_info.type) {
   case Uint:
@@ -4989,8 +4988,6 @@
 lldb_format = "vector-uint128";
 break;
   };
-  if (reg_set_info && reg.nub_info.set < num_reg_sets)
-lldb_set = reg_set_info[reg.nub_info.set].name;
 
   uint32_t indent = 2;
 


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -4921,7 +4921,6 @@
   const char *gdb_type = default_gdb_type;
   const char *default_lldb_format = "hex";
   const char *lldb_format = default_lldb_format;
-  const char *lldb_set = NULL;
 
   switch (reg.nub_info.type) {
   case Uint:
@@ -4989,8 +4988,6 @@
 lldb_format = "vector-uint128";
 break;
   };
-  if (reg_set_info && reg.nub_info.set < num_reg_sets)
-lldb_set = reg_set_info[reg.nub_info.set].name;
 
   uint32_t indent = 2;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D113330: [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in breakpad.

2021-11-10 Thread Zequan Wu via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc9ced0ed420: [LLDB][Breakpad] Make lldb understand INLINE 
and INLINE_ORIGIN records in… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113330

Files:
  lldb/include/lldb/Symbol/Block.h
  lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
  lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Symbol/Block.cpp
  lldb/test/Shell/SymbolFile/Breakpad/Inputs/inline-record.syms
  lldb/test/Shell/SymbolFile/Breakpad/inline-record.test
  lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp

Index: lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
===
--- lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
+++ lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
@@ -18,6 +18,8 @@
   EXPECT_EQ(Record::Info, Record::classify("INFO"));
   EXPECT_EQ(Record::File, Record::classify("FILE"));
   EXPECT_EQ(Record::Func, Record::classify("FUNC"));
+  EXPECT_EQ(Record::Inline, Record::classify("INLINE"));
+  EXPECT_EQ(Record::InlineOrigin, Record::classify("INLINE_ORIGIN"));
   EXPECT_EQ(Record::Public, Record::classify("PUBLIC"));
   EXPECT_EQ(Record::StackCFI, Record::classify("STACK CFI"));
   EXPECT_EQ(Record::StackWin, Record::classify("STACK WIN"));
@@ -76,6 +78,27 @@
   EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC"));
 }
 
+TEST(InlineOriginRecord, parse) {
+  EXPECT_EQ(InlineOriginRecord(47, "foo"),
+InlineOriginRecord::parse("INLINE_ORIGIN 47 foo"));
+  EXPECT_EQ(llvm::None, InlineOriginRecord::parse("INLINE_ORIGIN 47"));
+  EXPECT_EQ(llvm::None, InlineOriginRecord::parse("INLINE_ORIGIN"));
+  EXPECT_EQ(llvm::None, InlineOriginRecord::parse(""));
+}
+
+TEST(InlineRecord, parse) {
+  InlineRecord record1 = InlineRecord(0, 1, 2, 3);
+  record1.Ranges.emplace_back(4, 5);
+  EXPECT_EQ(record1, InlineRecord::parse("INLINE 0 1 2 3 4 5"));
+  record1.Ranges.emplace_back(6, 7);
+  EXPECT_EQ(record1, InlineRecord::parse("INLINE 0 1 2 3 4 5 6 7"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("INLINE 0 1 2 3"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("INLINE 0 1 2 3 4 5 6"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("INLNIE 0"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse(""));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("FUNC"));
+}
+
 TEST(LineRecord, parse) {
   EXPECT_EQ(LineRecord(0x47, 0x74, 47, 74), LineRecord::parse("47 74 47 74"));
   EXPECT_EQ(llvm::None, LineRecord::parse("47 74 47"));
Index: lldb/test/Shell/SymbolFile/Breakpad/inline-record.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/Breakpad/inline-record.test
@@ -0,0 +1,56 @@
+# RUN: yaml2obj %S/Inputs/basic-elf.yaml -o %T/inline-record.out
+# RUN: %lldb %T/inline-record.out -o "target symbols add -s inline-record.out %S/Inputs/inline-record.syms" \
+# RUN:   -s %s | FileCheck --match-full-lines %s
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400010 -v
+# CHECK:   Summary: inline-record.out`f1 [inlined] inlined_f1 at a.c:3
+# CHECK-NEXT:   inline-record.out`f1 at a.c:8
+# CHECK:  Function: id = {0x}, name = "f1", range = [0x00400010-0x00400020)
+# CHECK-NEXT:   Blocks: id = {0x}, range = [0x00400010-0x00400020)
+# CHECK-NEXT:   id = {0x0010}, ranges = [0x00400010-0x00400015)[0x00400017-0x0040001b), name = "inlined_f1"
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400016 -v
+# CHECK:   Summary: inline-record.out`f1 + 6 at a.c:3
+# CHECK-NOT:inline-record.out`f1
+# CHECK:  Function: id = {0x}, name = "f1", range = [0x00400010-0x00400020)
+# CHECK-NEXT:   Blocks: id = {0x}, range = [0x00400010-0x00400020)
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400023 -v
+# CHECK:  Summary: inline-record.out`f2 + 3 [inlined] inlined_f2 at b.c:2
+# CHECK-NEXT:  inline-record.out`f2 + 3 [inlined] inlined_f1 at b.c:4
+# CHECK-NEXT:  inline-record.out`f2 + 3 at a.c:3
+# CHECK:  Function: id = {0x0001}, name = "f2", range = [0x00400020-0x00400030)
+# CHECK-NEXT:   Blocks: id = {0x0001}, range = [0x00400020-0x00400030)
+# CHECK-NEXT:   id = {0x0043}, range = [0x00400023-0x0040002d), name = "inlined_f1"
+# CHECK-NEXT:   id = {0x0057}, range = [0x00400023-0x00400028), name = "inlined_f2"
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400029 -v
+# CHECK:  Summary: inline-record.out`f2 + 9 [inlined] inlined_f1 + 6 at b.c:2
+# CHECK-NEXT:  

[Lldb-commits] [lldb] cc9ced0 - [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in breakpad.

2021-11-10 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2021-11-10T11:20:32-08:00
New Revision: cc9ced0ed4202a4f8a550551bbb14584f93f3055

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

LOG: [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in 
breakpad.

Teach LLDB to understand INLINE and INLINE_ORIGIN records in breakpad.
They have the following formats:
```
INLINE inline_nest_level call_site_line call_site_file_num origin_num [address 
size]+
INLINE_ORIGIN origin_num name
```
`INLNIE_ORIGIN` is simply a string pool for INLINE so that we won't have
duplicated names for inlined functions and can show up anywhere in the symbol
file.
`INLINE` follows immediately after `FUNC` represents the ranges of momery
address that has functions inlined inside the function.

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

Added: 
lldb/test/Shell/SymbolFile/Breakpad/Inputs/inline-record.syms
lldb/test/Shell/SymbolFile/Breakpad/inline-record.test

Modified: 
lldb/include/lldb/Symbol/Block.h
lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Symbol/Block.cpp
lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Block.h 
b/lldb/include/lldb/Symbol/Block.h
index de94556d3f228..02fd2add53103 100644
--- a/lldb/include/lldb/Symbol/Block.h
+++ b/lldb/include/lldb/Symbol/Block.h
@@ -338,6 +338,8 @@ class Block : public UserID, public SymbolContextScope {
 
   Block *FindBlockByID(lldb::user_id_t block_id);
 
+  Block *FindInnermostBlockByOffset(const lldb::addr_t offset);
+
   size_t GetNumRanges() const { return m_ranges.GetSize(); }
 
   bool GetRangeContainingOffset(const lldb::addr_t offset, Range );

diff  --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp 
b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
index bd8eeedce57d4..24941be515de0 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
@@ -23,6 +23,8 @@ enum class Token {
   CodeID,
   File,
   Func,
+  Inline,
+  InlineOrigin,
   Public,
   Stack,
   CFI,
@@ -41,6 +43,8 @@ template <> Token stringTo(llvm::StringRef Str) {
   .Case("CODE_ID", Token::CodeID)
   .Case("FILE", Token::File)
   .Case("FUNC", Token::Func)
+  .Case("INLINE", Token::Inline)
+  .Case("INLINE_ORIGIN", Token::InlineOrigin)
   .Case("PUBLIC", Token::Public)
   .Case("STACK", Token::Stack)
   .Case("CFI", Token::CFI)
@@ -145,7 +149,10 @@ llvm::Optional 
Record::classify(llvm::StringRef Line) {
 default:
   return llvm::None;
 }
-
+  case Token::Inline:
+return Record::Inline;
+  case Token::InlineOrigin:
+return Record::InlineOrigin;
   case Token::Unknown:
 // Optimistically assume that any unrecognised token means this is a line
 // record, those don't have a special keyword and start directly with a
@@ -216,9 +223,11 @@ llvm::raw_ostream ::operator<<(llvm::raw_ostream 
,
   return OS << "INFO CODE_ID " << R.ID.GetAsString();
 }
 
-llvm::Optional FileRecord::parse(llvm::StringRef Line) {
-  // FILE number name
-  if (consume(Line) != Token::File)
+template 
+static llvm::Optional parseNumberName(llvm::StringRef Line,
+ Token TokenType) {
+  // TOKEN number name
+  if (consume(Line) != TokenType)
 return llvm::None;
 
   llvm::StringRef Str;
@@ -231,7 +240,12 @@ llvm::Optional 
FileRecord::parse(llvm::StringRef Line) {
   if (Name.empty())
 return llvm::None;
 
-  return FileRecord(Number, Name);
+  return T(Number, Name);
+}
+
+llvm::Optional FileRecord::parse(llvm::StringRef Line) {
+  // FILE number name
+  return parseNumberName(Line, Token::File);
 }
 
 llvm::raw_ostream ::operator<<(llvm::raw_ostream ,
@@ -239,6 +253,17 @@ llvm::raw_ostream ::operator<<(llvm::raw_ostream 
,
   return OS << "FILE " << R.Number << " " << R.Name;
 }
 
+llvm::Optional
+InlineOriginRecord::parse(llvm::StringRef Line) {
+  // INLINE_ORIGIN number name
+  return parseNumberName(Line, Token::InlineOrigin);
+}
+
+llvm::raw_ostream ::operator<<(llvm::raw_ostream ,
+const InlineOriginRecord ) {
+  return OS << "INLINE_ORIGIN " << R.Number << " " << R.Name;
+}
+
 static bool parsePublicOrFunc(llvm::StringRef Line, bool ,
   lldb::addr_t , lldb::addr_t *Size,
   lldb::addr_t , llvm::StringRef ) {
@@ -299,6 +324,58 @@ 

[Lldb-commits] [PATCH] D113330: [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in breakpad.

2021-11-10 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu updated this revision to Diff 386256.
zequanwu added a comment.

Rebased and add test cases for out of range file/origin index.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113330

Files:
  lldb/include/lldb/Symbol/Block.h
  lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
  lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Symbol/Block.cpp
  lldb/test/Shell/SymbolFile/Breakpad/Inputs/inline-record.syms
  lldb/test/Shell/SymbolFile/Breakpad/inline-record.test
  lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp

Index: lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
===
--- lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
+++ lldb/unittests/ObjectFile/Breakpad/BreakpadRecordsTest.cpp
@@ -18,6 +18,8 @@
   EXPECT_EQ(Record::Info, Record::classify("INFO"));
   EXPECT_EQ(Record::File, Record::classify("FILE"));
   EXPECT_EQ(Record::Func, Record::classify("FUNC"));
+  EXPECT_EQ(Record::Inline, Record::classify("INLINE"));
+  EXPECT_EQ(Record::InlineOrigin, Record::classify("INLINE_ORIGIN"));
   EXPECT_EQ(Record::Public, Record::classify("PUBLIC"));
   EXPECT_EQ(Record::StackCFI, Record::classify("STACK CFI"));
   EXPECT_EQ(Record::StackWin, Record::classify("STACK WIN"));
@@ -76,6 +78,27 @@
   EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC"));
 }
 
+TEST(InlineOriginRecord, parse) {
+  EXPECT_EQ(InlineOriginRecord(47, "foo"),
+InlineOriginRecord::parse("INLINE_ORIGIN 47 foo"));
+  EXPECT_EQ(llvm::None, InlineOriginRecord::parse("INLINE_ORIGIN 47"));
+  EXPECT_EQ(llvm::None, InlineOriginRecord::parse("INLINE_ORIGIN"));
+  EXPECT_EQ(llvm::None, InlineOriginRecord::parse(""));
+}
+
+TEST(InlineRecord, parse) {
+  InlineRecord record1 = InlineRecord(0, 1, 2, 3);
+  record1.Ranges.emplace_back(4, 5);
+  EXPECT_EQ(record1, InlineRecord::parse("INLINE 0 1 2 3 4 5"));
+  record1.Ranges.emplace_back(6, 7);
+  EXPECT_EQ(record1, InlineRecord::parse("INLINE 0 1 2 3 4 5 6 7"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("INLINE 0 1 2 3"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("INLINE 0 1 2 3 4 5 6"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("INLNIE 0"));
+  EXPECT_EQ(llvm::None, InlineRecord::parse(""));
+  EXPECT_EQ(llvm::None, InlineRecord::parse("FUNC"));
+}
+
 TEST(LineRecord, parse) {
   EXPECT_EQ(LineRecord(0x47, 0x74, 47, 74), LineRecord::parse("47 74 47 74"));
   EXPECT_EQ(llvm::None, LineRecord::parse("47 74 47"));
Index: lldb/test/Shell/SymbolFile/Breakpad/inline-record.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/Breakpad/inline-record.test
@@ -0,0 +1,56 @@
+# RUN: yaml2obj %S/Inputs/basic-elf.yaml -o %T/inline-record.out
+# RUN: %lldb %T/inline-record.out -o "target symbols add -s inline-record.out %S/Inputs/inline-record.syms" \
+# RUN:   -s %s | FileCheck --match-full-lines %s
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400010 -v
+# CHECK:   Summary: inline-record.out`f1 [inlined] inlined_f1 at a.c:3
+# CHECK-NEXT:   inline-record.out`f1 at a.c:8
+# CHECK:  Function: id = {0x}, name = "f1", range = [0x00400010-0x00400020)
+# CHECK-NEXT:   Blocks: id = {0x}, range = [0x00400010-0x00400020)
+# CHECK-NEXT:   id = {0x0010}, ranges = [0x00400010-0x00400015)[0x00400017-0x0040001b), name = "inlined_f1"
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400016 -v
+# CHECK:   Summary: inline-record.out`f1 + 6 at a.c:3
+# CHECK-NOT:inline-record.out`f1
+# CHECK:  Function: id = {0x}, name = "f1", range = [0x00400010-0x00400020)
+# CHECK-NEXT:   Blocks: id = {0x}, range = [0x00400010-0x00400020)
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400023 -v
+# CHECK:  Summary: inline-record.out`f2 + 3 [inlined] inlined_f2 at b.c:2
+# CHECK-NEXT:  inline-record.out`f2 + 3 [inlined] inlined_f1 at b.c:4
+# CHECK-NEXT:  inline-record.out`f2 + 3 at a.c:3
+# CHECK:  Function: id = {0x0001}, name = "f2", range = [0x00400020-0x00400030)
+# CHECK-NEXT:   Blocks: id = {0x0001}, range = [0x00400020-0x00400030)
+# CHECK-NEXT:   id = {0x0043}, range = [0x00400023-0x0040002d), name = "inlined_f1"
+# CHECK-NEXT:   id = {0x0057}, range = [0x00400023-0x00400028), name = "inlined_f2"
+
+# CHECK-LABEL: (lldb) image lookup -a 0x400029 -v
+# CHECK:  Summary: inline-record.out`f2 + 9 [inlined] inlined_f1 + 6 at b.c:2
+# CHECK-NEXT:  inline-record.out`f2 + 3 at a.c:3
+# CHECK:  Function: id = {0x0001}, name = "f2", range = 

[Lldb-commits] [lldb] 419b471 - [lldb/test] Skip TestScriptedProcess when using system's debugserver (NFC)

2021-11-10 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-11-10T20:12:42+01:00
New Revision: 419b4711961216b9c09d06735bb4d442a213fe57

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

LOG: [lldb/test] Skip TestScriptedProcess when using system's debugserver (NFC)

Because TestScriptedProcess.py creates a skinny corefile to provides data
to the ScriptedProcess and ScriptedThread, we need to make sure that the
debugserver used is not out of tree, to ensure feature availability
between debugserver and lldb.

This also removes the `SKIP_SCRIPTED_PROCESS_LAUNCH` env variable after
each test finish running.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py 
b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
index b8319d722e34..342068328310 100644
--- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -51,8 +51,12 @@ def test_scripted_process_and_scripted_thread(self):
 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
 self.assertTrue(target, VALID_TARGET)
 
-scripted_process_example_relpath = 'dummy_scripted_process.py'
 os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
+def cleanup():
+  del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
+self.addTearDownHook(cleanup)
+
+scripted_process_example_relpath = 'dummy_scripted_process.py'
 self.runCmd("command script import " + 
os.path.join(self.getSourceDir(),
 
scripted_process_example_relpath))
 
@@ -98,6 +102,7 @@ def create_stack_skinny_corefile(self, file):
 self.assertTrue(self.dbg.DeleteTarget(target), "Couldn't delete 
target")
 
 @skipUnlessDarwin
+@skipIfOutOfTreeDebugserver
 @skipIf(archs=no_match(['x86_64']))
 def test_launch_scripted_process_stack_frames(self):
 """Test that we can launch an lldb scripted process from the command
@@ -115,8 +120,12 @@ def test_launch_scripted_process_stack_frames(self):
 error = target.SetModuleLoadAddress(main_module, 0)
 self.assertTrue(error.Success(), "Reloading main module at offset 0 
failed.")
 
-scripted_process_example_relpath = 'stack_core_scripted_process.py'
 os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
+def cleanup():
+  del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
+self.addTearDownHook(cleanup)
+
+scripted_process_example_relpath = 'stack_core_scripted_process.py'
 self.runCmd("command script import " + 
os.path.join(self.getSourceDir(),
 
scripted_process_example_relpath))
 



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


[Lldb-commits] [PATCH] D111409: proposed support for Java interface to Scripting Bridge

2021-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Hi David, this looks really comprehensive. As far as the code is concerned, it 
has all the parts that we'd want to support another scripting language in LLDB. 
That leaves us with the last remaining questions:

- Testing: having a bot that actually builds & tests this configuration.
- Maintainership: having a commitment from you (or someone else) to maintain 
this code.

Are you willing and able to sign up for those things?

PS: I installed Java and applied your patch on top-of-tree. Things didn't built 
because of the recent change to the plugin manager that now expects 
`StringRef`s instead of `ConstString`s. Please let me know if you've rebased 
the patch and I'd love to give it a try.




Comment at: lldb/cmake/modules/FindJavaAndSwig.cmake:13
+find_package(Java 11.0)
+find_package(JNI REQUIRED)
+if(JAVA_FOUND AND SWIG_FOUND)

This can't be `REQUIRED` because that will fail the CMake configuration stage 
when Java isn't found which is not what you want when doing autodetection (the 
default). Making it required is handled at a higher level for `FindJavaAndSwig` 
as a whole. 


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D111409

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


[Lldb-commits] [PATCH] D113163: [LLDB][Breakpad] Create a function for each compilation unit.

2021-11-10 Thread Zequan Wu via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfbf665a0086c: [LLDB][Breakpad] Create a function for each 
compilation unit. (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113163

Files:
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/test/Shell/Minidump/Inputs/linux-x86_64.syms
  lldb/test/Shell/Minidump/breakpad-symbols.test
  lldb/test/Shell/SymbolFile/Breakpad/line-table.test
  lldb/test/Shell/SymbolFile/Breakpad/symtab.test

Index: lldb/test/Shell/SymbolFile/Breakpad/symtab.test
===
--- lldb/test/Shell/SymbolFile/Breakpad/symtab.test
+++ lldb/test/Shell/SymbolFile/Breakpad/symtab.test
@@ -3,17 +3,17 @@
 # RUN:   -s %s | FileCheck %s
 
 # CHECK-LABEL: (lldb) image dump symtab symtab.out
-# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
+# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address   Size   Flags  Name
 # CHECK: [0]  0  SX Code0x00400x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}
-# CHECK: [1]  0   X Code0x004000b00x000c 0x f1_func
-# CHECK: [2]  0   X Code0x004000a00x000d 0x func_only
-# CHECK: [3]  0   X Code0x004000c00x0010 0x f2
-# CHECK: [4]  0   X Code0x004000d00x0022 0x _start
+# CHECK: [1]  0   X Code0x004000b00x0010 0x f1
+# CHECK: [2]  0   X Code0x004000c00x0010 0x f2
+# CHECK: [3]  0   X Code0x004000d00x0022 0x _start
 
 # CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v
 # CHECK: Address: symtab.out[0x004000b0] (symtab.out.PT_LOAD[0]..text2 + 0)
-# CHECK: Symbol: id = {0x}, range = [0x004000b0-0x004000bc), name="f1_func"
+# CHECK: Function: id = {0x0001}, name = "f1_func", range = [0x004000b0-0x004000bc)
+# CHECK: Symbol: id = {0x}, range = [0x004000b0-0x004000c0), name="f1"
 
 # CHECK-LABEL: (lldb) image lookup -n f2 -v
 # CHECK: Address: symtab.out[0x004000c0] (symtab.out.PT_LOAD[0]..text2 + 16)
Index: lldb/test/Shell/SymbolFile/Breakpad/line-table.test
===
--- lldb/test/Shell/SymbolFile/Breakpad/line-table.test
+++ lldb/test/Shell/SymbolFile/Breakpad/line-table.test
@@ -39,7 +39,16 @@
 image lookup -a 0x4000b2 -v
 # CHECK-LABEL: image lookup -a 0x4000b2 -v
 # CHECK: Summary: line-table.out`func + 2
+# CHECK: Function: id = {0x}, name = "func", range = [0x004000b0-0x004000c0)
+
+image dump symfile
+# CHECK-LABEL: Compile units:
+# CHECK-NEXT:  CompileUnit{0x}, language = "", file = '/tmp/a.c'
+# CHECK-NEXT:   Function{0x}, demangled = func, type_uid = 0x
+# CHECK:  CompileUnit{0x0001}, language = "", file = '/tmp/c.c'
+# CHECK-NEXT:  CompileUnit{0x0002}, language = "", file = '/tmp/d.c'
+# CHECK-NEXT:  CompileUnit{0x0003}, language = "", file = '/tmp/d.c'
 
 breakpoint set -f c.c -l 2
 # CHECK-LABEL: breakpoint set -f c.c -l 2
-# CHECK: Breakpoint 1: where = line-table.out`func + 2, address = 0x004000b2
+# CHECK: Breakpoint 1: where = line-table.out`func + 2 at c.c:2, address = 0x004000b2
Index: lldb/test/Shell/Minidump/breakpad-symbols.test
===
--- lldb/test/Shell/Minidump/breakpad-symbols.test
+++ lldb/test/Shell/Minidump/breakpad-symbols.test
@@ -15,8 +15,8 @@
 image dump symtab /tmp/test/linux-x86_64
 # CHECK-LABEL: image dump symtab /tmp/test/linux-x86_64
 # CHECK: Symtab, file = /tmp/test/linux-x86_64, num_symbols = 2:
-# CHECK: [0]  0   X Code0x004003d0 0x004003d0 0x0018 0x crash()
-# CHECK: [1]  0   X Code0x004003f0 0x004003f0 0x0010 0x _start
+# CHECK: [0]  0   X Code0x004003d0 0x004003d0 0x0020 0x crash()
+# CHECK: [1]  0   X Code0x004003f0 0x004003f0 0x0c10 0x _start
 
 image lookup -a 0x4003f3
 # CHECK-LABEL: image lookup -a 0x4003f3
Index: lldb/test/Shell/Minidump/Inputs/linux-x86_64.syms

[Lldb-commits] [lldb] fbf665a - [LLDB][Breakpad] Create a function for each compilation unit.

2021-11-10 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2021-11-10T10:51:16-08:00
New Revision: fbf665a0086c8d88d62d60320bef4466c590132e

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

LOG: [LLDB][Breakpad] Create a function for each compilation unit.

Since every FUNC record (in breakpad) is a compilation unit, creating the
function for the CU allows `ResolveSymbolContext` to resolve
`eSymbolContextFunction`.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/test/Shell/Minidump/Inputs/linux-x86_64.syms
lldb/test/Shell/Minidump/breakpad-symbols.test
lldb/test/Shell/SymbolFile/Breakpad/line-table.test
lldb/test/Shell/SymbolFile/Breakpad/symtab.test

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index ef11ed2a39415..3795147668c88 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -219,9 +219,45 @@ CompUnitSP 
SymbolFileBreakpad::ParseCompileUnitAtIndex(uint32_t index) {
   return cu_sp;
 }
 
+FunctionSP SymbolFileBreakpad::GetOrCreateFunction(CompileUnit _unit) {
+  user_id_t id = comp_unit.GetID();
+  if (FunctionSP func_sp = comp_unit.FindFunctionByUID(id))
+return func_sp;
+
+  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
+  FunctionSP func_sp;
+  addr_t base = GetBaseFileAddress();
+  if (base == LLDB_INVALID_ADDRESS) {
+LLDB_LOG(log, "Unable to fetch the base address of object file. Skipping "
+  "symtab population.");
+return func_sp;
+  }
+
+  const SectionList *list = comp_unit.GetModule()->GetSectionList();
+  CompUnitData  = m_cu_data->GetEntryRef(id).data;
+  LineIterator It(*m_objfile_sp, Record::Func, data.bookmark);
+  assert(Record::classify(*It) == Record::Func);
+
+  if (auto record = FuncRecord::parse(*It)) {
+Mangled func_name;
+func_name.SetValue(ConstString(record->Name), false);
+addr_t address = record->Address + base;
+SectionSP section_sp = list->FindSectionContainingFileAddress(address);
+if (section_sp) {
+  AddressRange func_range(
+  section_sp, address - section_sp->GetFileAddress(), record->Size);
+  // Use the CU's id because every CU has only one function inside.
+  func_sp = std::make_shared(_unit, id, 0, func_name,
+   nullptr, func_range);
+  comp_unit.AddFunction(func_sp);
+}
+  }
+  return func_sp;
+}
+
 size_t SymbolFileBreakpad::ParseFunctions(CompileUnit _unit) {
-  // TODO
-  return 0;
+  std::lock_guard guard(GetModuleMutex());
+  return GetOrCreateFunction(comp_unit) ? 1 : 0;
 }
 
 bool SymbolFileBreakpad::ParseLineTable(CompileUnit _unit) {
@@ -251,7 +287,8 @@ SymbolFileBreakpad::ResolveSymbolContext(const Address 
_addr,
  SymbolContextItem resolve_scope,
  SymbolContext ) {
   std::lock_guard guard(GetModuleMutex());
-  if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry)))
+  if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry |
+ eSymbolContextFunction)))
 return 0;
 
   ParseCUData();
@@ -268,6 +305,13 @@ SymbolFileBreakpad::ResolveSymbolContext(const Address 
_addr,
   result |= eSymbolContextLineEntry;
 }
   }
+  if (resolve_scope & eSymbolContextFunction) {
+FunctionSP func_sp = GetOrCreateFunction(*sc.comp_unit);
+if (func_sp) {
+  sc.function = func_sp.get();
+  result |= eSymbolContextFunction;
+}
+  }
 
   return result;
 }
@@ -291,7 +335,20 @@ void SymbolFileBreakpad::FindFunctions(
 ConstString name, const CompilerDeclContext _decl_ctx,
 FunctionNameType name_type_mask, bool include_inlines,
 SymbolContextList _list) {
-  // TODO
+  std::lock_guard guard(GetModuleMutex());
+  // TODO: Implement this with supported FunctionNameType.
+
+  for (uint32_t i = 0; i < GetNumCompileUnits(); ++i) {
+CompUnitSP cu_sp = GetCompileUnitAtIndex(i);
+FunctionSP func_sp = GetOrCreateFunction(*cu_sp);
+if (func_sp && name == func_sp->GetNameNoArguments()) {
+  SymbolContext sc;
+  sc.comp_unit = cu_sp.get();
+  sc.function = func_sp.get();
+  sc.module_sp = func_sp->CalculateSymbolContextModule();
+  sc_list.Append(sc);
+}
+  }
 }
 
 void SymbolFileBreakpad::FindFunctions(const RegularExpression ,
@@ -346,11 +403,6 @@ void SymbolFileBreakpad::AddSymbols(Symtab ) {
 size.hasValue(), /*contains_linker_annotations*/ false, /*flags*/ 0);
 

[Lldb-commits] [PATCH] D113449: Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"

2021-11-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG360d901bf047: Revert [lldb] Disable minimal import 
mode for RecordDecls that back FieldDecls (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113449

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/test/API/commands/expression/pr52257/Makefile
  lldb/test/API/commands/expression/pr52257/TestExprCrash.py
  lldb/test/API/commands/expression/pr52257/main.cpp
  lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py

Index: lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
===
--- lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
+++ lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
@@ -7,6 +7,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
+@expectedFailure("The fix for this was reverted due to llvm.org/PR52257")
 def test(self):
 self.build()
 self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
Index: lldb/test/API/commands/expression/pr52257/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/main.cpp
@@ -0,0 +1,12 @@
+template  struct pair {};
+struct A {
+  using iterator = pair;
+  pair a_[];
+};
+struct B {
+  using iterator = A::iterator;
+  iterator begin();
+  A *tag_set_;
+};
+B b;
+int main() {};
Index: lldb/test/API/commands/expression/pr52257/TestExprCrash.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/TestExprCrash.py
@@ -0,0 +1,18 @@
+"""
+Verify that LLDB doesn't crash during expression evaluation.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprCrashTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_pr52257(self):
+self.build()
+self.createTestTarget()
+self.expect_expr("b", result_type="B", result_children=[ValueCheck(name="tag_set_")])
Index: lldb/test/API/commands/expression/pr52257/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -479,7 +479,10 @@
decl->getDeclKindName(), ast_dump);
   }
 
-  CopyDecl(decl);
+  Decl *copied_decl = CopyDecl(decl);
+
+  if (!copied_decl)
+continue;
 
   // FIXME: We should add the copied decl to the 'decls' list. This would
   // add the copied Decl into the DeclContext and make sure that we
@@ -489,6 +492,12 @@
   // lookup issues later on.
   // We can't just add them for now as the ASTImporter already added the
   // decl into the DeclContext and this would add it twice.
+
+  if (FieldDecl *copied_field = dyn_cast(copied_decl)) {
+QualType copied_field_type = copied_field->getType();
+
+m_ast_importer_sp->RequireCompleteType(copied_field_type);
+  }
 } else {
   SkippedDecls = true;
 }
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -888,37 +888,6 @@
 LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
   }
 
-  // Disable the minimal import for fields that have record types. There is
-  // no point in minimally importing the record behind their type as Clang
-  // will anyway request their definition when the FieldDecl is added to the
-  // RecordDecl (as Clang will query the FieldDecl's type for things such
-  // as a deleted constexpr destructor).
-  // By importing the type ahead of time we avoid some corner cases where
-  // the FieldDecl's record is importing in the middle of Clang's
-  // `DeclContext::addDecl` logic.
-  if (clang::FieldDecl *fd = dyn_cast(From)) {
-// This is only necessary because we do the 'minimal import'. Remove this
-// once LLDB stopped using that mode.
-assert(isMinimalImport() && "Only necessary for minimal import");
-QualType field_type = fd->getType();
-if (field_type->isRecordType()) {
-  // First get the 

[Lldb-commits] [lldb] 360d901 - Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"

2021-11-10 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2021-11-10T10:38:01-08:00
New Revision: 360d901bf0478293d6e57f58bdb63b386f97f531

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

LOG: Revert "[lldb] Disable minimal import mode for RecordDecls that back 
FieldDecls"

This reverts commit 3bf96b0329be554c67282b0d7d8da6a864b9e38f.

It causes crashes as reported in PR52257 and a few other places. A reproducer 
is bundled with this commit to verify any fix forward. The original test is 
left in place, but marked XFAIL as it now produces the wrong result.

Reviewed By: teemperor

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

Added: 
lldb/test/API/commands/expression/pr52257/Makefile
lldb/test/API/commands/expression/pr52257/TestExprCrash.py
lldb/test/API/commands/expression/pr52257/main.cpp

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 94647b0ef9785..9ff6fbc28bf9c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -888,37 +888,6 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl 
*From) {
 LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
   }
 
-  // Disable the minimal import for fields that have record types. There is
-  // no point in minimally importing the record behind their type as Clang
-  // will anyway request their definition when the FieldDecl is added to the
-  // RecordDecl (as Clang will query the FieldDecl's type for things such
-  // as a deleted constexpr destructor).
-  // By importing the type ahead of time we avoid some corner cases where
-  // the FieldDecl's record is importing in the middle of Clang's
-  // `DeclContext::addDecl` logic.
-  if (clang::FieldDecl *fd = dyn_cast(From)) {
-// This is only necessary because we do the 'minimal import'. Remove this
-// once LLDB stopped using that mode.
-assert(isMinimalImport() && "Only necessary for minimal import");
-QualType field_type = fd->getType();
-if (field_type->isRecordType()) {
-  // First get the underlying record and minimally import it.
-  clang::TagDecl *record_decl = field_type->getAsTagDecl();
-  llvm::Expected imported = Import(record_decl);
-  if (!imported)
-return imported.takeError();
-  // Check how/if the import got redirected to a 
diff erent AST. Now
-  // import the definition of what was actually imported. If there is no
-  // origin then that means the record was imported by just picking a
-  // compatible type in the target AST (in which case there is no more
-  // importing to do).
-  if (clang::Decl *origin = m_master.GetDeclOrigin(*imported).decl) {
-if (llvm::Error def_err = ImportDefinition(record_decl))
-  return std::move(def_err);
-  }
-}
-  }
-
   return ASTImporter::ImportImpl(From);
 }
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index ae93252e55212..410d8a95cb120 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -479,7 +479,10 @@ void ClangASTSource::FindExternalLexicalDecls(
decl->getDeclKindName(), ast_dump);
   }
 
-  CopyDecl(decl);
+  Decl *copied_decl = CopyDecl(decl);
+
+  if (!copied_decl)
+continue;
 
   // FIXME: We should add the copied decl to the 'decls' list. This would
   // add the copied Decl into the DeclContext and make sure that we
@@ -489,6 +492,12 @@ void ClangASTSource::FindExternalLexicalDecls(
   // lookup issues later on.
   // We can't just add them for now as the ASTImporter already added the
   // decl into the DeclContext and this would add it twice.
+
+  if (FieldDecl *copied_field = dyn_cast(copied_decl)) {
+QualType copied_field_type = copied_field->getType();
+
+m_ast_importer_sp->RequireCompleteType(copied_field_type);
+  }
 } else {
   SkippedDecls = true;
 }

diff  --git a/lldb/test/API/commands/expression/pr52257/Makefile 
b/lldb/test/API/commands/expression/pr52257/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/commands/expression/pr52257/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 

[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbef51eb43c2: [lldb] make it easier to find LLDBs 
python (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/bindings/python/CMakeLists.txt
  lldb/bindings/python/lldb-python
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/test/API/functionalities/paths/TestPaths.py
  lldb/test/Shell/Driver/TestHelp.test
  lldb/tools/driver/Driver.cpp
  lldb/tools/driver/Driver.h
  lldb/tools/driver/Options.td

Index: lldb/tools/driver/Options.td
===
--- lldb/tools/driver/Options.td
+++ lldb/tools/driver/Options.td
@@ -48,6 +48,10 @@
   HelpText<"Alias for --python-path">,
   Group;
 
+def print_script_interpreter_info: F<"print-script-interpreter-info">,
+  HelpText<"Prints out a json dictionary with information about the scripting language interpreter.">,
+  Group;
+
 def script_language: Separate<["--", "-"], "script-language">,
   MetaVarName<"">,
   HelpText<"Tells the debugger to use the specified scripting language for user-defined scripts.">,
Index: lldb/tools/driver/Driver.h
===
--- lldb/tools/driver/Driver.h
+++ lldb/tools/driver/Driver.h
@@ -79,6 +79,7 @@
 bool m_source_quietly = false;
 bool m_print_version = false;
 bool m_print_python_path = false;
+bool m_print_script_interpreter_info = false;
 bool m_wait_for = false;
 bool m_repl = false;
 bool m_batch = false;
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -18,6 +18,7 @@
 #include "lldb/API/SBReproducer.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Format.h"
@@ -201,6 +202,9 @@
   if (args.hasArg(OPT_python_path)) {
 m_option_data.m_print_python_path = true;
   }
+  if (args.hasArg(OPT_print_script_interpreter_info)) {
+m_option_data.m_print_script_interpreter_info = true;
+  }
 
   if (args.hasArg(OPT_batch)) {
 m_option_data.m_batch = true;
@@ -398,6 +402,22 @@
 return error;
   }
 
+  if (m_option_data.m_print_script_interpreter_info) {
+SBStructuredData info =
+m_debugger.GetScriptInterpreterInfo(m_debugger.GetScriptLanguage());
+if (!info) {
+  error.SetErrorString("no script interpreter.");
+} else {
+  SBStream stream;
+  error = info.GetAsJSON(stream);
+  if (error.Success()) {
+llvm::outs() << stream.GetData() << '\n';
+  }
+}
+exiting = true;
+return error;
+  }
+
   return error;
 }
 
Index: lldb/test/Shell/Driver/TestHelp.test
===
--- lldb/test/Shell/Driver/TestHelp.test
+++ lldb/test/Shell/Driver/TestHelp.test
@@ -62,6 +62,7 @@
 
 CHECK: SCRIPTING
 CHECK: -l
+CHECK: --print-script-interpreter-info
 CHECK: --python-path
 CHECK: -P
 CHECK: --script-language
Index: lldb/test/API/functionalities/paths/TestPaths.py
===
--- lldb/test/API/functionalities/paths/TestPaths.py
+++ lldb/test/API/functionalities/paths/TestPaths.py
@@ -5,6 +5,8 @@
 
 import lldb
 import os
+import sys
+import json
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
@@ -42,6 +44,21 @@
 self.assertTrue(any([os.path.exists(os.path.join(shlib_dir, f)) for f in
 filenames]), "shlib_dir = " + shlib_dir)
 
+@no_debug_info_test
+def test_interpreter_info(self):
+info_sd = self.dbg.GetScriptInterpreterInfo(self.dbg.GetScriptingLanguage("python"))
+self.assertTrue(info_sd.IsValid())
+stream = lldb.SBStream()
+self.assertTrue(info_sd.GetAsJSON(stream).Success())
+info = json.loads(stream.GetData())
+prefix = info['prefix']
+self.assertEqual(os.path.realpath(sys.prefix), os.path.realpath(prefix))
+self.assertEqual(
+os.path.realpath(os.path.join(info['lldb-pythonpath'], 'lldb')),
+

[Lldb-commits] [lldb] bbef51e - [lldb] make it easier to find LLDB's python

2021-11-10 Thread Lawrence D'Anna via lldb-commits

Author: Lawrence D'Anna
Date: 2021-11-10T10:33:34-08:00
New Revision: bbef51eb43c2e8f8e36fbbc0d0b4cca75b6f0863

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

LOG: [lldb] make it easier to find LLDB's python

It is surprisingly difficult to write a simple python script that
can reliably `import lldb` without failing, or crashing.   I'm
currently resorting to convolutions like this:

def find_lldb(may_reexec=False):
if prefix := os.environ.get('LLDB_PYTHON_PREFIX'):
if os.path.realpath(prefix) != 
os.path.realpath(sys.prefix):
raise Exception("cannot import lldb.\n"
f"  sys.prefix should be: {prefix}\n"
f"  but it is: {sys.prefix}")
else:
line1, line2 = subprocess.run(
['lldb', '-x', '-b', '-o', 'script 
print(sys.prefix)'],
encoding='utf8', stdout=subprocess.PIPE,
check=True).stdout.strip().splitlines()
assert line1.strip() == '(lldb) script 
print(sys.prefix)'
prefix = line2.strip()
os.environ['LLDB_PYTHON_PREFIX'] = prefix

if sys.prefix != prefix:
if not may_reexec:
raise Exception(
"cannot import lldb.\n" +
f"  This python, at {sys.prefix}\n"
f"  does not math LLDB's python at 
{prefix}")
os.environ['LLDB_PYTHON_PREFIX'] = prefix
python_exe = os.path.join(prefix, 'bin', 'python3')
os.execl(python_exe, python_exe, *sys.argv)

lldb_path = subprocess.run(['lldb', '-P'],
check=True, stdout=subprocess.PIPE,
encoding='utf8').stdout.strip()

sys.path = [lldb_path] + sys.path

This patch aims to replace all that with:

  #!/usr/bin/env lldb-python
  import lldb
  ...

... by adding the following features:

* new command line option: --print-script-interpreter-info.  This
   prints language-specific information about the script interpreter
   in JSON format.

* new tool (unix only): lldb-python which finds python and exec's it.

Reviewed By: JDevlieghere

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

Added: 
lldb/bindings/python/lldb-python

Modified: 
lldb/bindings/interface/SBDebugger.i
lldb/bindings/python/CMakeLists.txt
lldb/docs/man/lldb.rst
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/source/API/SBDebugger.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/test/API/functionalities/paths/TestPaths.py
lldb/test/Shell/Driver/TestHelp.test
lldb/tools/driver/Driver.cpp
lldb/tools/driver/Driver.h
lldb/tools/driver/Options.td

Removed: 




diff  --git a/lldb/bindings/interface/SBDebugger.i 
b/lldb/bindings/interface/SBDebugger.i
index cf4411980cc30..aae72dd513940 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -479,6 +479,8 @@ public:
 lldb::SBTypeSynthetic
 GetSyntheticForType (lldb::SBTypeNameSpecifier);
 
+SBStructuredData GetScriptInterpreterInfo(ScriptLanguage);
+
 STRING_EXTENSION(SBDebugger)
 
 %feature("docstring",

diff  --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 9422ee00cb5fc..5aabaf574636c 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -23,6 +23,18 @@ add_custom_target(swig_wrapper_python ALL DEPENDS
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
 
+if (NOT WIN32)
+add_custom_command(
+  OUTPUT  ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-python
+  VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E copy lldb-python 
${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-python
+  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+add_custom_target(lldb-python-wrapper ALL DEPENDS
+  ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-python
+)
+endif()
+
 function(create_python_package swig_target working_dir pkg_dir)
   cmake_parse_arguments(ARG 

[Lldb-commits] [PATCH] D113449: Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"

2021-11-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D113449#3121070 , @teemperor wrote:

> I actually didn't see that the patch deleted the TestCppReferenceToOuterClass 
> test. Could you just add a `@skipIf # Crashes` or so above its `def test...` 
> method? The test itself is still valid user code that we shouldn't crash on.

I assume you mean something like `expectedFailure`, as this should 
unconditionally fail.

> I left some nits and the test source probably needs to be made a bit more 
> expressive in terms of what's its trying to test, but this can all be done 
> later. Let's just land this to get the regression fixed.

OK, retesting real quick against trunk and submitting now. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113449

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


[Lldb-commits] [PATCH] D113449: Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"

2021-11-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 386227.
rupprecht added a comment.

- Use better test APIs, add test back w/ a @expectedFailure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113449

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/test/API/commands/expression/pr52257/Makefile
  lldb/test/API/commands/expression/pr52257/TestExprCrash.py
  lldb/test/API/commands/expression/pr52257/main.cpp
  lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py

Index: lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
===
--- lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
+++ lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
@@ -7,6 +7,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
+@expectedFailure("The fix for this was reverted due to llvm.org/PR52257")
 def test(self):
 self.build()
 self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
Index: lldb/test/API/commands/expression/pr52257/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/main.cpp
@@ -0,0 +1,12 @@
+template  struct pair {};
+struct A {
+  using iterator = pair;
+  pair a_[];
+};
+struct B {
+  using iterator = A::iterator;
+  iterator begin();
+  A *tag_set_;
+};
+B b;
+int main() {};
Index: lldb/test/API/commands/expression/pr52257/TestExprCrash.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/TestExprCrash.py
@@ -0,0 +1,18 @@
+"""
+Verify that LLDB doesn't crash during expression evaluation.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprCrashTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_pr52257(self):
+self.build()
+self.createTestTarget()
+self.expect_expr("b", result_type="B", result_children=[ValueCheck(name="tag_set_")])
Index: lldb/test/API/commands/expression/pr52257/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -479,7 +479,10 @@
decl->getDeclKindName(), ast_dump);
   }
 
-  CopyDecl(decl);
+  Decl *copied_decl = CopyDecl(decl);
+
+  if (!copied_decl)
+continue;
 
   // FIXME: We should add the copied decl to the 'decls' list. This would
   // add the copied Decl into the DeclContext and make sure that we
@@ -489,6 +492,12 @@
   // lookup issues later on.
   // We can't just add them for now as the ASTImporter already added the
   // decl into the DeclContext and this would add it twice.
+
+  if (FieldDecl *copied_field = dyn_cast(copied_decl)) {
+QualType copied_field_type = copied_field->getType();
+
+m_ast_importer_sp->RequireCompleteType(copied_field_type);
+  }
 } else {
   SkippedDecls = true;
 }
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -888,37 +888,6 @@
 LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
   }
 
-  // Disable the minimal import for fields that have record types. There is
-  // no point in minimally importing the record behind their type as Clang
-  // will anyway request their definition when the FieldDecl is added to the
-  // RecordDecl (as Clang will query the FieldDecl's type for things such
-  // as a deleted constexpr destructor).
-  // By importing the type ahead of time we avoid some corner cases where
-  // the FieldDecl's record is importing in the middle of Clang's
-  // `DeclContext::addDecl` logic.
-  if (clang::FieldDecl *fd = dyn_cast(From)) {
-// This is only necessary because we do the 'minimal import'. Remove this
-// once LLDB stopped using that mode.
-assert(isMinimalImport() && "Only necessary for minimal import");
-QualType field_type = fd->getType();
-if (field_type->isRecordType()) {
-  // First get the underlying record and minimally import it.
-  clang::TagDecl 

[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 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/D112973/new/

https://reviews.llvm.org/D112973

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


[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 386198.
lawrence_danna marked 3 inline comments as done.
lawrence_danna added a comment.

cleanup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/bindings/python/CMakeLists.txt
  lldb/bindings/python/lldb-python
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/test/API/functionalities/paths/TestPaths.py
  lldb/test/Shell/Driver/TestHelp.test
  lldb/tools/driver/Driver.cpp
  lldb/tools/driver/Driver.h
  lldb/tools/driver/Options.td

Index: lldb/tools/driver/Options.td
===
--- lldb/tools/driver/Options.td
+++ lldb/tools/driver/Options.td
@@ -48,6 +48,10 @@
   HelpText<"Alias for --python-path">,
   Group;
 
+def print_script_interpreter_info: F<"print-script-interpreter-info">,
+  HelpText<"Prints out a json dictionary with information about the scripting language interpreter.">,
+  Group;
+
 def script_language: Separate<["--", "-"], "script-language">,
   MetaVarName<"">,
   HelpText<"Tells the debugger to use the specified scripting language for user-defined scripts.">,
Index: lldb/tools/driver/Driver.h
===
--- lldb/tools/driver/Driver.h
+++ lldb/tools/driver/Driver.h
@@ -79,6 +79,7 @@
 bool m_source_quietly = false;
 bool m_print_version = false;
 bool m_print_python_path = false;
+bool m_print_script_interpreter_info = false;
 bool m_wait_for = false;
 bool m_repl = false;
 bool m_batch = false;
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -18,6 +18,7 @@
 #include "lldb/API/SBReproducer.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Format.h"
@@ -201,6 +202,9 @@
   if (args.hasArg(OPT_python_path)) {
 m_option_data.m_print_python_path = true;
   }
+  if (args.hasArg(OPT_print_script_interpreter_info)) {
+m_option_data.m_print_script_interpreter_info = true;
+  }
 
   if (args.hasArg(OPT_batch)) {
 m_option_data.m_batch = true;
@@ -398,6 +402,22 @@
 return error;
   }
 
+  if (m_option_data.m_print_script_interpreter_info) {
+SBStructuredData info =
+m_debugger.GetScriptInterpreterInfo(m_debugger.GetScriptLanguage());
+if (!info) {
+  error.SetErrorString("no script interpreter.");
+} else {
+  SBStream stream;
+  error = info.GetAsJSON(stream);
+  if (error.Success()) {
+llvm::outs() << stream.GetData() << '\n';
+  }
+}
+exiting = true;
+return error;
+  }
+
   return error;
 }
 
Index: lldb/test/Shell/Driver/TestHelp.test
===
--- lldb/test/Shell/Driver/TestHelp.test
+++ lldb/test/Shell/Driver/TestHelp.test
@@ -62,6 +62,7 @@
 
 CHECK: SCRIPTING
 CHECK: -l
+CHECK: --print-script-interpreter-info
 CHECK: --python-path
 CHECK: -P
 CHECK: --script-language
Index: lldb/test/API/functionalities/paths/TestPaths.py
===
--- lldb/test/API/functionalities/paths/TestPaths.py
+++ lldb/test/API/functionalities/paths/TestPaths.py
@@ -5,6 +5,8 @@
 
 import lldb
 import os
+import sys
+import json
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
@@ -42,6 +44,21 @@
 self.assertTrue(any([os.path.exists(os.path.join(shlib_dir, f)) for f in
 filenames]), "shlib_dir = " + shlib_dir)
 
+@no_debug_info_test
+def test_interpreter_info(self):
+info_sd = self.dbg.GetScriptInterpreterInfo(self.dbg.GetScriptingLanguage("python"))
+self.assertTrue(info_sd.IsValid())
+stream = lldb.SBStream()
+self.assertTrue(info_sd.GetAsJSON(stream).Success())
+info = json.loads(stream.GetData())
+prefix = info['prefix']
+self.assertEqual(os.path.realpath(sys.prefix), os.path.realpath(prefix))
+self.assertEqual(
+os.path.realpath(os.path.join(info['lldb-pythonpath'], 'lldb')),
+

[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added inline comments.



Comment at: lldb/include/lldb/API/SBHostOS.h:23
 
+  const char *GetScriptInterpreterInfo();
+

JDevlieghere wrote:
> Is still still relevant?
nope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

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


[Lldb-commits] [lldb] d96656c - [lldb] [test] Fix new signal tests to use remote-linux plugin

2021-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-11-10T18:08:05+01:00
New Revision: d96656ca9011db77ebbf6e91f380fb8894cbf820

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

LOG: [lldb] [test] Fix new signal tests to use remote-linux plugin

Hopefully this will fix OSX and Windows buildbots

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 96544f158fe7..7341fe13fa90 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -426,6 +426,7 @@ def cont(self):
 
 self.server.responder = MyResponder()
 
+self.runCmd("platform select remote-linux")
 target = self.createTarget("a.yaml")
 process = self.connect(target)
 
@@ -434,7 +435,6 @@ def cont(self):
 self.assertEqual(process.threads[0].GetStopDescription(100),
  'signal SIGBUS')
 
-@skipIfWindows
 def test_signal_lldb_old(self):
 class MyResponder(MockGDBServerResponder):
 def qSupported(self, client_supported):
@@ -454,6 +454,7 @@ def cont(self):
 
 self.server.responder = MyResponder()
 
+self.runCmd("platform select remote-linux")
 target = self.createTarget("a.yaml")
 process = self.connect(target)
 
@@ -462,7 +463,6 @@ def cont(self):
 self.assertEqual(process.threads[0].GetStopDescription(100),
  'signal SIGUSR1')
 
-@skipIfWindows
 def test_signal_lldb(self):
 class MyResponder(MockGDBServerResponder):
 def qSupported(self, client_supported):
@@ -479,6 +479,7 @@ def cont(self):
 
 self.server.responder = MyResponder()
 
+self.runCmd("platform select remote-linux")
 target = self.createTarget("a.yaml")
 process = self.connect(target)
 



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


[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

A few small nits but I'm very happy with the approach. Thanks Larry!




Comment at: lldb/include/lldb/API/SBHostOS.h:23
 
+  const char *GetScriptInterpreterInfo();
+

Is still still relevant?



Comment at: lldb/test/API/functionalities/paths/TestPaths.py:50
+info_sd = 
self.dbg.GetScriptInterpreterInfo(self.dbg.GetScriptingLanguage("python"))
+assert info_sd.IsValid()
+stream = lldb.SBStream()





Comment at: lldb/test/API/functionalities/paths/TestPaths.py:51
+assert info_sd.IsValid()
+stream = lldb.SBStream()
+assert info_sd.GetAsJSON(stream).Success()

Might be nice to check that all the keys you expect for Python are in the 
structured data, either here or in a separate test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

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


[Lldb-commits] [PATCH] D112047: [lldb/test] Update TestScriptedProcess to use skinny corefiles

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG976867b513ab: [lldb/test] Update TestScriptedProcess to use 
skinny corefiles (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112047

Files:
  lldb/examples/python/scripted_process/main.stack-dump
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  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
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -0,0 +1,139 @@
+import os,struct,signal
+
+from typing import Any, Dict
+
+import lldb
+from lldb.plugins.scripted_process import ScriptedProcess
+from lldb.plugins.scripted_process import ScriptedThread
+
+class StackCoreScriptedProcess(ScriptedProcess):
+def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
+super().__init__(target, args)
+
+self.backing_target_idx = args.GetValueForKey("backing_target_idx")
+
+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 = target.GetDebugger().GetTargetAtIndex(idx)
+self.corefile_process = self.corefile_target.GetProcess()
+
+def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
+mem_region = lldb.SBMemoryRegionInfo()
+error = self.corefile_process.GetMemoryRegionInfo(addr, mem_region)
+if error.Fail():
+return None
+return mem_region
+
+def get_thread_with_id(self, tid: int):
+return {}
+
+def get_registers_for_thread(self, tid: int):
+return {}
+
+def read_memory_at_address(self, addr: int, size: int) -> lldb.SBData:
+data = lldb.SBData()
+error = lldb.SBError()
+bytes_read = self.corefile_process.ReadMemory(addr, size, error)
+
+if error.Fail():
+return data
+
+data.SetData(error, bytes_read, self.corefile_target.GetByteOrder(),
+self.corefile_target.GetAddressByteSize())
+
+return data
+
+def get_loaded_images(self):
+# TODO: Iterate over corefile_target modules and build a data structure
+# from it.
+return self.loaded_images
+
+def get_process_id(self) -> int:
+return 42
+
+def should_stop(self) -> bool:
+return True
+
+def is_alive(self) -> bool:
+return True
+
+def get_scripted_thread_plugin(self):
+return StackCoreScriptedThread.__module__ + "." + StackCoreScriptedThread.__name__
+
+
+class StackCoreScriptedThread(ScriptedThread):
+def __init__(self, process, args):
+super().__init__(process, args)
+self.backing_target_idx = args.GetValueForKey("backing_target_idx")
+
+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_process = self.corefile_target.GetProcess()
+
+def get_thread_id(self) -> int:
+return 0x19
+
+def get_name(self) -> str:
+return StackCoreScriptedThread.__name__ + ".thread-1"
+
+def get_stop_reason(self) -> Dict[str, Any]:
+return { "type": lldb.eStopReasonSignal, "data": {
+"signal": signal.SIGINT
+} }
+
+def get_stackframes(self):
+class ScriptedStackFrame:
+def __init__(idx, cfa, pc, symbol_ctx):
+self.idx = idx
+self.cfa = cfa
+self.pc = pc
+self.symbol_ctx = symbol_ctx
+
+
+symbol_ctx = lldb.SBSymbolContext()
+frame_zero = ScriptedStackFrame(0, 0x42424242, 0x500, symbol_ctx)
+self.frames.append(frame_zero)
+
+return 

[Lldb-commits] [PATCH] D112046: [lldb/bindings] Change ScriptedThread initializer parameters

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG738621d047f2: [lldb/bindings] Change ScriptedThread 
initializer parameters (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112046

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -229,7 +229,8 @@
 
 extern "C" void *LLDBSwigPythonCreateScriptedThread(
 const char *python_class_name, const char *session_dictionary_name,
-const lldb::TargetSP _sp, std::string _string) {
+const lldb::ProcessSP _sp, StructuredDataImpl *args_impl,
+std::string _string) {
   return nullptr;
 }
 
Index: lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
@@ -43,8 +43,8 @@
 
 
 class DummyScriptedThread(ScriptedThread):
-def __init__(self, target):
-super().__init__(target)
+def __init__(self, process, args):
+super().__init__(process, args)
 
 def get_thread_id(self) -> int:
 return 0x19
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
@@ -36,16 +36,20 @@
   if (class_name.empty())
 return {};
 
-  Locker py_lock(_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
- Locker::FreeLock);
-
+  ProcessSP process_sp = exe_ctx.GetProcessSP();
+  StructuredDataImpl *args_impl = nullptr;
+  if (args_sp) {
+args_impl = new StructuredDataImpl();
+args_impl->SetObjectSP(args_sp);
+  }
   std::string error_string;
 
-  TargetSP target_sp = exe_ctx.GetTargetSP();
+  Locker py_lock(_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
+ Locker::FreeLock);
 
   void *ret_val = LLDBSwigPythonCreateScriptedThread(
-  class_name.str().c_str(), m_interpreter.GetDictionaryName(), target_sp,
-  error_string);
+  class_name.str().c_str(), m_interpreter.GetDictionaryName(), process_sp,
+  args_impl, error_string);
 
   if (!ret_val)
 return {};
Index: lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -48,7 +48,8 @@
 
 extern "C" void *LLDBSwigPythonCreateScriptedThread(
 const char *python_class_name, const char *session_dictionary_name,
-const lldb::TargetSP _sp, std::string _string);
+const lldb::ProcessSP _sp, StructuredDataImpl *args_impl,
+std::string _string);
 
 extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void *data);
 extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data);
Index: lldb/examples/python/scripted_process/scripted_process.py
===
--- lldb/examples/python/scripted_process/scripted_process.py
+++ lldb/examples/python/scripted_process/scripted_process.py
@@ -190,18 +190,20 @@
 """
 
 @abstractmethod
-def __init__(self, target):
+def __init__(self, process, args):
 """ Construct a scripted thread.
 
 Args:
-target (lldb.SBTarget): The target launching the scripted process.
+process (lldb.SBProcess): The scripted process owning this thread.
 args (lldb.SBStructuredData): A Dictionary holding arbitrary
-key/value pairs used by the scripted process.
+key/value pairs used by the scripted thread.
 """
 self.target = None
+self.process = None
 self.args = None
-if isinstance(target, lldb.SBTarget) and target.IsValid():
-self.target = target
+if isinstance(process, lldb.SBProcess) and process.IsValid():
+self.process = process
+self.target = process.GetTarget()
 
 

[Lldb-commits] [PATCH] D112107: [lldb] Fix Scripted ProcessLaunchInfo Argument nullptr deref

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
mib marked an inline comment as done.
Closed by commit rGad0f7d3d4a0c: [lldb] Fix Scripted ProcessLaunchInfo Argument 
nullptr deref (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D112107?vs=386005=386184#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112107

Files:
  lldb/include/lldb/Core/StructuredDataImpl.h
  lldb/include/lldb/Utility/StructuredData.h
  lldb/source/API/SBLaunchInfo.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  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
@@ -55,7 +55,7 @@
   StructuredData::GenericSP object_sp =
   scripted_thread_interface->CreatePluginObject(
   class_name->c_str(), exe_ctx,
-  process.m_scripted_process_info.GetDictionarySP());
+  process.m_scripted_process_info.GetArgsSP());
   if (!object_sp || !object_sp->IsValid()) {
 error.SetErrorString("Failed to create valid script object");
 return;
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -25,17 +25,15 @@
   public:
 ScriptedProcessInfo(const ProcessLaunchInfo _info) {
   m_class_name = launch_info.GetScriptedProcessClassName();
-  m_dictionary_sp = launch_info.GetScriptedProcessDictionarySP();
+  m_args_sp = launch_info.GetScriptedProcessDictionarySP();
 }
 
 std::string GetClassName() const { return m_class_name; }
-StructuredData::DictionarySP GetDictionarySP() const {
-  return m_dictionary_sp;
-}
+StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; }
 
   private:
 std::string m_class_name;
-StructuredData::DictionarySP m_dictionary_sp;
+StructuredData::DictionarySP m_args_sp;
   };
 
 public:
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -106,7 +106,7 @@
 
   StructuredData::GenericSP object_sp = GetInterface().CreatePluginObject(
   m_scripted_process_info.GetClassName().c_str(), exe_ctx,
-  m_scripted_process_info.GetDictionarySP());
+  m_scripted_process_info.GetArgsSP());
 
   if (!object_sp || !object_sp->IsValid()) {
 error.SetErrorStringWithFormat("ScriptedProcess::%s () - ERROR: %s",
Index: lldb/source/API/SBLaunchInfo.cpp
===
--- lldb/source/API/SBLaunchInfo.cpp
+++ lldb/source/API/SBLaunchInfo.cpp
@@ -380,16 +380,18 @@
 void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary,
  (lldb::SBStructuredData), dict);
+  if (!dict.IsValid() || !dict.m_impl_up)
+return;
 
-  SBStream stream;
-  SBError error = dict.GetAsJSON(stream);
+  StructuredData::ObjectSP obj_sp = dict.m_impl_up->GetObjectSP();
 
-  if (error.Fail())
+  if (!obj_sp)
 return;
 
-  StructuredData::DictionarySP dict_sp;
-  llvm::json::OStream s(stream.ref().AsRawOstream());
-  dict_sp->Serialize(s);
+  StructuredData::DictionarySP dict_sp =
+  std::make_shared(obj_sp);
+  if (!dict_sp || dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
+return;
 
   m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp);
 }
Index: lldb/include/lldb/Utility/StructuredData.h
===
--- lldb/include/lldb/Utility/StructuredData.h
+++ lldb/include/lldb/Utility/StructuredData.h
@@ -353,6 +353,17 @@
   public:
 Dictionary() : Object(lldb::eStructuredDataTypeDictionary), m_dict() {}
 
+Dictionary(ObjectSP obj_sp)
+: Object(lldb::eStructuredDataTypeDictionary), m_dict() {
+  if (!obj_sp || obj_sp->GetType() != lldb::eStructuredDataTypeDictionary) {
+SetType(lldb::eStructuredDataTypeInvalid);
+return;
+  }
+
+  Dictionary *dict = obj_sp->GetAsDictionary();
+  m_dict = dict->m_dict;
+}
+
 ~Dictionary() override = default;
 
 size_t GetSize() const { return m_dict.size(); }
Index: lldb/include/lldb/Core/StructuredDataImpl.h
===
--- lldb/include/lldb/Core/StructuredDataImpl.h
+++ 

[Lldb-commits] [lldb] 976867b - [lldb/test] Update TestScriptedProcess to use skinny corefiles

2021-11-10 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-11-10T17:43:29+01:00
New Revision: 976867b513abbf72e505506686219efaa7f3520f

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

LOG: [lldb/test] Update TestScriptedProcess to use skinny corefiles

This patch changes the ScriptedProcess test to use a stack-only skinny
corefile as a backing store.

The corefile is saved as a temporary file at the beginning of the test,
and a second target is created for the ScriptedProcess. To do so, we use
the SBAPI from the ScriptedProcess' python script to interact with the
corefile process.

This patch also makes some small adjustments to the other ScriptedProcess
scripts to resolve some inconsistencies and removes the raw memory dump
that was previously checked in.

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

Signed-off-by: Med Ismail Bennani 

Added: 

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Modified: 
lldb/examples/python/scripted_process/my_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Removed: 
lldb/examples/python/scripted_process/main.stack-dump



diff  --git a/lldb/examples/python/scripted_process/main.stack-dump 
b/lldb/examples/python/scripted_process/main.stack-dump
deleted file mode 100644
index 3df66384f4431..0
Binary files a/lldb/examples/python/scripted_process/main.stack-dump and 
/dev/null 
diff er

diff  --git a/lldb/examples/python/scripted_process/my_scripted_process.py 
b/lldb/examples/python/scripted_process/my_scripted_process.py
index 5e7c10b91533d..202ad097d4987 100644
--- a/lldb/examples/python/scripted_process/my_scripted_process.py
+++ b/lldb/examples/python/scripted_process/my_scripted_process.py
@@ -69,7 +69,7 @@ def get_scripted_thread_plugin(self):
 
 
 class MyScriptedThread(ScriptedThread):
-registers = {
+register_ctx = {
 "rax":0x06e4,
 "rbx":0x0001040b6060,
 "rcx":0x0001040b2e00,
@@ -123,7 +123,7 @@ def __init__(idx, cfa, pc, symbol_ctx):
 return self.frame_zero[0:0]
 
 def get_register_context(self) -> str:
-return struct.pack("{}Q".format(len(self.registers)), 
*self.registers.values())
+return struct.pack("{}Q".format(len(self.register_ctx)), 
*self.register_ctx.values())
 
 
 def __lldb_init_module(debugger, dict):

diff  --git a/lldb/examples/python/scripted_process/scripted_process.py 
b/lldb/examples/python/scripted_process/scripted_process.py
index 43ee2d6fffb27..ebb48523805d9 100644
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -37,7 +37,7 @@ def __init__(self, target, args):
 self.args = args
 
 @abstractmethod
-def get_memory_region_containing_address(addr):
+def get_memory_region_containing_address(self, addr):
 """ Get the memory region for the scripted process, containing a
 specific address.
 
@@ -52,7 +52,7 @@ def get_memory_region_containing_address(addr):
 pass
 
 @abstractmethod
-def get_thread_with_id(tid):
+def get_thread_with_id(self, tid):
 """ Get the scripted process thread with a specific ID.
 
 Args:
@@ -66,7 +66,7 @@ def get_thread_with_id(tid):
 pass
 
 @abstractmethod
-def get_registers_for_thread(tid):
+def get_registers_for_thread(self, tid):
 """ Get the register context dictionary for a certain thread of
 the scripted process.
 
@@ -81,7 +81,7 @@ def get_registers_for_thread(tid):
 pass
 
 @abstractmethod
-def read_memory_at_address(addr, size):
+def read_memory_at_address(self, addr, size):
 """ Get a memory buffer from the scripted process at a certain address,
 of a certain size.
 
@@ -211,7 +211,7 @@ def __init__(self, process, args):
 self.state = None
 self.stop_reason = None
 self.register_info = None
-self.register_ctx = []
+self.register_ctx = {}
 self.frames = []
 
 @abstractmethod
@@ -294,7 +294,7 @@ def get_register_info(self):
 if triple:
 arch = triple.split('-')[0]
 if arch == 'x86_64':
-self.register_info['sets'] = ['GPR', 'FPU', 'EXC']
+self.register_info['sets'] = ['General Purpose Registers']
 self.register_info['registers'] = [
 {'name': 'rax', 'bitsize': 64, 'offset': 0, 
'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 0, 'dwarf': 0},
 {'name': 'rbx', 'bitsize': 64, 'offset': 8, 
'encoding': 'uint', 'format': 'hex', 

[Lldb-commits] [lldb] 738621d - [lldb/bindings] Change ScriptedThread initializer parameters

2021-11-10 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-11-10T17:43:28+01:00
New Revision: 738621d047f2c14482509b39f8307967a91e7586

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

LOG: [lldb/bindings] Change ScriptedThread initializer parameters

This patch changes the `ScriptedThread` initializer in couple of ways:
- It replaces the `SBTarget` parameter by a `SBProcess` (pointing to the
  `ScriptedProcess` that "owns" the `ScriptedThread`).
- It adds a reference to the `ScriptedProcessInfo` Dictionary, to pass
  arbitrary user-input to the `ScriptedThread`.

This patch also fixes the SWIG bindings methods that call the
`ScriptedProcess` and `ScriptedThread` initializers by passing all the
arguments to the appropriate `PythonCallable` object.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/python/python-wrapper.swig
lldb/examples/python/scripted_process/my_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 




diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 5a950e259e993..698d7d12cebca 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -322,16 +322,10 @@ LLDBSwigPythonCreateScriptedProcess
 
 PythonObject result = {};
 if (arg_info.get().max_positional_args == 2) {
-if (args_impl != nullptr) {
-   error_string.assign("args passed, but __init__ does not take an 
args dictionary");
-   Py_RETURN_NONE;
-}
-result = pfunc(target_arg, dict);
-} else if (arg_info.get().max_positional_args >= 3) {
 PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new 
lldb::SBStructuredData(args_impl)));
-result = pfunc(target_arg, args_arg, dict);
+result = pfunc(target_arg, args_arg);
 } else {
-error_string.assign("wrong number of arguments in __init__, should be 
2 or 3 (not including self)");
+error_string.assign("wrong number of arguments in __init__, should be 
2 (not including self)");
 Py_RETURN_NONE;
 }
 
@@ -345,7 +339,8 @@ LLDBSwigPythonCreateScriptedThread
 (
 const char *python_class_name,
 const char *session_dictionary_name,
-const lldb::TargetSP& target_sp,
+const lldb::ProcessSP& process_sp,
+lldb_private::StructuredDataImpl *args_impl,
 std::string _string
 )
 {
@@ -363,12 +358,12 @@ LLDBSwigPythonCreateScriptedThread
 return nullptr;
 }
 
-// I do not want the SBTarget to be deallocated when going out of scope
+// I do not want the SBProcess to be deallocated when going out of scope
 // because python has ownership of it and will manage memory for this
 // object by itself
-PythonObject target_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new 
lldb::SBTarget(target_sp)));
+PythonObject process_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new 
lldb::SBProcess(process_sp)));
 
-if (!target_arg.IsAllocated())
+if (!process_arg.IsAllocated())
 Py_RETURN_NONE;
 
 llvm::Expected arg_info = pfunc.GetArgInfo();
@@ -385,10 +380,11 @@ LLDBSwigPythonCreateScriptedThread
 }
 
 PythonObject result = {};
-if (arg_info.get().max_positional_args == 1) {
-result = pfunc(target_arg);
+if (arg_info.get().max_positional_args == 2) {
+PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new 
lldb::SBStructuredData(args_impl)));
+result = pfunc(process_arg, args_arg);
 } else {
-error_string.assign("wrong number of arguments in __init__, should be 
2 or 3 (not including self)");
+error_string.assign("wrong number of arguments in __init__, should be 
2 (not including self)");
 Py_RETURN_NONE;
 }
 

diff  --git a/lldb/examples/python/scripted_process/my_scripted_process.py 
b/lldb/examples/python/scripted_process/my_scripted_process.py
index 224b772845a7f..5e7c10b91533d 100644
--- a/lldb/examples/python/scripted_process/my_scripted_process.py
+++ b/lldb/examples/python/scripted_process/my_scripted_process.py
@@ -93,8 +93,8 @@ class MyScriptedThread(ScriptedThread):
 "gs":0x,
 }
 
-def __init__(self, target):
-super().__init__(target)
+def __init__(self, process, args):
+super().__init__(process, args)
 
 def get_thread_id(self) -> int:
 return 0x19

diff  --git 

[Lldb-commits] [lldb] ad0f7d3 - [lldb] Fix Scripted ProcessLaunchInfo Argument nullptr deref

2021-11-10 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-11-10T16:43:19Z
New Revision: ad0f7d3d4a0c7ceaa5878494b2ad673287ef6a76

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

LOG: [lldb] Fix Scripted ProcessLaunchInfo Argument nullptr deref

This patch adds a new `StructuredData::Dictionary` constructor that
takes a `StructuredData::ObjectSP` as an argument. This is used to pass
the opaque_ptr from the `SBStructuredData` used to initialize a
ScriptedProecss, to the `ProcessLaunchInfo` class.

This also updates `SBLaunchInfo::SetScriptedProcessDictionary` to
reflect the formentionned changes which solves the nullptr deref.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Core/StructuredDataImpl.h
lldb/include/lldb/Utility/StructuredData.h
lldb/source/API/SBLaunchInfo.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/StructuredDataImpl.h 
b/lldb/include/lldb/Core/StructuredDataImpl.h
index 929ce21fb2f92..d6f64451e5c22 100644
--- a/lldb/include/lldb/Core/StructuredDataImpl.h
+++ b/lldb/include/lldb/Core/StructuredDataImpl.h
@@ -152,6 +152,8 @@ class StructuredDataImpl {
 return (::snprintf(dst, dst_len, "%s", result.data()));
   }
 
+  StructuredData::ObjectSP GetObjectSP() const { return m_data_sp; }
+
 private:
   lldb::StructuredDataPluginWP m_plugin_wp;
   StructuredData::ObjectSP m_data_sp;

diff  --git a/lldb/include/lldb/Utility/StructuredData.h 
b/lldb/include/lldb/Utility/StructuredData.h
index 4d03af18e527b..c1d136db1c2ef 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -353,6 +353,17 @@ class StructuredData {
   public:
 Dictionary() : Object(lldb::eStructuredDataTypeDictionary), m_dict() {}
 
+Dictionary(ObjectSP obj_sp)
+: Object(lldb::eStructuredDataTypeDictionary), m_dict() {
+  if (!obj_sp || obj_sp->GetType() != lldb::eStructuredDataTypeDictionary) 
{
+SetType(lldb::eStructuredDataTypeInvalid);
+return;
+  }
+
+  Dictionary *dict = obj_sp->GetAsDictionary();
+  m_dict = dict->m_dict;
+}
+
 ~Dictionary() override = default;
 
 size_t GetSize() const { return m_dict.size(); }

diff  --git a/lldb/source/API/SBLaunchInfo.cpp 
b/lldb/source/API/SBLaunchInfo.cpp
index 70cd1c6ecf744..0735e62a16cfd 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -380,16 +380,18 @@ lldb::SBStructuredData 
SBLaunchInfo::GetScriptedProcessDictionary() const {
 void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary,
  (lldb::SBStructuredData), dict);
+  if (!dict.IsValid() || !dict.m_impl_up)
+return;
 
-  SBStream stream;
-  SBError error = dict.GetAsJSON(stream);
+  StructuredData::ObjectSP obj_sp = dict.m_impl_up->GetObjectSP();
 
-  if (error.Fail())
+  if (!obj_sp)
 return;
 
-  StructuredData::DictionarySP dict_sp;
-  llvm::json::OStream s(stream.ref().AsRawOstream());
-  dict_sp->Serialize(s);
+  StructuredData::DictionarySP dict_sp =
+  std::make_shared(obj_sp);
+  if (!dict_sp || dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
+return;
 
   m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp);
 }

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 63c68c2a20236..23659bdb8a47a 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -106,7 +106,7 @@ ScriptedProcess::ScriptedProcess(
 
   StructuredData::GenericSP object_sp = GetInterface().CreatePluginObject(
   m_scripted_process_info.GetClassName().c_str(), exe_ctx,
-  m_scripted_process_info.GetDictionarySP());
+  m_scripted_process_info.GetArgsSP());
 
   if (!object_sp || !object_sp->IsValid()) {
 error.SetErrorStringWithFormat("ScriptedProcess::%s () - ERROR: %s",

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index fd4a94b9b6adb..3f8d53908339b 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -25,17 +25,15 @@ class ScriptedProcess : public Process {
   public:
 ScriptedProcessInfo(const ProcessLaunchInfo _info) {
   m_class_name = launch_info.GetScriptedProcessClassName();
-  m_dictionary_sp = 

[Lldb-commits] [PATCH] D112047: [lldb/test] Update TestScriptedProcess to use skinny corefiles

2021-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Some of the formatting in the Python tests seems a little off (can you run it 
through something like yapf ?). Other than that 
this LGTM with the inline comments addressed.




Comment at: 
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py:101
 @skipUnlessDarwin
+@skipIf(archs=no_match(['x86_64']))
 def test_launch_scripted_process_stack_frames(self):

You'll also need `skipIfOutOfTreeDebugserver` because skinny corefiles require 
debugserver support.



Comment at: 
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py:119
+scripted_process_example_relpath = 'stack_core_scripted_process.py'
+os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
 self.runCmd("command script import " + 
os.path.join(self.getSourceDir(),

You'll want to unset this after your test so it doesn't affect another test:

```
def cleanup():
del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"]
self.addTearDownHook(cleanup)
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112047

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


[Lldb-commits] [PATCH] D112047: [lldb/test] Update TestScriptedProcess to use skinny corefiles

2021-11-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 386176.
mib added a comment.

Move `stack_core_scripted_process.py` from `examples` to `test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112047

Files:
  lldb/examples/python/scripted_process/main.stack-dump
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  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
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -0,0 +1,139 @@
+import os,struct,signal
+
+from typing import Any, Dict
+
+import lldb
+from lldb.plugins.scripted_process import ScriptedProcess
+from lldb.plugins.scripted_process import ScriptedThread
+
+class StackCoreScriptedProcess(ScriptedProcess):
+def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
+super().__init__(target, args)
+
+self.backing_target_idx = args.GetValueForKey("backing_target_idx")
+
+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 = target.GetDebugger().GetTargetAtIndex(idx)
+self.corefile_process = self.corefile_target.GetProcess()
+
+def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
+mem_region = lldb.SBMemoryRegionInfo()
+error = self.corefile_process.GetMemoryRegionInfo(addr, mem_region)
+if error.Fail():
+return None
+return mem_region
+
+def get_thread_with_id(self, tid: int):
+return {}
+
+def get_registers_for_thread(self, tid: int):
+return {}
+
+def read_memory_at_address(self, addr: int, size: int) -> lldb.SBData:
+data = lldb.SBData()
+error = lldb.SBError()
+bytes_read = self.corefile_process.ReadMemory(addr, size, error)
+
+if error.Fail():
+return data
+
+data.SetData(error, bytes_read, self.corefile_target.GetByteOrder(),
+self.corefile_target.GetAddressByteSize())
+
+return data
+
+def get_loaded_images(self):
+# TODO: Iterate over corefile_target modules and build a data structure
+# from it.
+return self.loaded_images
+
+def get_process_id(self) -> int:
+return 42
+
+def should_stop(self) -> bool:
+return True
+
+def is_alive(self) -> bool:
+return True
+
+def get_scripted_thread_plugin(self):
+return StackCoreScriptedThread.__module__ + "." + StackCoreScriptedThread.__name__
+
+
+class StackCoreScriptedThread(ScriptedThread):
+def __init__(self, process, args):
+super().__init__(process, args)
+self.backing_target_idx = args.GetValueForKey("backing_target_idx")
+
+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_process = self.corefile_target.GetProcess()
+
+def get_thread_id(self) -> int:
+return 0x19
+
+def get_name(self) -> str:
+return StackCoreScriptedThread.__name__ + ".thread-1"
+
+def get_stop_reason(self) -> Dict[str, Any]:
+return { "type": lldb.eStopReasonSignal, "data": {
+"signal": signal.SIGINT
+} }
+
+def get_stackframes(self):
+class ScriptedStackFrame:
+def __init__(idx, cfa, pc, symbol_ctx):
+self.idx = idx
+self.cfa = cfa
+self.pc = pc
+self.symbol_ctx = symbol_ctx
+
+
+symbol_ctx = lldb.SBSymbolContext()
+frame_zero = ScriptedStackFrame(0, 0x42424242, 0x500, symbol_ctx)
+self.frames.append(frame_zero)
+
+return self.frame_zero[0:0]
+
+def get_register_context(self) -> str:
+thread = 

[Lldb-commits] [PATCH] D111409: proposed support for Java interface to Scripting Bridge

2021-11-10 Thread David Millar via Phabricator via lldb-commits
d-millar updated this revision to Diff 386169.
d-millar added a comment.

OK, well, took my some time but I have made an attempt to address the three 
areas described by Mr. Ingham:

//Support for a scripting language in lldb has three distinct pieces.

1. Making the SB API's available to the scripting languages
2. Adding all the callbacks so the scripting language can be used for 
breakpoint callbacks, data formatters, etc.
3. Adding a REPL for that language to the "script" command

//
With regard to #3, I had hoped JShell would work as a viable REPL.  
Unfortunately, it does not appear to support System.loadLibrary, which makes it 
somewhat useless in the current context.  Because I cannot load the JNI 
libraries, I would not have access to the classes in the Scripting Bridge, 
which sort of defeats the purpose.

As an alternative, I have implemented a quasi-REPL, which allows you to compose 
classes, compile, and run them.  The "script" command behaves for the most part 
like it would for Python or Lua, but have a set of /-prefixed commands, 
described in the initial message, that enable the extra functionality.  The 
JShell interface is also include via those commands - perhaps loadLibrary will 
be supported in the future.

Anyway, let me know what you think and what else you might need for possible 
inclusion of this patch.

Best,
Dave


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D111409

Files:
  lldb/CMakeLists.txt
  lldb/bindings/CMakeLists.txt
  lldb/bindings/java/CMakeLists.txt
  lldb/bindings/java/SWIG/LldbScriptInterpreter.java
  lldb/bindings/java/java-swigsafecast.swig
  lldb/bindings/java/java-typemaps.swig
  lldb/bindings/java/java-wrapper.swig
  lldb/bindings/java/java.swig
  lldb/cmake/modules/FindJavaAndSwig.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/docs/resources/build.rst
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/CMakeLists.txt
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/liblldb-private.exports
  lldb/source/API/liblldb.exports
  lldb/source/Commands/CommandObjectBreakpointCommand.cpp
  lldb/source/Commands/CommandObjectScript.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Interpreter/OptionArgParser.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Java/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Java/Java.cpp
  lldb/source/Plugins/ScriptInterpreter/Java/Java.h
  lldb/source/Plugins/ScriptInterpreter/Java/ScriptInterpreterJava.cpp
  lldb/source/Plugins/ScriptInterpreter/Java/ScriptInterpreterJava.h
  lldb/test/CMakeLists.txt
  lldb/test/Shell/ScriptInterpreter/Java/Inputs/independent_state.in
  lldb/test/Shell/ScriptInterpreter/Java/Inputs/nested_sessions.in
  lldb/test/Shell/ScriptInterpreter/Java/Inputs/nested_sessions_2.in
  lldb/test/Shell/ScriptInterpreter/Java/Inputs/testmodule.java
  lldb/test/Shell/ScriptInterpreter/Java/bindings.test
  lldb/test/Shell/ScriptInterpreter/Java/breakpoint_callback.test
  lldb/test/Shell/ScriptInterpreter/Java/breakpoint_function_callback.test
  lldb/test/Shell/ScriptInterpreter/Java/breakpoint_oneline_callback.test
  lldb/test/Shell/ScriptInterpreter/Java/command_script_import.test
  lldb/test/Shell/ScriptInterpreter/Java/convenience_variables.test
  lldb/test/Shell/ScriptInterpreter/Java/fail_breakpoint_oneline.test
  lldb/test/Shell/ScriptInterpreter/Java/independent_state.test
  lldb/test/Shell/ScriptInterpreter/Java/io.test
  lldb/test/Shell/ScriptInterpreter/Java/java-python.test
  lldb/test/Shell/ScriptInterpreter/Java/java.test
  lldb/test/Shell/ScriptInterpreter/Java/lit.local.cfg
  lldb/test/Shell/ScriptInterpreter/Java/nested_sessions.test
  lldb/test/Shell/ScriptInterpreter/Java/partial_statements.test
  lldb/test/Shell/ScriptInterpreter/Java/persistent_state.test
  lldb/test/Shell/ScriptInterpreter/Java/print.test
  lldb/test/Shell/ScriptInterpreter/Java/quit.test
  lldb/test/Shell/ScriptInterpreter/Java/watchpoint_callback.test
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in
  lldb/test/Unit/lit.cfg.py
  lldb/unittests/ScriptInterpreter/CMakeLists.txt
  lldb/unittests/ScriptInterpreter/Java/CMakeLists.txt
  lldb/unittests/ScriptInterpreter/Java/JavaTests.cpp
  lldb/unittests/ScriptInterpreter/Java/ScriptInterpreterTests.cpp

Index: lldb/unittests/ScriptInterpreter/Java/ScriptInterpreterTests.cpp
===
--- /dev/null
+++ lldb/unittests/ScriptInterpreter/Java/ScriptInterpreterTests.cpp
@@ -0,0 +1,59 @@
+//===-- JavaTests.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// 

[Lldb-commits] [PATCH] D112973: [lldb] make it easier to find LLDB's python

2021-11-10 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 386170.
lawrence_danna added a comment.

changed internal apis to use StructuredData instead of char*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112973

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/bindings/python/CMakeLists.txt
  lldb/bindings/python/lldb-python
  lldb/docs/man/lldb.rst
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBHostOS.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/test/API/functionalities/paths/TestPaths.py
  lldb/test/Shell/Driver/TestHelp.test
  lldb/tools/driver/Driver.cpp
  lldb/tools/driver/Driver.h
  lldb/tools/driver/Options.td

Index: lldb/tools/driver/Options.td
===
--- lldb/tools/driver/Options.td
+++ lldb/tools/driver/Options.td
@@ -48,6 +48,10 @@
   HelpText<"Alias for --python-path">,
   Group;
 
+def print_script_interpreter_info: F<"print-script-interpreter-info">,
+  HelpText<"Prints out a json dictionary with information about the scripting language interpreter.">,
+  Group;
+
 def script_language: Separate<["--", "-"], "script-language">,
   MetaVarName<"">,
   HelpText<"Tells the debugger to use the specified scripting language for user-defined scripts.">,
Index: lldb/tools/driver/Driver.h
===
--- lldb/tools/driver/Driver.h
+++ lldb/tools/driver/Driver.h
@@ -79,6 +79,7 @@
 bool m_source_quietly = false;
 bool m_print_version = false;
 bool m_print_python_path = false;
+bool m_print_script_interpreter_info = false;
 bool m_wait_for = false;
 bool m_repl = false;
 bool m_batch = false;
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -18,6 +18,7 @@
 #include "lldb/API/SBReproducer.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Format.h"
@@ -201,6 +202,9 @@
   if (args.hasArg(OPT_python_path)) {
 m_option_data.m_print_python_path = true;
   }
+  if (args.hasArg(OPT_print_script_interpreter_info)) {
+m_option_data.m_print_script_interpreter_info = true;
+  }
 
   if (args.hasArg(OPT_batch)) {
 m_option_data.m_batch = true;
@@ -398,6 +402,22 @@
 return error;
   }
 
+  if (m_option_data.m_print_script_interpreter_info) {
+SBStructuredData info =
+m_debugger.GetScriptInterpreterInfo(m_debugger.GetScriptLanguage());
+if (!info) {
+  error.SetErrorString("no script interpreter.");
+} else {
+  SBStream stream;
+  error = info.GetAsJSON(stream);
+  if (error.Success()) {
+llvm::outs() << stream.GetData() << '\n';
+  }
+}
+exiting = true;
+return error;
+  }
+
   return error;
 }
 
Index: lldb/test/Shell/Driver/TestHelp.test
===
--- lldb/test/Shell/Driver/TestHelp.test
+++ lldb/test/Shell/Driver/TestHelp.test
@@ -62,6 +62,7 @@
 
 CHECK: SCRIPTING
 CHECK: -l
+CHECK: --print-script-interpreter-info
 CHECK: --python-path
 CHECK: -P
 CHECK: --script-language
Index: lldb/test/API/functionalities/paths/TestPaths.py
===
--- lldb/test/API/functionalities/paths/TestPaths.py
+++ lldb/test/API/functionalities/paths/TestPaths.py
@@ -5,6 +5,8 @@
 
 import lldb
 import os
+import sys
+import json
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
@@ -42,6 +44,18 @@
 self.assertTrue(any([os.path.exists(os.path.join(shlib_dir, f)) for f in
 filenames]), "shlib_dir = " + shlib_dir)
 
+@no_debug_info_test
+def test_interpreter_info(self):
+info_sd = self.dbg.GetScriptInterpreterInfo(self.dbg.GetScriptingLanguage("python"))
+assert info_sd.IsValid()
+stream = lldb.SBStream()
+assert info_sd.GetAsJSON(stream).Success()
+info = json.loads(stream.GetData())
+prefix = info['prefix']
+self.assertEqual(os.path.realpath(sys.prefix), os.path.realpath(prefix))
+self.assertEqual(
+os.path.realpath(os.path.join(info['lldb-pythonpath'], 'lldb')),
+

[Lldb-commits] [lldb] ff7ce0a - [lldb] DeConstStringify the Property class

2021-11-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-11-10T15:07:30+01:00
New Revision: ff7ce0af04ae8ef034ea18c8116331c843f36c40

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

LOG: [lldb] DeConstStringify the Property class

Most of the interfaces were converted already, this just converts the
internal implementation.

Added: 


Modified: 
lldb/include/lldb/Interpreter/Property.h
lldb/source/Interpreter/OptionValueProperties.cpp
lldb/source/Interpreter/Property.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/Property.h 
b/lldb/include/lldb/Interpreter/Property.h
index 97ec7ca1d4afa..09f09358e8af8 100644
--- a/lldb/include/lldb/Interpreter/Property.h
+++ b/lldb/include/lldb/Interpreter/Property.h
@@ -10,7 +10,6 @@
 #define LLDB_INTERPRETER_PROPERTY_H
 
 #include "lldb/Interpreter/OptionValue.h"
-#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Flags.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-private-types.h"
@@ -37,13 +36,11 @@ class Property {
 public:
   Property(const PropertyDefinition );
 
-  Property(ConstString name, ConstString desc, bool is_global,
+  Property(llvm::StringRef name, llvm::StringRef desc, bool is_global,
const lldb::OptionValueSP _sp);
 
-  llvm::StringRef GetName() const { return m_name.GetStringRef(); }
-  llvm::StringRef GetDescription() const {
-return m_description.GetStringRef();
-  }
+  llvm::StringRef GetName() const { return m_name; }
+  llvm::StringRef GetDescription() const { return m_description; }
 
   const lldb::OptionValueSP () const { return m_value_sp; }
 
@@ -67,8 +64,8 @@ class Property {
   void SetValueChangedCallback(std::function callback);
 
 protected:
-  ConstString m_name;
-  ConstString m_description;
+  std::string m_name;
+  std::string m_description;
   lldb::OptionValueSP m_value_sp;
   bool m_is_global;
 };

diff  --git a/lldb/source/Interpreter/OptionValueProperties.cpp 
b/lldb/source/Interpreter/OptionValueProperties.cpp
index ae073798ca12e..1a8f2f0ab1809 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -48,7 +48,8 @@ void OptionValueProperties::AppendProperty(ConstString name,
ConstString desc,
bool is_global,
const OptionValueSP _sp) {
-  Property property(name, desc, is_global, value_sp);
+  Property property(name.GetStringRef(), desc.GetStringRef(), is_global,
+value_sp);
   m_name_to_index.Append(name, m_properties.size());
   m_properties.push_back(property);
   value_sp->SetParent(shared_from_this());

diff  --git a/lldb/source/Interpreter/Property.cpp 
b/lldb/source/Interpreter/Property.cpp
index 410562f274f18..fe3a8a31394b5 100644
--- a/lldb/source/Interpreter/Property.cpp
+++ b/lldb/source/Interpreter/Property.cpp
@@ -227,13 +227,13 @@ Property::Property(const PropertyDefinition )
   }
 }
 
-Property::Property(ConstString name, ConstString desc,
-   bool is_global, const lldb::OptionValueSP _sp)
+Property::Property(llvm::StringRef name, llvm::StringRef desc, bool is_global,
+   const lldb::OptionValueSP _sp)
 : m_name(name), m_description(desc), m_value_sp(value_sp),
   m_is_global(is_global) {}
 
 bool Property::DumpQualifiedName(Stream ) const {
-  if (m_name) {
+  if (!m_name.empty()) {
 if (m_value_sp->DumpQualifiedName(strm))
   strm.PutChar('.');
 strm << m_name;
@@ -251,7 +251,7 @@ void Property::Dump(const ExecutionContext *exe_ctx, Stream 
,
 if (dump_cmd && !transparent)
   strm << "settings set -f ";
 if (dump_desc || !transparent) {
-  if ((dump_mask & OptionValue::eDumpOptionName) && m_name) {
+  if ((dump_mask & OptionValue::eDumpOptionName) && !m_name.empty()) {
 DumpQualifiedName(strm);
 if (dump_mask & ~OptionValue::eDumpOptionName)
   strm.PutChar(' ');
@@ -295,8 +295,8 @@ void Property::DumpDescription(CommandInterpreter 
, Stream ,
   interpreter.OutputFormattedHelpText(strm, qualified_name.GetString(),
   "--", desc, output_width);
 } else {
-  interpreter.OutputFormattedHelpText(strm, m_name.GetStringRef(), "--",
-  desc, output_width);
+  interpreter.OutputFormattedHelpText(strm, m_name, "--", desc,
+  output_width);
 }
   }
 }



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


[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

In D112069#3120951 , @DavidSpickett 
wrote:

> - Set locations for all general purpose registers
> - Set register type to DWARF due to that
> - Add a new test that sets known register values and compares them between 
> signal catch and handler
> - Remove changes to handle abort test (though I could do those as a separate 
> thing later)
>
> One thing remains, the sigcontext can include floating point and SVE
> registers. We'd need to read some memory to determine if it does:
> https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/sigcontext.h#L39
>
> Which I can do by passing the target and generating the plan based on
> what's present.
>
> For now let me know if the test case makes sense. Maybe this is ok
> to go in as is and I can follow up with the other registers?

Yes, this is definitely fine. Thanks for taking your time to do that.

Dynamically generating unwind plans based on the contents of memory kinda goes 
against the concept of unwind plans, which were meant to be static (and 
cacheable) descriptions of how to unwind from a given point (PC) in a program. 
I guess the most "pure" solution would be to encode this logic into the dwarf 
expressions for the relevant registers. I think this should be doable (dwarf 
expressions being turing-complete and all), but the resulting expressions would 
probably be horrendous.

Overall, I'm not too worried about not being able to recover non-gpr registers 
so (unless you really want to work on this) I think that can stay 
unimplemented. (I'd also be fine with not recovering gpr registers either, 
though it's obviously better if they are -- the reason this came up was because 
I was looking at ways to simplify the eRegisterKind business).




Comment at: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp:322
+
+  unwind_plan_sp = std::make_shared(eRegisterKindGeneric);
+  unwind_plan_sp->AppendRow(row);

Change to `eRegisterKindDWARF` and remove the `SetRegisterKind` call below.



Comment at: lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py:82-83
+
+# Save the backtrace frames to compare to the handler backtrace later.
+signal_frames = [make_frame_info(f) for f in 
thread.get_thread_frames()]
+

I don't think this is bad, but you could just hardcode the expectations into 
the python file. Then you could skip this step and continue straight to the 
final breakpoint.



Comment at: lldb/test/API/linux/aarch64/unwind_signal/main.c:23
+  SETREG("24") SETREG("25") SETREG("26") SETREG("27")
+  SETREG("28") SETREG("29") SETREG("30") /* 31 is xzr/sp */
+  /* clang-format on */

DavidSpickett wrote:
> In my testing the kernel didn't go out of its way to change all the register 
> values but it always changed a few so the test fails consistently if the 
> unwind plan doesn't set the locations.
One could also have a similar block (but with different values) in the signal 
handler, which would guarantee that all registers are being read from the stack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

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


[Lldb-commits] [PATCH] D113449: Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"

2021-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I actually didn't see that the patch deleted the TestCppReferenceToOuterClass 
test. Could you just add a `@skipIf # Crashes` or so above its `def test...` 
method? The test itself is still valid user code that we shouldn't crash on.

I left some nits and the test source probably needs to be made a bit more 
expressive in terms of what's its trying to test, but this can all be done 
later. Let's just land this to get the regression fixed.




Comment at: lldb/test/API/commands/expression/pr52257/TestExprCrash.py:17
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.expect("expr b", substrs=["tag_set_ = nullptr"])

nit: `self.createTestTarget()` (which generates useful error messages on 
failure)



Comment at: lldb/test/API/commands/expression/pr52257/TestExprCrash.py:18
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.expect("expr b", substrs=["tag_set_ = nullptr"])

nit: `self.expect_expr("b", result_type="B", 
result_children=[ValueCheck(name="tag_set_")])`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113449

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


[Lldb-commits] [PATCH] D113449: Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"

2021-11-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 386114.
rupprecht added a comment.

- Switch crash repro from shell -> api test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113449

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/test/API/commands/expression/pr52257/Makefile
  lldb/test/API/commands/expression/pr52257/TestExprCrash.py
  lldb/test/API/commands/expression/pr52257/main.cpp
  lldb/test/API/lang/cpp/reference-to-outer-type/Makefile
  lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
  lldb/test/API/lang/cpp/reference-to-outer-type/main.cpp

Index: lldb/test/API/lang/cpp/reference-to-outer-type/main.cpp
===
--- lldb/test/API/lang/cpp/reference-to-outer-type/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-struct Outer {
-  typedef int HookToOuter;
-  // When importing this type, we have to import all of it before adding it
-  // via the FieldDecl to 'Outer'. If we don't do this, then Clang will
-  // while adding 'NestedClassMember' ask for the full type of 'NestedClass'
-  // which then will start pulling in the 'RefToOuter' member. That member
-  // will import the typedef above and add it to 'Outer'. And adding a
-  // Decl to a DeclContext that is currently already in the process of adding
-  // another Decl will cause an inconsistent lookup.
-  struct NestedClass {
-HookToOuter RefToOuter;
-int SomeMember;
-  } NestedClassMember;
-};
-
-// We query the members of base classes of a type by doing a lookup via Clang.
-// As this tests is trying to find a borked lookup, we need a base class here
-// to make our 'GetChildMemberWithName' use the Clang lookup.
-struct In : Outer {};
-
-In test_var;
-
-int main() { return test_var.NestedClassMember.SomeMember; }
Index: lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
===
--- lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class TestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def test(self):
-self.build()
-self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
-test_var = self.expect_expr("test_var", result_type="In")
-nested_member = test_var.GetChildMemberWithName('NestedClassMember')
-self.assertEqual("Outer::NestedClass",
- nested_member.GetType().GetName())
Index: lldb/test/API/commands/expression/pr52257/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/main.cpp
@@ -0,0 +1,12 @@
+template  struct pair {};
+struct A {
+  using iterator = pair;
+  pair a_[];
+};
+struct B {
+  using iterator = A::iterator;
+  iterator begin();
+  A *tag_set_;
+};
+B b;
+int main() {};
\ No newline at end of file
Index: lldb/test/API/commands/expression/pr52257/TestExprCrash.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/pr52257/TestExprCrash.py
@@ -0,0 +1,18 @@
+"""
+Verify that LLDB doesn't crash during expression evaluation.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprCrashTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_pr52257(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.expect("expr b", substrs=["tag_set_ = nullptr"])
Index: lldb/test/API/lang/cpp/reference-to-outer-type/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/reference-to-outer-type/Makefile
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -479,7 +479,10 @@
decl->getDeclKindName(), ast_dump);
   }
 
-  CopyDecl(decl);
+  Decl *copied_decl = CopyDecl(decl);
+
+  if (!copied_decl)
+continue;
 
   // FIXME: We should add the copied decl to the 'decls' list. This would
   // add the copied Decl into the DeclContext and make sure that we
@@ -489,6 +492,12 @@
   // lookup issues later on.
   // We can't just add them for now as the ASTImporter already added the
   // decl into the DeclContext 

[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-11-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/test/API/linux/aarch64/unwind_signal/main.c:23
+  SETREG("24") SETREG("25") SETREG("26") SETREG("27")
+  SETREG("28") SETREG("29") SETREG("30") /* 31 is xzr/sp */
+  /* clang-format on */

In my testing the kernel didn't go out of its way to change all the register 
values but it always changed a few so the test fails consistently if the unwind 
plan doesn't set the locations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

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


[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-11-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

I'll at least make the floating point/SVE changes children of this review since 
it'll add some complexity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

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


[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-11-10 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 386108.
DavidSpickett added a comment.

- Set locations for all general purpose registers
- Set register type to DWARF due to that
- Add a new test that sets known register values and compares them between 
signal catch and handler
- Remove changes to handle abort test (though I could do those as a separate 
thing later)

One thing remains, the sigcontext can include floating point and SVE
registers. We'd need to read some memory to determine if it does:
https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/sigcontext.h#L39

Which I can do by passing the target and generating the plan based on
what's present.

For now let me know if the test case makes sense. Maybe this is ok
to go in as is and I can follow up with the other registers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
  lldb/test/API/linux/aarch64/unwind_signal/Makefile
  lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
  lldb/test/API/linux/aarch64/unwind_signal/main.c

Index: lldb/test/API/linux/aarch64/unwind_signal/main.c
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/unwind_signal/main.c
@@ -0,0 +1,41 @@
+#include 
+#include 
+#include 
+
+void handler(int sig) {
+  printf("Set a breakpoint here.\n");
+  exit(0);
+}
+
+static void sigill() {
+  // Set all general registers to known values to check
+  // that the signal unwind plan sets their locations correctly.
+#define SETREG(N) "mov x" N ", #" N "\n\t"
+  asm(
+  /* clang-format off */
+  SETREG("0")  SETREG("1")  SETREG("2")  SETREG("3")
+  SETREG("4")  SETREG("5")  SETREG("6")  SETREG("7")
+  SETREG("8")  SETREG("9")  SETREG("10") SETREG("11")
+  SETREG("12") SETREG("13") SETREG("14") SETREG("15")
+  SETREG("16") SETREG("17") SETREG("18") SETREG("19")
+  SETREG("20") SETREG("21") SETREG("22") SETREG("23")
+  SETREG("24") SETREG("25") SETREG("26") SETREG("27")
+  SETREG("28") SETREG("29") SETREG("30") /* 31 is xzr/sp */
+  /* clang-format on */
+  ".inst   0x\n\t" // udf #0 (old binutils don't support do udf)
+  ::
+  : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10",
+"x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19",
+"x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28",
+"x29", "x30");
+}
+
+int main() {
+  if (signal(SIGILL, handler) == SIG_ERR) {
+perror("signal");
+return 1;
+  }
+
+  sigill();
+  return 2;
+}
Index: lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
@@ -0,0 +1,115 @@
+"""Test that we can unwind out of a signal handler.
+   Which for AArch64 Linux requires a specific unwind plan."""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from collections import namedtuple
+
+
+# Since frames internally point to ExecutionContextRef which itself points
+# to something else, we can't make a deep copy of them from Python.
+# Instead save what we care about for comparison purposes.
+# Ignoring the frame ID because what is frame 0 in the first catch will
+# be frame 2 in the handler backtrace.
+class FrameInfo(namedtuple('FrameInfo', ['function_name', 'sp', 'gp_regs'])):
+# So assert failures are more readable
+def __repr__(self):
+reg_lines = []
+for k, v in self.gp_regs.items():
+if v is None:
+  value = "{}".format(v)
+else:
+  value = "0x{:x}".format(v)
+
+reg_lines.append("{}: {}".format(k, value))
+
+return "Fn: {} SP: 0x{:x}\n{}".format(self.function_name,
+  self.sp,
+  "\n".join(reg_lines))
+
+
+def make_frame_info(frame):
+gp_regs = frame.GetRegisters().GetValueAtIndex(0)
+reg_values = {}
+err = lldb.SBError()
+for i in range(0, 31):
+name = 'x' + str(i)
+# This will fail if we have no location information
+value = gp_regs.GetChildMemberWithName(name).GetValueAsUnsigned(err)
+reg_values[name] = value if err.Success() else None
+
+return FrameInfo(frame.GetDisplayFunctionName(), frame.GetSP(), reg_values)
+
+
+class UnwindSignalTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+

[Lldb-commits] [lldb] e786144 - [lldb] [test] Skip new signal tests on Windows

2021-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-11-10T11:31:21+01:00
New Revision: e7861449ea25ccad023054b42eba80dc340a5c83

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

LOG: [lldb] [test] Skip new signal tests on Windows

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 1db3717637df..96544f158fe7 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -434,6 +434,7 @@ def cont(self):
 self.assertEqual(process.threads[0].GetStopDescription(100),
  'signal SIGBUS')
 
+@skipIfWindows
 def test_signal_lldb_old(self):
 class MyResponder(MockGDBServerResponder):
 def qSupported(self, client_supported):
@@ -461,6 +462,7 @@ def cont(self):
 self.assertEqual(process.threads[0].GetStopDescription(100),
  'signal SIGUSR1')
 
+@skipIfWindows
 def test_signal_lldb(self):
 class MyResponder(MockGDBServerResponder):
 def qSupported(self, client_supported):



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


[Lldb-commits] [PATCH] D113487: [lldb] Refactor Platform::ResolveExecutable

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks, Greg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113487

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


[Lldb-commits] [PATCH] D113330: [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in breakpad.

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

In D113330#3119254 , @zequanwu wrote:

> Use empty callsite_file or name if index is out of range.

It'd be nice if you could also extend the test case to cover this scenario.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113330

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


[Lldb-commits] [PATCH] D113163: [LLDB][Breakpad] Create a function for each compilation unit.

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp:337
+  std::lock_guard guard(GetModuleMutex());
+  if (!(name_type_mask & eFunctionNameTypeMethod))
+return;

zequanwu wrote:
> labath wrote:
> > How did you come to pick this? I get that this is not critical 
> > functionality for your use case, but it seems rather strange to be claiming 
> > that you're looking up methods here. If you don't care what you look up 
> > exactly, then maybe you could just skip this check completely, possibly 
> > leaving a TODO to implement this in a better way. (The Symtab class has 
> > code (heuristics) which tries to classify symbols into functions, methods, 
> > etc., but I'm not sure if it actually works with breakpad symbols (them 
> > being demangled), nor am I sure that we should replicate that here.)
> I just found that name_type_mask always has `eFunctionNameTypeMethod`. 
> Removed.
This is probably the only value used by the tests, but one can definitely get 
other values too, for example through various arguments to the "breakpoint set" 
command. While a (very) brave soul could in theory try to set breakpoints and 
debug a live process with breakpad debug info, I think that's unlikely to 
happen in practice. So the usefulness of this function will probably remain 
limited to tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113163

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


[Lldb-commits] [PATCH] D113533: [LLDB] Remove access check of decl in TypeSystemClang.cpp

2021-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

I'm pretty sure you're trying to solve the same problem as here: D85993 


In short: You're calling `CreateFunctionDeclaration` to create a function in a 
record, but you actually want to call `AddMethodToCXXRecordType` which allows 
passing and setting an access specifier (which is what the assert here checks). 
You can fix this in the PDB plugin by looking at the DeclContext and if 
`decl_ctx->isRecord()` -> `AddMethodToCXXRecordType` and otherwise 
`CreateFunctionDeclaration`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113533

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


[Lldb-commits] [PATCH] D113519: [lldb] [gdb-server] Fix fill_clamp to handle signed src types

2021-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Closed by commit rG82ce9127436b: [lldb] [gdb-server] Fix fill_clamp to handle 
signed src types (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D113519?vs=385989=386079#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113519

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp


Index: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -771,8 +771,11 @@
 
 template 
 static void fill_clamp(T , U src, typename T::value_type fallback) {
-  dest = src <= std::numeric_limits::max() ? src
-   : fallback;
+  static_assert(std::is_unsigned::value,
+"Destination type must be unsigned.");
+  using UU = typename std::make_unsigned::type;
+  constexpr auto T_max = std::numeric_limits::max();
+  dest = src >= 0 && static_cast(src) <= T_max ? src : fallback;
 }
 
 GDBRemoteCommunication::PacketResult


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -771,8 +771,11 @@
 
 template 
 static void fill_clamp(T , U src, typename T::value_type fallback) {
-  dest = src <= std::numeric_limits::max() ? src
-   : fallback;
+  static_assert(std::is_unsigned::value,
+"Destination type must be unsigned.");
+  using UU = typename std::make_unsigned::type;
+  constexpr auto T_max = std::numeric_limits::max();
+  dest = src >= 0 && static_cast(src) <= T_max ? src : fallback;
 }
 
 GDBRemoteCommunication::PacketResult
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108078: [lldb] Support gdbserver signals

2021-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f1372365ac6: [lldb] Support gdbserver signals (authored by 
mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D108078?vs=385917=386078#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108078

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
  lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/tools/debugserver/source/RNBRemote.cpp

Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3462,7 +3462,8 @@
   uint32_t max_packet_size = 128 * 1024; // 128KBytes is a reasonable max packet
  // size--debugger can always use less
   char buf[256];
-  snprintf(buf, sizeof(buf), "qXfer:features:read+;PacketSize=%x;qEcho+",
+  snprintf(buf, sizeof(buf),
+   "qXfer:features:read+;PacketSize=%x;qEcho+;native-signals+",
max_packet_size);
 
   bool enable_compression = false;
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -412,3 +412,75 @@
 process = self.connect(target)
 process.Detach()
 self.assertRegex(self.server.responder.detached, r"D;0*400")
+
+def test_signal_gdb(self):
+class MyResponder(MockGDBServerResponder):
+def qSupported(self, client_supported):
+return "PacketSize=3fff;QStartNoAckMode+"
+
+def haltReason(self):
+return "S0a"
+
+def cont(self):
+return self.haltReason()
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+
+self.assertEqual(process.threads[0].GetStopReason(),
+ lldb.eStopReasonSignal)
+self.assertEqual(process.threads[0].GetStopDescription(100),
+ 'signal SIGBUS')
+
+def test_signal_lldb_old(self):
+class MyResponder(MockGDBServerResponder):
+def qSupported(self, client_supported):
+return "PacketSize=3fff;QStartNoAckMode+"
+
+def qHostInfo(self):
+return "triple:61726d76372d756e6b6e6f776e2d6c696e75782d676e75;"
+
+def QThreadSuffixSupported(self):
+return "OK"
+
+def haltReason(self):
+return "S0a"
+
+def cont(self):
+return self.haltReason()
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+
+self.assertEqual(process.threads[0].GetStopReason(),
+ lldb.eStopReasonSignal)
+self.assertEqual(process.threads[0].GetStopDescription(100),
+ 'signal SIGUSR1')
+
+def test_signal_lldb(self):
+class MyResponder(MockGDBServerResponder):
+def qSupported(self, client_supported):
+return "PacketSize=3fff;QStartNoAckMode+;native-signals+"
+
+def qHostInfo(self):
+return "triple:61726d76372d756e6b6e6f776e2d6c696e75782d676e75;"
+
+def haltReason(self):
+return "S0a"
+
+def cont(self):
+return self.haltReason()
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+
+self.assertEqual(process.threads[0].GetStopReason(),
+ lldb.eStopReasonSignal)
+self.assertEqual(process.threads[0].GetStopDescription(100),
+ 'signal SIGUSR1')
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -607,14 +607,6 @@
 __FUNCTION__, GetID(),
 

[Lldb-commits] [lldb] 82ce912 - [lldb] [gdb-server] Fix fill_clamp to handle signed src types

2021-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-11-10T09:38:55+01:00
New Revision: 82ce9127436b316eca6763b926b2cde2e3d4bb8a

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

LOG: [lldb] [gdb-server] Fix fill_clamp to handle signed src types

Fix the fill_clamp() function to handle signed source types.  Make sure
that the source value is always non-negative, and cast it to unsigned
when verifying the upper bound.  This fixes compiler warnings about
comparing unsigned and signed types.

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

Added: 


Modified: 

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index c61ce2a74b99..f371649842e8 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -771,8 +771,11 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(
 
 template 
 static void fill_clamp(T , U src, typename T::value_type fallback) {
-  dest = src <= std::numeric_limits::max() ? src
-   : fallback;
+  static_assert(std::is_unsigned::value,
+"Destination type must be unsigned.");
+  using UU = typename std::make_unsigned::type;
+  constexpr auto T_max = std::numeric_limits::max();
+  dest = src >= 0 && static_cast(src) <= T_max ? src : fallback;
 }
 
 GDBRemoteCommunication::PacketResult



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


[Lldb-commits] [lldb] 3f13723 - [lldb] Support gdbserver signals

2021-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-11-10T09:38:55+01:00
New Revision: 3f1372365ac6c860ff6ecc4cfd3ba131bdf81698

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

LOG: [lldb] Support gdbserver signals

GDB and LLDB use different signal models.  GDB uses a predefined set
of signal codes, and maps platform's signos to them.  On the other hand,
LLDB has historically simply passed native signos.

In order to improve compatibility between LLDB and gdbserver, the GDB
signal model should be used.  However, GDB does not provide a mapping
for all existing signals on Linux and unsupported signals are passed
as 'unknown'.  Limiting LLDB to this behavior could be considered
a regression.

To get the best of both worlds, use the LLDB signal model when talking
to lldb-server, and the GDB signal model otherwise.  For this purpose,
new versions of lldb-server indicate "native-signals+" via qSupported.
At the same time, we also detect older versions of lldb-server
via QThreadSuffixSupported for backwards compatibility.  If neither test
succeeds, we assume gdbserver or another implementation using GDB model.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
lldb/tools/debugserver/source/RNBRemote.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 1aaba6fcfb7f..1999399b89bc 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -858,6 +858,7 @@ def add_qSupported_packets(self, client_features=[]):
 "vfork-events",
 "memory-tagging",
 "qSaveCore",
+"native-signals",
 ]
 
 def parse_qSupported_response(self, context):

diff  --git a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp 
b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
index 427225c14d3b..15981a2c1cb8 100644
--- a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
@@ -15,4 +15,167 @@ GDBRemoteSignals::GDBRemoteSignals() : UnixSignals() { 
Reset(); }
 GDBRemoteSignals::GDBRemoteSignals(const lldb::UnixSignalsSP )
 : UnixSignals(*rhs) {}
 
-void GDBRemoteSignals::Reset() { m_signals.clear(); }
+void GDBRemoteSignals::Reset() {
+  m_signals.clear();
+  // clang-format off
+  //SIGNO   NAMESUPPRESS  STOPNOTIFY  DESCRIPTION
+  //==  ==    ==  ==  
===
+  AddSignal(1,  "SIGHUP",   false,true,   true,   "hangup");
+  AddSignal(2,  "SIGINT",   true, true,   true,   "interrupt");
+  AddSignal(3,  "SIGQUIT",  false,true,   true,   "quit");
+  AddSignal(4,  "SIGILL",   false,true,   true,   "illegal 
instruction");
+  AddSignal(5,  "SIGTRAP",  true, true,   true,   "trace trap (not 
reset when caught)");
+  AddSignal(6,  "SIGABRT",  false,true,   true,   "abort()/IOT 
trap", "SIGIOT");
+  AddSignal(7,  "SIGEMT",   false,true,   true,   "emulation 
trap");
+  AddSignal(8,  "SIGFPE",   false,true,   true,   "floating point 
exception");
+  AddSignal(9,  "SIGKILL",  false,true,   true,   "kill");
+  AddSignal(10, "SIGBUS",   false,true,   true,   "bus error");
+  AddSignal(11, "SIGSEGV",  false,true,   true,   "segmentation 
violation");
+  AddSignal(12, "SIGSYS",   false,true,   true,   "invalid system 
call");
+  AddSignal(13, "SIGPIPE",  false,true,   true,   "write to pipe 
with reading end closed");
+  AddSignal(14, "SIGALRM",  false,false,  false,  "alarm");
+  AddSignal(15, "SIGTERM",  false,true,   true,   "termination 
requested");
+  AddSignal(16, "SIGURG",   false,true,   true,   "urgent data on 
socket");
+  AddSignal(17, "SIGSTOP",  true, true,   true,   "process stop");
+  AddSignal(18, "SIGTSTP",  false,true,   true,   "tty stop");
+  

[Lldb-commits] [PATCH] D113521: Allow lldb to launch a remote executable when there isn't a local copy

2021-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I have two high-level questions about this:

- what should be the relative priority of executable ModuleSP vs the launch 
info? IIUC, in the current implementation the module takes precedence, but it 
seems to me it would be more natural if the launch info came out on top. One of 
the reasons I'm thinking about this is because you currently cannot re-run 
executables that use exec(2) (I mean, you can, but it will rarely produce the 
desired results). This happens because we use the post-exec executable, but the 
rest of the launch info refers to the main one. If the executable module was 
not the primary source of truth here, then maybe the we could somehow use this 
mechanism to improve the exec story as well (by storing the original executable 
in the launch info or something).
- what happens if the launch_info path happens to refer to a host executable? 
Will we still launch the remote one or will we try to copy the local one 
instead? I'm not sure of the current behavior, but I would like to avoid the 
behavior depending on the presence of local files.




Comment at: lldb/source/Commands/CommandObjectProcess.cpp:269
+if (!exe_module_sp) {
+  result.AppendError("Could not get executable module after launch.");
+  return false;

This probably shouldn't be a hard error. If we fail to obtain the executable 
module, I'd think we should still be able to continue with asm debugging. (In 
fact, since you don't clean up the process here, that's probably what will 
happen regardless of the error state.)



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py:30
+ascii = bytearray.fromhex(a_arr[2]).decode()
+self.testcase.assertEqual(ascii, self.testcase.absent_file, 
"We sent the right path")
+return "OK"

the responder will run on a separate thread, so a failing assertion will not 
immediately terminate the test, but rather confuse the hell out of everyone. It 
be better to just record the data here, and do the assertion on the main thread.



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py:69
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTargetWithFileAndArch(None, "x86_64")
+launch_info = target.GetLaunchInfo()

I would use the CreateTarget overload which takes a platform name argument. 
Otherwise, this will pick a random platform on non-darwin hosts and then it may 
get confused by the darwin-specific responses.



Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py:79-83
+# We need to fetch the connected event:
+event = lldb.SBEvent()
+got_event = self.dbg.GetListener().WaitForEventForBroadcaster(30, 
process.GetBroadcaster(), event)
+self.assertTrue(got_event, "Got an initial event after connect")
+self.assertEqual(process.GetState(), lldb.eStateConnected, "Unexpected 
state.")

we have `lldbutil.expect_state_changes` for this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113521

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