[Lldb-commits] [lldb] 320f65e - [LLDB][NFC] Remove parameter names from forward declarations from hand written expressions used in heap.py part 2

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

Author: Shafik Yaghmour
Date: 2021-10-19T16:52:36-07:00
New Revision: 320f65ee65f40fadbd2016036e538e28ae28614c

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

LOG: [LLDB][NFC] Remove parameter names from forward declarations from hand 
written expressions used in heap.py part 2

heap.py has a lot of large hand written expressions and each name in the
expression will be looked up by clang during expression parsing. For
function parameters this will be in Sema::ActOnParamDeclarator(...) in order to
catch redeclarations of parameters. The names are not needed and we have seen
some rare cases where since we don't have symbols we end up in
SymbolContext::FindBestGlobalDataSymbol(...) which may conflict with other 
global
symbols.

There may be a way to make this lookup smarter to avoid these cases but it is
not clear how well tested this path is and how much work it would be to fix it.
So we will go with this fix while we investigate more.

This is a second try at getting all the cases we care about.

Ref: rdar://78265641

Added: 


Modified: 
lldb/examples/darwin/heap_find/heap.py

Removed: 




diff  --git a/lldb/examples/darwin/heap_find/heap.py 
b/lldb/examples/darwin/heap_find/heap.py
index 8ee44ae25e446..75cb9225e72d6 100644
--- a/lldb/examples/darwin/heap_find/heap.py
+++ b/lldb/examples/darwin/heap_find/heap.py
@@ -129,7 +129,7 @@ def get_iterate_memory_expr(
 void *reserved1[12];
 struct malloc_introspection_t  *introspect;
 } malloc_zone_t;
-kern_return_t malloc_get_all_zones(task_t task, memory_reader_t reader, 
vm_address_t **addresses, unsigned *count);
+kern_return_t malloc_get_all_zones(task_t, memory_reader_t, vm_address_t **, 
unsigned *);
 memory_reader_t task_peek = [](task_t, vm_address_t remote_address, vm_size_t, 
void **local_memory) -> kern_return_t {
 *local_memory = (void*) remote_address;
 return KERN_SUCCESS;



___
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-10-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 380825.

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/examples/python/scripted_process/stack_core_scripted_process.py
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Index: lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -2,7 +2,7 @@
 Test python scripted process in lldb
 """
 
-import os
+import os, json, tempfile
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -10,14 +10,15 @@
 from lldbsuite.test import lldbutil
 from lldbsuite.test import lldbtest
 
-
 class ScriptedProcesTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
-self.source = "main.c"
+self.scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process']
+self.scripted_process_example_abspath = os.path.join(self.getSourceDir(),
+*self.scripted_process_example_relpath)
 
 def tearDown(self):
 TestBase.tearDown(self)
@@ -78,18 +79,31 @@
 self.assertGreater(thread.GetNumFrames(), 0)
 
 frame = thread.GetFrameAtIndex(0)
+GPRs = None
 register_set = frame.registers # Returns an SBValueList.
 for regs in register_set:
-if 'GPR' in regs.name:
-registers  = regs
+if 'general purpose' in regs.name.lower():
+GPRs = regs
 break
 
-self.assertTrue(registers, "Invalid General Purpose Registers Set")
-self.assertEqual(registers.GetNumChildren(), 21)
-for idx, reg in enumerate(registers, start=1):
+self.assertTrue(GPRs, "Invalid General Purpose Registers Set")
+self.assertEqual(GPRs.GetNumChildren(), 21)
+for idx, reg in enumerate(GPRs, start=1):
 self.assertEqual(idx, int(reg.value, 16))
 
-@skipIfDarwin
+def create_stack_skinny_corefile(self):
+self.build()
+target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
+self.assertTrue(process.IsValid(), "Process is invalid.")
+# FIXME: Use SBAPI to save the process corefile.
+stack_core = tempfile.NamedTemporaryFile()
+self.runCmd("process save-core -s stack  " + stack_core.name)
+self.assertTrue(os.path.exists(stack_core.name), "No stack-only corefile found.")
+self.assertTrue(self.dbg.DeleteTarget(target), "Couldn't delete target")
+print(stack_core.name)
+target = self.dbg.CreateTarget(None)
+return target.LoadCore(self.getBuildArtifact(stack_core.name))
+
 @skipUnlessDarwin
 def test_launch_scripted_process_stack_frames(self):
 """Test that we can launch an lldb scripted process from the command
@@ -101,26 +115,40 @@
 for module in target.modules:
 if 'a.out' in module.GetFileSpec().GetFilename():
 main_module = module
+break
 
 self.assertTrue(main_module, "Invalid main module.")
 error = target.SetModuleLoadAddress(main_module, 0)
 self.assertTrue(error.Success(), "Reloading main module at offset 0 failed.")
 
-scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process','my_scripted_process.py']
-self.runCmd("command script import " + os.path.join(self.getSourceDir(),
-*scripted_process_example_relpath))
+os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
+self.runCmd("command script import " + os.path.join(self.scripted_process_example_abspath,
+"stack_core_scripted_process.py"))
 
-process = target.GetProcess()
+corefile_process = self.create_stack_skinny_corefile()
+self.assertTrue(corefile_process, PROCESS_IS_VALID)
+
+structured_data = lldb.SBStructuredData()
+structured_data.SetFromJSON(json.dumps({
+"backing_target_idx" : self.dbg.GetIndexOfTarget(corefile_process.GetTarget())
+}))
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetProcessPluginName("ScriptedProcess")
+launch_info.SetScriptedProcessClassName("stack_core_scripted_process.StackCoreScriptedProcess")
+launch_info.SetScriptedProcessDictionary(structured_data)
+
+error = lldb.SBError()
+

[Lldb-commits] [PATCH] D112045: [lldb/API] Fix SBLaunchInfo::SetScriptedProcessDictionary

2021-10-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib abandoned this revision.
mib added a comment.

I'm abandoning this revision in favor of D112109 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112045

___
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-10-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 380819.
mib added a comment.

Fix 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/examples/python/scripted_process/stack_core_scripted_process.py
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Index: lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -2,7 +2,7 @@
 Test python scripted process in lldb
 """
 
-import os
+import os, json, tempfile
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -10,14 +10,15 @@
 from lldbsuite.test import lldbutil
 from lldbsuite.test import lldbtest
 
-
 class ScriptedProcesTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
-self.source = "main.c"
+self.scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process']
+self.scripted_process_example_abspath = os.path.join(self.getSourceDir(),
+*self.scripted_process_example_relpath)
 
 def tearDown(self):
 TestBase.tearDown(self)
@@ -78,19 +79,31 @@
 self.assertGreater(thread.GetNumFrames(), 0)
 
 frame = thread.GetFrameAtIndex(0)
+GPRs = None
 register_set = frame.registers # Returns an SBValueList.
 for regs in register_set:
-if 'GPR' in regs.name:
-registers  = regs
+if 'general purpose' in regs.name.lower():
+GPRs = regs
 break
 
-self.assertTrue(registers, "Invalid General Purpose Registers Set")
-self.assertEqual(registers.GetNumChildren(), 21)
-for idx, reg in enumerate(registers, start=1):
+self.assertTrue(GPRs, "Invalid General Purpose Registers Set")
+self.assertEqual(GPRs.GetNumChildren(), 21)
+for idx, reg in enumerate(GPRs, start=1):
 self.assertEqual(idx, int(reg.value, 16))
 
-@skipIfDarwin
-@skipUnlessDarwin
+def create_stack_skinny_corefile(self):
+self.build()
+target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
+self.assertTrue(process.IsValid(), "Process is invalid.")
+# FIXME: Use SBAPI to save the process corefile.
+stack_core = tempfile.NamedTemporaryFile()
+self.runCmd("process save-core -s stack  " + stack_core.name)
+self.assertTrue(os.path.exists(stack_core.name), "No stack-only corefile found.")
+self.assertTrue(self.dbg.DeleteTarget(target), "Couldn't delete target")
+print(stack_core.name)
+target = self.dbg.CreateTarget(None)
+return target.LoadCore(self.getBuildArtifact(stack_core.name))
+
 def test_launch_scripted_process_stack_frames(self):
 """Test that we can launch an lldb scripted process from the command
 line, check its process ID and read string from memory."""
@@ -101,26 +114,40 @@
 for module in target.modules:
 if 'a.out' in module.GetFileSpec().GetFilename():
 main_module = module
+break
 
 self.assertTrue(main_module, "Invalid main module.")
 error = target.SetModuleLoadAddress(main_module, 0)
 self.assertTrue(error.Success(), "Reloading main module at offset 0 failed.")
 
-scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process','my_scripted_process.py']
-self.runCmd("command script import " + os.path.join(self.getSourceDir(),
-*scripted_process_example_relpath))
+os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
+self.runCmd("command script import " + os.path.join(self.scripted_process_example_abspath,
+"stack_core_scripted_process.py"))
 
-process = target.GetProcess()
+corefile_process = self.create_stack_skinny_corefile()
+self.assertTrue(corefile_process, PROCESS_IS_VALID)
+
+structured_data = lldb.SBStructuredData()
+structured_data.SetFromJSON(json.dumps({
+"backing_target_idx" : self.dbg.GetIndexOfTarget(corefile_process.GetTarget())
+}))
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetProcessPluginName("ScriptedProcess")
+

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

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

Update after rebase.


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()
 
 self.id = None
 self.name = None
Index: 

[Lldb-commits] [PATCH] D112109: [lldb/Plugins] Serialize ProcessLaunchInfo ScriptedProcess Dictionary

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

This patch replaces the type of the ProcessLaunchInfo ScriptedProcess
Dictionary from a StructuredData pointer to be serialized in a string.

The reason behind this change is that the lifetime of the dictionary's
pointer could be managed by an actor other than the debugger (i.e. the
Python Interpreter). In some cases, this caused the dictionary's pointer
to point to corrupted memory, which can interfere with the good functionning
of Scripted Processes and Scripted Threads.

This patch also updates the related-code to take these changes into account.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112109

Files:
  lldb/include/lldb/Host/ProcessLaunchInfo.h
  lldb/source/API/SBLaunchInfo.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/common/ProcessLaunchInfo.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2930,8 +2930,8 @@
 default_launch_info.SetProcessPluginName("ScriptedProcess");
 default_launch_info.SetScriptedProcessClassName(
 launch_info.GetScriptedProcessClassName());
-default_launch_info.SetScriptedProcessDictionarySP(
-launch_info.GetScriptedProcessDictionarySP());
+default_launch_info.SetScriptedProcessDictionary(
+launch_info.GetScriptedProcessDictionary());
 
 SetProcessLaunchInfo(launch_info);
   }
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -25,6 +25,8 @@
   public:
 ScriptedProcessInfo(const ProcessLaunchInfo _info) {
   m_class_name = launch_info.GetScriptedProcessClassName();
+  m_args_sp =
+  StructuredData::ParseJSON(launch_info.GetScriptedProcessDictionary());
 }
 
 std::string GetClassName() const { return m_class_name; }
Index: lldb/source/Host/common/ProcessLaunchInfo.cpp
===
--- lldb/source/Host/common/ProcessLaunchInfo.cpp
+++ lldb/source/Host/common/ProcessLaunchInfo.cpp
@@ -32,7 +32,7 @@
 : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
   m_file_actions(), m_pty(new PseudoTerminal), m_monitor_callback(nullptr),
   m_listener_sp(), m_hijack_listener_sp(), m_scripted_process_class_name(),
-  m_scripted_process_dictionary_sp() {}
+  m_scripted_process_dict() {}
 
 ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec _file_spec,
  const FileSpec _file_spec,
@@ -43,7 +43,7 @@
   m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
   m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
   m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp(),
-  m_scripted_process_class_name(), m_scripted_process_dictionary_sp() {
+  m_scripted_process_class_name(), m_scripted_process_dict() {
   if (stdin_file_spec) {
 FileAction file_action;
 const bool read = true;
@@ -173,7 +173,7 @@
   m_listener_sp.reset();
   m_hijack_listener_sp.reset();
   m_scripted_process_class_name.clear();
-  m_scripted_process_dictionary_sp.reset();
+  m_scripted_process_dict.clear();
 }
 
 void ProcessLaunchInfo::SetMonitorProcessCallback(
Index: lldb/source/Commands/CommandObjectProcess.cpp
===
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ lldb/source/Commands/CommandObjectProcess.cpp
@@ -190,8 +190,16 @@
   m_options.launch_info.SetProcessPluginName("ScriptedProcess");
   m_options.launch_info.SetScriptedProcessClassName(
   m_class_options.GetName());
-  m_options.launch_info.SetScriptedProcessDictionarySP(
-  m_class_options.GetStructuredData());
+  const StructuredData::DictionarySP dict_sp =
+  m_class_options.GetStructuredData();
+
+  if (dict_sp) {
+StreamString stream;
+llvm::json::OStream s(stream.AsRawOstream());
+dict_sp->Serialize(s);
+m_options.launch_info.SetScriptedProcessDictionary(stream.GetData());
+  }
+
   target->SetProcessLaunchInfo(m_options.launch_info);
 }
 
Index: lldb/source/API/SBLaunchInfo.cpp
===
--- lldb/source/API/SBLaunchInfo.cpp
+++ lldb/source/API/SBLaunchInfo.cpp
@@ -367,12 +367,9 @@
 lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBStructuredData, SBLaunchInfo,
 

[Lldb-commits] [PATCH] D112107: [lldb/Plugins] Make `ScriptedInterface::CreatePluginObject` more generic

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

This patch refactors the `ScriptedInterface::CreatePluginObject` method
and all its virtual implementations to use a `StructuredData::ObjectSP`
instead of a `StructuredData::DictionarySP` argument.

This is less restrictive and makes calls to `StructuredData::ParseJSON`
seemless.

This patch also updates the `ScriptedProcessInfo` class to conform to this.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112107

Files:
  lldb/include/lldb/Interpreter/ScriptedInterface.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
@@ -24,7 +24,7 @@
 
   StructuredData::GenericSP
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext _ctx,
- StructuredData::DictionarySP args_sp) override;
+ StructuredData::ObjectSP args_sp) override;
 
   lldb::tid_t GetThreadID() override;
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
@@ -31,7 +31,7 @@
 
 StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject(
 const llvm::StringRef class_name, ExecutionContext _ctx,
-StructuredData::DictionarySP args_sp) {
+StructuredData::ObjectSP args_sp) {
 
   if (class_name.empty())
 return {};
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -25,7 +25,7 @@
   StructuredData::GenericSP
   CreatePluginObject(const llvm::StringRef class_name,
  ExecutionContext _ctx,
- StructuredData::DictionarySP args_sp) override;
+ StructuredData::ObjectSP args_sp) override;
 
   Status Launch() override;
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -32,7 +32,7 @@
 
 StructuredData::GenericSP ScriptedProcessPythonInterface::CreatePluginObject(
 llvm::StringRef class_name, ExecutionContext _ctx,
-StructuredData::DictionarySP args_sp) {
+StructuredData::ObjectSP args_sp) {
   if (class_name.empty())
 return {};
 
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,14 @@
   public:
 ScriptedProcessInfo(const ProcessLaunchInfo _info) {
   m_class_name = launch_info.GetScriptedProcessClassName();
-  m_dictionary_sp = launch_info.GetScriptedProcessDictionarySP();
 }
 
 std::string GetClassName() const { return m_class_name; }
-StructuredData::DictionarySP GetDictionarySP() const {
-  return 

[Lldb-commits] [PATCH] D112034: [lldb/test] Update test/API/functionalities/load_lazy to macOS 12

2021-10-19 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e004b03f72a: [lldb/test] Update 
test/API/functionalities/load_lazy to macOS 12 (authored by vsk).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112034

Files:
  lldb/test/API/functionalities/load_lazy/Makefile


Index: lldb/test/API/functionalities/load_lazy/Makefile
===
--- lldb/test/API/functionalities/load_lazy/Makefile
+++ lldb/test/API/functionalities/load_lazy/Makefile
@@ -5,9 +5,20 @@
 
 include Makefile.rules
 
+ifeq "$(OS)" "Darwin"
+   # In macOS 12, dyld switched to using chained fixups. As a result, all
+   # symbols are bound at launch and there are no lazy pointers any more.
+   # Since we wish to import/dlopen() a dylib with missing symbols, we need
+   # to use a weak import. This applies to all macOS 12-aligned OS 
releases,
+   # e.g. iOS 15, etc.
+   LINKFLAGS := "-Wl,-weak-lt2_0"
+else
+   LINKFLAGS := "-lt2_0"
+endif
+
 t1: t2_0
$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. $(LINKFLAGS)"
 
 t2_0:
$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \


Index: lldb/test/API/functionalities/load_lazy/Makefile
===
--- lldb/test/API/functionalities/load_lazy/Makefile
+++ lldb/test/API/functionalities/load_lazy/Makefile
@@ -5,9 +5,20 @@
 
 include Makefile.rules
 
+ifeq "$(OS)" "Darwin"
+	# In macOS 12, dyld switched to using chained fixups. As a result, all
+	# symbols are bound at launch and there are no lazy pointers any more.
+	# Since we wish to import/dlopen() a dylib with missing symbols, we need
+	# to use a weak import. This applies to all macOS 12-aligned OS releases,
+	# e.g. iOS 15, etc.
+	LINKFLAGS := "-Wl,-weak-lt2_0"
+else
+	LINKFLAGS := "-lt2_0"
+endif
+
 t1: t2_0
 	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-		DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 LD_EXTRAS="-L. -lt2_0"
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 LD_EXTRAS="-L. $(LINKFLAGS)"
 
 t2_0:
 	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5e004b0 - [lldb/test] Update test/API/functionalities/load_lazy to macOS 12

2021-10-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-10-19T13:25:14-07:00
New Revision: 5e004b03f72a17f916b93792eb778dfa9e7a09cc

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

LOG: [lldb/test] Update test/API/functionalities/load_lazy to macOS 12

In macOS 12, dyld switched to using chained fixups. As a result, all symbols
are bound at launch and there are no lazy pointers any more. Since we wish to
import/dlopen() a dylib with missing symbols, we need to use a weak import.
This applies to all macOS 12-aligned OS releases, e.g. iOS 15, etc.

rdar://81295101

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

Added: 


Modified: 
lldb/test/API/functionalities/load_lazy/Makefile

Removed: 




diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
index 7200114d03aeb..81bc7dcb4d05f 100644
--- a/lldb/test/API/functionalities/load_lazy/Makefile
+++ b/lldb/test/API/functionalities/load_lazy/Makefile
@@ -5,9 +5,20 @@ all: t2_0 t2_1 t1 a.out
 
 include Makefile.rules
 
+ifeq "$(OS)" "Darwin"
+   # In macOS 12, dyld switched to using chained fixups. As a result, all
+   # symbols are bound at launch and there are no lazy pointers any more.
+   # Since we wish to import/dlopen() a dylib with missing symbols, we need
+   # to use a weak import. This applies to all macOS 12-aligned OS 
releases,
+   # e.g. iOS 15, etc.
+   LINKFLAGS := "-Wl,-weak-lt2_0"
+else
+   LINKFLAGS := "-lt2_0"
+endif
+
 t1: t2_0
$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. $(LINKFLAGS)"
 
 t2_0:
$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \



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


[Lldb-commits] [PATCH] D111965: [lldb] improve the help strings for gdb-remote and kdp-remote

2021-10-19 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ac5a6641fa4: [lldb] improve the help strings for gdb-remote 
and kdp-remote (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111965

Files:
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,10 @@
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin "
+  "gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +764,10 @@
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin "
+  "kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,10 @@
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin "
+  "gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +764,10 @@
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin "
+  "kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8ac5a66 - [lldb] improve the help strings for gdb-remote and kdp-remote

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

Author: Lawrence D'Anna
Date: 2021-10-19T13:08:21-07:00
New Revision: 8ac5a6641fa4d742fb4599b485c40700e773f01f

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

LOG: [lldb] improve the help strings for gdb-remote and kdp-remote

The help string can be more helpful by explaining these are
aliases for 'process connect'

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index d5426ba1b6db..301bf949feef 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,10 @@ void CommandInterpreter::LoadCommandDictionary() {
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin "
+  "gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +764,10 @@ void CommandInterpreter::LoadCommandDictionary() {
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin "
+  "kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(



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


[Lldb-commits] [PATCH] D111965: [lldb] improve the help strings for gdb-remote and kdp-remote

2021-10-19 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/D111965/new/

https://reviews.llvm.org/D111965

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


[Lldb-commits] [PATCH] D112058: [lldb/DWARF] Ignore debug info pointing to the low addresses

2021-10-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks good. Do we need a follow up patch to avoid creating functions that 
should have been stripped?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112058

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


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

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

It looks like you missed one conversion.  I agree with Pavel that None is not 
only more pythonic but also more lldbutils-y.  Other than those nits, LGTM.




Comment at: lldb/packages/Python/lldbsuite/test/lldbutil.py:648
+expected_hit_count = -1,
+location_id = -1,
+expected_location_hit_count = -1):

These could be two lists or a list of duples to allow matching against more 
than one location at a time, but we can do also that when we need it.



Comment at: 
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py:269
 self.expect(side_effect.bp_loc, exe=False,
-patterns=["1.* where = .*main .* resolved, hit count = 1"])
+patterns=["1.* where = .*main .* resolved,( hardware,)? hit 
count = 1"])
 

Why didn't you change this one to use your new function?


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

https://reviews.llvm.org/D111899

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


[Lldb-commits] [PATCH] D111355: [lldb] Add serial:// protocol for connecting to serial port

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 380731.
mgorny retitled this revision from "[lldb] Add serial:// protocol for 
connecting to serial port [WIP/PoC]" to "[lldb] Add serial:// protocol for 
connecting to serial port".
mgorny added a comment.

Move `serial://` URL parsing to `SerialPort` class. Improve error handling.


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

https://reviews.llvm.org/D111355

Files:
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/common/File.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestPty.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py

Index: lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -427,7 +427,7 @@
 return libc.ptsname(self._master.fileno()).decode()
 
 def get_connect_url(self):
-return "file://" + self.get_connect_address()
+return "serial://" + self.get_connect_address()
 
 def close_server(self):
 self._slave.close()
Index: lldb/test/API/functionalities/gdb_remote_client/TestPty.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestPty.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestPty.py
@@ -9,6 +9,38 @@
 mydir = TestBase.compute_mydir(__file__)
 server_socket_class = PtyServerSocket
 
+def get_term_attrs(self):
+import termios
+return termios.tcgetattr(self.server._socket._slave)
+
+def setUp(self):
+super().setUp()
+self.orig_attr = self.get_term_attrs()
+
+def assert_raw_mode(self, current_attr):
+import termios
+self.assertEqual(current_attr[0] & (termios.BRKINT |
+termios.PARMRK |
+termios.ISTRIP | termios.INLCR |
+termios.IGNCR | termios.ICRNL |
+termios.IXON),
+ 0)
+self.assertEqual(current_attr[1] & termios.OPOST, 0)
+self.assertEqual(current_attr[2] & termios.CSIZE, termios.CS8)
+self.assertEqual(current_attr[3] & (termios.ICANON | termios.ECHO |
+termios.ISIG | termios.IEXTEN),
+ 0)
+self.assertEqual(current_attr[6][termios.VMIN], 1)
+self.assertEqual(current_attr[6][termios.VTIME], 0)
+
+def get_parity_flags(self, attr):
+import termios
+return attr[2] & (termios.PARENB | termios.PARODD)
+
+def get_stop_bit_flags(self, attr):
+import termios
+return attr[2] & termios.CSTOPB
+
 def test_process_connect_sync(self):
 """Test the process connect command in synchronous mode"""
 try:
@@ -17,8 +49,20 @@
 substrs=['Platform: remote-gdb-server', 'Connected: no'])
 self.expect("process connect " + self.server.get_connect_url(),
 substrs=['Process', 'stopped'])
+
+current_attr = self.get_term_attrs()
+# serial:// should set raw mode
+self.assert_raw_mode(current_attr)
+# other parameters should be unmodified
+self.assertEqual(current_attr[4:6], self.orig_attr[4:6])
+self.assertEqual(self.get_parity_flags(current_attr),
+ self.get_parity_flags(self.orig_attr))
+self.assertEqual(self.get_stop_bit_flags(current_attr),
+ self.get_stop_bit_flags(self.orig_attr))
 finally:
 self.dbg.GetSelectedTarget().GetProcess().Kill()
+# original mode should be restored on exit
+self.assertEqual(self.get_term_attrs(), self.orig_attr)
 
 def test_process_connect_async(self):
 """Test the process connect command in asynchronous mode"""
@@ -31,7 +75,63 @@
 substrs=['Process', 'stopped'])
 lldbutil.expect_state_changes(self, self.dbg.GetListener(),
   self.process(), [lldb.eStateStopped])
+
+current_attr = self.get_term_attrs()
+# serial:// should set raw mode
+self.assert_raw_mode(current_attr)
+# other parameters should be unmodified
+self.assertEqual(current_attr[4:6], self.orig_attr[4:6])
+self.assertEqual(self.get_parity_flags(current_attr),
+ self.get_parity_flags(self.orig_attr))
+self.assertEqual(self.get_stop_bit_flags(current_attr),
+ 

[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 380726.
mgorny added a comment.

Rebased to use `llvm::Error` return type. Moved `Parity` into `Terminal` class.


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

https://reviews.llvm.org/D111030

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -72,6 +72,149 @@
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
 
+TEST_F(TerminalTest, SetRaw) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetRaw(), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  // NB: cfmakeraw() on glibc disables IGNBRK, on FreeBSD sets it
+  EXPECT_EQ(terminfo.c_iflag &
+(BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON),
+0U);
+  EXPECT_EQ(terminfo.c_oflag & OPOST, 0U);
+  EXPECT_EQ(terminfo.c_lflag & (ICANON | ECHO | ISIG | IEXTEN), 0U);
+  EXPECT_EQ(terminfo.c_cflag & (CSIZE | PARENB), 0U | CS8);
+  EXPECT_EQ(terminfo.c_cc[VMIN], 1);
+  EXPECT_EQ(terminfo.c_cc[VTIME], 0);
+}
+
+TEST_F(TerminalTest, SetBaudRate) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(38400), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(cfgetispeed(), static_cast(B38400));
+  EXPECT_EQ(cfgetospeed(), static_cast(B38400));
+
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(115200), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(cfgetispeed(), static_cast(B115200));
+  EXPECT_EQ(cfgetospeed(), static_cast(B115200));
+
+  // uncommon value
+#if defined(B153600)
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(153600), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(cfgetispeed(), static_cast(B153600));
+  EXPECT_EQ(cfgetospeed(), static_cast(B153600));
+#else
+  ASSERT_THAT_ERROR(m_term.SetBaudRate(153600),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"baud rate 153600 unsupported by the platform")));
+#endif
+}
+
+TEST_F(TerminalTest, SetStopBits) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetStopBits(1), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(terminfo.c_cflag & CSTOPB, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetStopBits(2), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_NE(terminfo.c_cflag & CSTOPB, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetStopBits(0),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"invalid stop bit count: 0 (must be 1 or 2)")));
+  ASSERT_THAT_ERROR(m_term.SetStopBits(3),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"invalid stop bit count: 3 (must be 1 or 2)")));
+}
+
+TEST_F(TerminalTest, SetParity) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::No), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(terminfo.c_cflag & PARENB, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Even),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
+#if defined(CMSPAR)
+  EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
+#endif
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Odd), llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
+#if defined(CMSPAR)
+  EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
+#endif
+
+#if defined(CMSPAR)
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Space),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
+  EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Mark),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
+  EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
+#else
+  ASSERT_THAT_ERROR(m_term.SetParity(Terminal::Parity::Space),
+llvm::Failed(testing::Property(
+::ErrorInfoBase::message,
+"space/mark parity is not supported by the platform")));
+  

[Lldb-commits] [lldb] a66798c - Remove unneeded variable num_found.

2021-10-19 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-10-19T09:57:07-07:00
New Revision: a66798cd67fedc35efbb8986deef417631bbc88a

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

LOG: Remove unneeded variable num_found.

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 1c43ea15af01b..d5426ba1b6dbf 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1255,13 +1255,11 @@ CommandObject *CommandInterpreter::GetUserCommandObject(
 return exact_cmd;
 
   // We didn't have an exact command, so now look for partial matches.
-  size_t num_found;
   StringList tmp_list;
   StringList *matches_ptr = matches ? matches : _list;
-  num_found =
-  AddNamesMatchingPartialString(GetUserCommands(), cmd_str, *matches_ptr);
-  num_found += AddNamesMatchingPartialString(GetUserMultiwordCommands(),
- cmd_str, *matches_ptr);
+  AddNamesMatchingPartialString(GetUserCommands(), cmd_str, *matches_ptr);
+  AddNamesMatchingPartialString(GetUserMultiwordCommands(),
+cmd_str, *matches_ptr);
 
   return {};
 }



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


[Lldb-commits] [lldb] 1529738 - [debugserver] Fix BUILDING_FOR_ARM64_OSX

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

Author: Jonas Devlieghere
Date: 2021-10-19T09:55:53-07:00
New Revision: 1529738b6619cdf817feb31771b57a893accf63b

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

LOG: [debugserver] Fix BUILDING_FOR_ARM64_OSX

Check for TARGET_CPU_ARM64 (ARM instructions for 64-bit mode) rather
than TARGET_CPU_ARM (instructions for 32-bit mode).

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index 588df7f65355f..cf1eea31cdb8d 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -88,21 +88,21 @@ include(CheckCSourceCompiles)
 check_c_source_compiles(
 "
 #include 
-#if TARGET_CPU_ARM
+#if TARGET_CPU_ARM64
 #if TARGET_OS_OSX
 #warning Building for macOS
 #else
 #error Not building for macOS
 #endif
 #else
-#error Not building for ARM
+#error Not building for ARM64
 #endif
 int main() { return 0; }
 "
-BUILDING_FOR_ARM_OSX
+BUILDING_FOR_ARM64_OSX
 )
 
-if (BUILDING_FOR_ARM_OSX)
+if (BUILDING_FOR_ARM64_OSX)
   set(CMAKE_OSX_ARCHITECTURES "arm64;arm64e")
 endif ()
 



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


[Lldb-commits] [PATCH] D112058: [lldb/DWARF] Ignore debug info pointing to the low addresses

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



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:472
+  InitializeFirstCodeAddress(*m_objfile_sp->GetModule()->GetSectionList());
+  if (m_first_code_address == LLDB_INVALID_ADDRESS)
+m_first_code_address = 0;

shafik wrote:
> It would be nice to wrap this up into `InitializeFirstCodeAddress(...)` it 
> could be done by making iterating over the section list a lambda and then 
> checking after that or splitting it into a helper etc
Yeah I was wondering about that myself. I've created a new function for that 
now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112058

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


[Lldb-commits] [PATCH] D112058: [lldb/DWARF] Ignore debug info pointing to the low addresses

2021-10-19 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 380715.
labath added a comment.

Move the recursion into a helper function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112058

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml

Index: lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
@@ -0,0 +1,152 @@
+# RUN: yaml2obj %s > %t
+# RUN: %lldb %t -o "image dump line-table a.c" -o "image lookup -n _start" -o "image lookup -n f" -o exit | FileCheck %s
+
+# CHECK-LABEL: image dump line-table a.c
+# CHECK-NEXT: Line table for a.c
+# CHECK-NEXT: 0x0080: a.c:1
+# CHECK-NEXT: 0x0084: a.c:1
+# CHECK-NEXT: 0x0086: a.c:1
+# CHECK-EMPTY:
+# CHECK-NEXT: image lookup -n _start
+# CHECK-NEXT: 1 match found
+# CHECK-LABEL: image lookup -n f
+# CHECK-EMPTY:
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+ProgramHeaders:
+  - Type:PT_LOAD
+Flags:   [ PF_X, PF_R ]
+Offset:  0x
+FirstSec:.text
+LastSec: .text
+Align:   0x1000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x80
+AddressAlign:0x10
+Content: 554889E55DC3
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x1
+DWARF:
+  debug_ranges:
+- Offset:  0x0
+  AddrSize:0x8
+  Entries:
+- LowOffset:   0x0
+  HighOffset:  0x6
+- LowOffset:   0x80
+  HighOffset:  0x86
+  debug_abbrev:
+- ID:  0
+  Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_string
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
+- Attribute:   DW_AT_stmt_list
+  Form:DW_FORM_sec_offset
+- Attribute:   DW_AT_low_pc
+  Form:DW_FORM_addr
+- Attribute:   DW_AT_ranges
+  Form:DW_FORM_sec_offset
+- Code:0x0002
+  Tag: DW_TAG_subprogram
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_low_pc
+  Form:DW_FORM_addr
+- Attribute:   DW_AT_high_pc
+  Form:DW_FORM_data4
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
+  debug_info:
+- Version: 4
+  AbbrevTableID:   0
+  AbbrOffset:  0x
+  AddrSize:8
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- CStr:Hand-written DWARF
+- CStr:a.c
+- Value:   0x
+- Value:   0x
+- Value:   0x
+- AbbrCode:0x0002
+  Values:
+- Value:   0x
+- Value:   0x0006
+- CStr:f
+- AbbrCode:0x0002
+  Values:
+- Value:   0x0080
+- Value:   0x0006
+- CStr:_start
+- AbbrCode:0x
+  debug_line:
+- Version: 4
+  MinInstLength:   1
+  MaxOpsPerInst:   1
+  DefaultIsStmt:   1
+  LineBase:251
+  LineRange:   14
+  OpcodeBase:  13
+  StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
+  IncludeDirs: []
+  Files:
+- Name:a.c
+  DirIdx:  0
+  ModTime: 0
+  Length:  0
+  Opcodes:
+- Opcode:  DW_LNS_extended_op
+  ExtLen:  9
+  SubOpcode:   DW_LNE_set_address
+  Data:0
+- Opcode:  DW_LNS_copy
+  Data:0
+- Opcode:  

[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

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



Comment at: lldb/packages/Python/lldbsuite/test/lldbutil.py:646
+bpno,
+expected_locations = -1,
+expected_hit_count = -1,

`None` would be more pythonic



Comment at: lldb/packages/Python/lldbsuite/test/lldbutil.py:663-664
+if(expected_locations > -1):
+test.assertTrue(expected_locations == bkpt.GetNumLocations(),
+"Expecting {} locations, got 
{}.".format(expected_locations, bkpt.GetNumLocations()))
+

If you replace `assertTrue(foo == bar)` with `assertEquals(foo, bar)` then you 
get the failure message for free.


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

https://reviews.llvm.org/D111899

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


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-19 Thread Nikolay Chokoev via Phabricator via lldb-commits
georgiev updated this revision to Diff 380714.
georgiev added a comment.

A new lldbutil function to test the breakpoint - check_breakpoint.


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

https://reviews.llvm.org/D111899

Files:
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py
  lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
  lldb/test/API/functionalities/breakpoint/cpp_exception/Makefile
  lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
  lldb/test/API/functionalities/memory/find/TestMemoryFind.py
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py
  lldb/test/API/lang/c/anonymous/TestAnonymous.py
  lldb/test/API/lang/c/array_types/TestArrayTypes.py
  lldb/test/API/lang/c/bitfields/TestBitfields.py
  lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
  lldb/test/API/lang/c/const_variables/TestConstVariables.py
  lldb/test/API/lang/c/enum_types/TestEnumTypes.py
  lldb/test/API/lang/c/forward/TestForwardDeclaration.py
  lldb/test/API/lang/c/function_types/TestFunctionTypes.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/c/local_variables/TestLocalVariables.py
  lldb/test/API/lang/c/modules/TestCModules.py
  lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
  lldb/test/API/lang/c/set_values/TestSetValues.py
  lldb/test/API/lang/c/shared_lib/TestSharedLib.py
  
lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
  lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py
  lldb/test/API/lang/cpp/inlines/TestInlines.py
  lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py
  lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
  lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
  lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
  lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
  lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
  lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
  lldb/test/API/lang/objc/modules/TestObjCModules.py
  lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
  lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
  
lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py

Index: lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
===
--- lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
+++ lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
@@ -40,8 +40,7 @@
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 d1 = self.frame().FindVariable("d1")
 d1.SetPreferSyntheticValue(True)
Index: lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
===
--- lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
+++ lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
@@ -33,14 +33,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 # This should display correctly.
 self.expect(
@@ -71,14 +69,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count 

[Lldb-commits] [PATCH] D112058: [lldb/DWARF] Ignore debug info pointing to the low addresses

2021-10-19 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:472
+  InitializeFirstCodeAddress(*m_objfile_sp->GetModule()->GetSectionList());
+  if (m_first_code_address == LLDB_INVALID_ADDRESS)
+m_first_code_address = 0;

It would be nice to wrap this up into `InitializeFirstCodeAddress(...)` it 
could be done by making iterating over the section list a lambda and then 
checking after that or splitting it into a helper etc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112058

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


[Lldb-commits] [lldb] b492b0b - [lldb] [Process/Utility] Define dN regs on ARM via helper macro

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

Author: Michał Górny
Date: 2021-10-19T17:06:03+02:00
New Revision: b492b0be95d9134bfb092eb2c73cf6996c4518f7

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

LOG: [lldb] [Process/Utility] Define dN regs on ARM via helper macro

Use FPU_REG macro to define dN registers, removing the wrong value_regs
while at it.  This is a piece-wise attempt of reconstructing D112066
with the goal of figuring out which part of the larger change breaks
the buildbot.

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
index 1f30cb0723ce..2eabe1659c2b 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -254,23 +254,6 @@ static uint32_t g_s29_invalidates[] = {fpu_d14, fpu_q7, 
LLDB_INVALID_REGNUM};
 static uint32_t g_s30_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 static uint32_t g_s31_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 
-static uint32_t g_d0_contains[] = {fpu_s0, fpu_s1, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_contains[] = {fpu_s2, fpu_s3, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_contains[] = {fpu_s4, fpu_s5, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_contains[] = {fpu_s6, fpu_s7, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_contains[] = {fpu_s8, fpu_s9, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_contains[] = {fpu_s10, fpu_s11, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_contains[] = {fpu_s12, fpu_s13, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_contains[] = {fpu_s14, fpu_s15, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_contains[] = {fpu_s16, fpu_s17, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_contains[] = {fpu_s18, fpu_s19, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_contains[] = {fpu_s20, fpu_s21, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_contains[] = {fpu_s22, fpu_s23, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_contains[] = {fpu_s24, fpu_s25, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_contains[] = {fpu_s26, fpu_s27, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_contains[] = {fpu_s28, fpu_s29, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_contains[] = {fpu_s30, fpu_s31, LLDB_INVALID_REGNUM};
-
 static uint32_t g_d0_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
 static uint32_t g_d1_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
 static uint32_t g_d2_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
@@ -596,390 +579,38 @@ static RegisterInfo g_register_infos_arm[] = {
 nullptr,
 },
 
-{
-"d0",
-nullptr,
-8,
-FPU_OFFSET(0),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d0},
-g_d0_contains,
-g_d0_invalidates,
-},
-{
-"d1",
-nullptr,
-8,
-FPU_OFFSET(2),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d1},
-g_d1_contains,
-g_d1_invalidates,
-},
-{
-"d2",
-nullptr,
-8,
-FPU_OFFSET(4),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d2},
-g_d2_contains,
-g_d2_invalidates,
-},
-{
-"d3",
-nullptr,
-8,
-FPU_OFFSET(6),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d3},
-g_d3_contains,
-g_d3_invalidates,
-},
-{
-"d4",
-nullptr,
-8,
-FPU_OFFSET(8),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d4},
-g_d4_contains,
-g_d4_invalidates,
-},
-{
-"d5",
-nullptr,
-8,
-FPU_OFFSET(10),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d5},
-g_d5_contains,
-g_d5_invalidates,
-},
-{
-"d6",
-nullptr,
-8,
-FPU_OFFSET(12),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_d6},
-g_d6_contains,
-g_d6_invalidates,
-},
-{
-"d7",
-nullptr,
-8,
-FPU_OFFSET(14),
-   

[Lldb-commits] [PATCH] D110827: [LLDB] Provide target specific directories to libclang

2021-10-19 Thread Pavel Kosov via Phabricator via lldb-commits
kpdev42 added a comment.

In D110827#3059120 , @clayborg wrote:

> In D110827#3042820 , @kpdev42 wrote:
>
>> In D110827#3034767 , @clayborg 
>> wrote:
>>
>>> LLDB also tests with compilers that were built, like when LLDB builds clang 
>>> and uses that clang and clang++ that it built to run the test suite. If we 
>>> had settings in LLDB that users could set, then the test suite would be 
>>> able to use the include files for the compiler that is being used instead 
>>> of always defaulting to the system headers.
>>
>> Could you please clarify: "LLDB builds clang" - here you mean clang which 
>> was build with LLDB? And I would like to mention that starting from 
>> https://reviews.llvm.org/D89013 libcxx puts __config_site header to target 
>> specific folder
>
> We often build the full clang compiler during LLDB builds and then use the 
> clang we built as the compiler when running our test suite. So anything we 
> can do to make sure what ever clang we use for building the test suite 
> binaries has all of the headers that it was built with along with any support 
> library headers (libcxx, etc) that would be great.

That's fine, but patch is about *libclang* seeing target specific headers, not 
clang frontend. While clang frontend obtains system header paths through 
Toolchain-derived classes (lib/Driver/Toolchain), one has to *explicitly* set 
those paths when calling libclang. That's exactly what lldb does in 
CppModuleConfiguration.cpp when evaluating expression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110827

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


[Lldb-commits] [lldb] 28e0c34 - [lldb] [Process/Utility] Define sN regs on ARM via helper macro

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

Author: Michał Górny
Date: 2021-10-19T15:51:47+02:00
New Revision: 28e0c34216530087f62da66f3f19ce57211d8eed

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

LOG: [lldb] [Process/Utility] Define sN regs on ARM via helper macro

This is a piece-wise attempt of reconstructing D112066 with the goal
of figuring out which part of the larger change breaks the buildbot.

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
index 28af25322afb..1f30cb0723ce 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -329,6 +329,14 @@ static uint32_t g_q13_contains[] = {fpu_d26, fpu_d27, 
LLDB_INVALID_REGNUM};
 static uint32_t g_q14_contains[] = {fpu_d28, fpu_d29, LLDB_INVALID_REGNUM};
 static uint32_t g_q15_contains[] = {fpu_d30, fpu_d31, LLDB_INVALID_REGNUM};
 
+#define FPU_REG(name, size, offset, qreg)  
\
+  {
\
+#name, nullptr, size, FPU_OFFSET(offset), eEncodingIEEE754, eFormatFloat,  
\
+{LLDB_INVALID_REGNUM, dwarf_##name, LLDB_INVALID_REGNUM,   
\
+ LLDB_INVALID_REGNUM, fpu_##name },
\
+ nullptr, g_##name##_invalidates,  
\
+  }
+
 static RegisterInfo g_register_infos_arm[] = {
 //  NAME ALT SZ   OFFSET  ENCODING  FORMAT
 //  EH_FRAME DWARFGENERIC
@@ -542,390 +550,39 @@ static RegisterInfo g_register_infos_arm[] = {
 nullptr,
 },
 
-{
-"s0",
-nullptr,
-4,
-FPU_OFFSET(0),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s0},
-nullptr,
-g_s0_invalidates,
-},
-{
-"s1",
-nullptr,
-4,
-FPU_OFFSET(1),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s1},
-nullptr,
-g_s1_invalidates,
-},
-{
-"s2",
-nullptr,
-4,
-FPU_OFFSET(2),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s2},
-nullptr,
-g_s2_invalidates,
-},
-{
-"s3",
-nullptr,
-4,
-FPU_OFFSET(3),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s3},
-nullptr,
-g_s3_invalidates,
-},
-{
-"s4",
-nullptr,
-4,
-FPU_OFFSET(4),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s4},
-nullptr,
-g_s4_invalidates,
-},
-{
-"s5",
-nullptr,
-4,
-FPU_OFFSET(5),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s5},
-nullptr,
-g_s5_invalidates,
-},
-{
-"s6",
-nullptr,
-4,
-FPU_OFFSET(6),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s6},
-nullptr,
-g_s6_invalidates,
-},
-{
-"s7",
-nullptr,
-4,
-FPU_OFFSET(7),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s7},
-nullptr,
-g_s7_invalidates,
-},
-{
-"s8",
-nullptr,
-4,
-FPU_OFFSET(8),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s8},
-nullptr,
-g_s8_invalidates,
-},
-{
-"s9",
-nullptr,
-4,
-FPU_OFFSET(9),
-eEncodingIEEE754,
-eFormatFloat,
-{LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, fpu_s9},
-nullptr,
-g_s9_invalidates,
-},
-{
-"s10",
-nullptr,
-4,
-FPU_OFFSET(10),
-eEncodingIEEE754,
- 

[Lldb-commits] [lldb] 5cd28f7 - [lldb] [Process/Utility] clang-format RegisterInfos_arm.h

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

Author: Michał Górny
Date: 2021-10-19T15:51:47+02:00
New Revision: 5cd28f71b1d96a4d4ed61e06751f52257da4df71

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

LOG: [lldb] [Process/Utility] clang-format RegisterInfos_arm.h

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
index 9eba19c071e3b..28af25322afba 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -337,1114 +337,1221 @@ static RegisterInfo g_register_infos_arm[] = {
 //  ===  ===
 //  ==  ===  =
 //  ==  =
-{"r0",
- nullptr,
- 4,
- GPR_OFFSET(0),
- eEncodingUint,
- eFormatHex,
- {ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM,
-  gpr_r0},
- nullptr,
- nullptr,
-},
-{"r1",
- nullptr,
- 4,
- GPR_OFFSET(1),
- eEncodingUint,
- eFormatHex,
- {ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM,
-  gpr_r1},
- nullptr,
- nullptr,
-},
-{"r2",
- nullptr,
- 4,
- GPR_OFFSET(2),
- eEncodingUint,
- eFormatHex,
- {ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM,
-  gpr_r2},
- nullptr,
- nullptr,
-},
-{"r3",
- nullptr,
- 4,
- GPR_OFFSET(3),
- eEncodingUint,
- eFormatHex,
- {ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM,
-  gpr_r3},
- nullptr,
- nullptr,
-},
-{"r4",
- nullptr,
- 4,
- GPR_OFFSET(4),
- eEncodingUint,
- eFormatHex,
- {ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r4},
- nullptr,
- nullptr,
-},
-{"r5",
- nullptr,
- 4,
- GPR_OFFSET(5),
- eEncodingUint,
- eFormatHex,
- {ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r5},
- nullptr,
- nullptr,
-},
-{"r6",
- nullptr,
- 4,
- GPR_OFFSET(6),
- eEncodingUint,
- eFormatHex,
- {ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r6},
- nullptr,
- nullptr,
-},
-{"r7",
- nullptr,
- 4,
- GPR_OFFSET(7),
- eEncodingUint,
- eFormatHex,
- {ehframe_r7, dwarf_r7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r7},
- nullptr,
- nullptr,
-},
-{"r8",
- nullptr,
- 4,
- GPR_OFFSET(8),
- eEncodingUint,
- eFormatHex,
- {ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r8},
- nullptr,
- nullptr,
-},
-{"r9",
- nullptr,
- 4,
- GPR_OFFSET(9),
- eEncodingUint,
- eFormatHex,
- {ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r9},
- nullptr,
- nullptr,
-},
-{"r10",
- nullptr,
- 4,
- GPR_OFFSET(10),
- eEncodingUint,
- eFormatHex,
- {ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  gpr_r10},
- nullptr,
- nullptr,
-},
-{"r11",
- nullptr,
- 4,
- GPR_OFFSET(11),
- eEncodingUint,
- eFormatHex,
- {ehframe_r11, dwarf_r11, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
-  gpr_r11},
- nullptr,
- nullptr,
-},
-{"r12",
- nullptr,
- 4,
- GPR_OFFSET(12),
- eEncodingUint,
- eFormatHex,
- {ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  gpr_r12},
- nullptr,
- nullptr,
-},
-{"sp",
- "r13",
- 4,
- GPR_OFFSET(13),
- eEncodingUint,
- eFormatHex,
- {ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
-  gpr_sp},
- nullptr,
- nullptr,
-},
-{"lr",
- "r14",
- 4,
- GPR_OFFSET(14),
- eEncodingUint,
- eFormatHex,
- {ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM,
-  gpr_lr},
- nullptr,
- nullptr,
-},
-{"pc",
- "r15",
- 4,
- GPR_OFFSET(15),
- eEncodingUint,
- eFormatHex,
- {ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM,
-  gpr_pc},
- nullptr,
- nullptr,
-},
-{"cpsr",
- "psr",
- 4,
- GPR_OFFSET(16),
- eEncodingUint,
- eFormatHex,
- {ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM,
-  gpr_cpsr},
- nullptr,
- nullptr,
+{
+"r0",
+nullptr,
+4,
+GPR_OFFSET(0),
+eEncodingUint,
+eFormatHex,
+

[Lldb-commits] [lldb] 7df912c - Revert "[lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM"

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

Author: Michał Górny
Date: 2021-10-19T15:33:39+02:00
New Revision: 7df912c65d1963c5403f1d645329b20f7e2d60ea

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

LOG: Revert "[lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM"

This reverts commit 1c2c67b46b55a2a81ebc988c829e2eee13a4fec6.
Something's still wrong.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
index ace2e5a9f68b0..9eba19c071e3b 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -254,38 +254,39 @@ static uint32_t g_s29_invalidates[] = {fpu_d14, fpu_q7, 
LLDB_INVALID_REGNUM};
 static uint32_t g_s30_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 static uint32_t g_s31_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 
-static uint32_t g_d0_invalidates[] = {fpu_q0, fpu_s0, fpu_s1,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d1_invalidates[] = {fpu_q0, fpu_s2, fpu_s3,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d2_invalidates[] = {fpu_q1, fpu_s4, fpu_s5,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d3_invalidates[] = {fpu_q1, fpu_s6, fpu_s7,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d4_invalidates[] = {fpu_q2, fpu_s8, fpu_s9,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d5_invalidates[] = {fpu_q2, fpu_s10, fpu_s11,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d6_invalidates[] = {fpu_q3, fpu_s12, fpu_s13,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d7_invalidates[] = {fpu_q3, fpu_s14, fpu_s15,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d8_invalidates[] = {fpu_q4, fpu_s16, fpu_s17,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d9_invalidates[] = {fpu_q4, fpu_s18, fpu_s19,
-  LLDB_INVALID_REGNUM};
-static uint32_t g_d10_invalidates[] = {fpu_q5, fpu_s20, fpu_s21,
-   LLDB_INVALID_REGNUM};
-static uint32_t g_d11_invalidates[] = {fpu_q5, fpu_s22, fpu_s23,
-   LLDB_INVALID_REGNUM};
-static uint32_t g_d12_invalidates[] = {fpu_q6, fpu_s24, fpu_s25,
-   LLDB_INVALID_REGNUM};
-static uint32_t g_d13_invalidates[] = {fpu_q6, fpu_s26, fpu_s27,
-   LLDB_INVALID_REGNUM};
-static uint32_t g_d14_invalidates[] = {fpu_q7, fpu_s28, fpu_s29,
-   LLDB_INVALID_REGNUM};
-static uint32_t g_d15_invalidates[] = {fpu_q7, fpu_s30, fpu_s31,
-   LLDB_INVALID_REGNUM};
+static uint32_t g_d0_contains[] = {fpu_s0, fpu_s1, LLDB_INVALID_REGNUM};
+static uint32_t g_d1_contains[] = {fpu_s2, fpu_s3, LLDB_INVALID_REGNUM};
+static uint32_t g_d2_contains[] = {fpu_s4, fpu_s5, LLDB_INVALID_REGNUM};
+static uint32_t g_d3_contains[] = {fpu_s6, fpu_s7, LLDB_INVALID_REGNUM};
+static uint32_t g_d4_contains[] = {fpu_s8, fpu_s9, LLDB_INVALID_REGNUM};
+static uint32_t g_d5_contains[] = {fpu_s10, fpu_s11, LLDB_INVALID_REGNUM};
+static uint32_t g_d6_contains[] = {fpu_s12, fpu_s13, LLDB_INVALID_REGNUM};
+static uint32_t g_d7_contains[] = {fpu_s14, fpu_s15, LLDB_INVALID_REGNUM};
+static uint32_t g_d8_contains[] = {fpu_s16, fpu_s17, LLDB_INVALID_REGNUM};
+static uint32_t g_d9_contains[] = {fpu_s18, fpu_s19, LLDB_INVALID_REGNUM};
+static uint32_t g_d10_contains[] = {fpu_s20, fpu_s21, LLDB_INVALID_REGNUM};
+static uint32_t g_d11_contains[] = {fpu_s22, fpu_s23, LLDB_INVALID_REGNUM};
+static uint32_t g_d12_contains[] = {fpu_s24, fpu_s25, LLDB_INVALID_REGNUM};
+static uint32_t g_d13_contains[] = {fpu_s26, fpu_s27, LLDB_INVALID_REGNUM};
+static uint32_t g_d14_contains[] = {fpu_s28, fpu_s29, LLDB_INVALID_REGNUM};
+static uint32_t g_d15_contains[] = {fpu_s30, fpu_s31, LLDB_INVALID_REGNUM};
+
+static uint32_t g_d0_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
+static uint32_t g_d1_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
+static uint32_t g_d2_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
+static uint32_t g_d3_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
+static uint32_t g_d4_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
+static uint32_t g_d5_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
+static uint32_t g_d6_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
+static uint32_t g_d7_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
+static 

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

2021-10-19 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: omjavaid.
DavidSpickett added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: lldb/source/Symbol/AArch64UnwindInfo.cpp:40
+  // [1]
+  // https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/signal.c
+  int32_t offset = 128 + 8 + 8 + 24 + 128 + 8;

This comment comes from the libunwind change.



Comment at: lldb/source/Symbol/AArch64UnwindInfo.cpp:58
+  unwind_plan_sp->SetSourcedFromCompiler(eLazyBoolYes);
+  unwind_plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  unwind_plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolYes);

If this means "at all instructions within that function" this could be yes, but 
no one seems to read this field anyway.


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-10-19 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: kristof.beyls, mgorny.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds a specific unwind plan for AArch64 Linux sigreturn frames.
Previously we assumed that the fp would be valid here but it is not.

https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S

On Ubuntu Bionic it happened to point to an old frame info which meant
you got what looked like a correct backtrace. On Focal, the info is
completely invalid. (probably due to some code shuffling in libc)

This adds an UnwindPlan that knows that the sp in a sigreturn frame
points to an rt_sigframe from which we can offset to get saved
sp and pc values to backtrace correctly.

Based on LibUnwind's change: https://reviews.llvm.org/D90898

This also updates TestHandleAbort to check that common frames
between signal and signal handler backtrace are in fact the same.

Fixes https://bugs.llvm.org/show_bug.cgi?id=52165


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112069

Files:
  lldb/include/lldb/Symbol/AArch64UnwindInfo.h
  lldb/source/Symbol/AArch64UnwindInfo.cpp
  lldb/source/Symbol/CMakeLists.txt
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py

Index: lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
===
--- lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
+++ lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
@@ -16,8 +16,6 @@
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfWindows  # signals do not exist on Windows
-# Fails on Ubuntu Focal
-@skipIf(archs=["aarch64"], oslist=["linux"])
 @expectedFailureNetBSD
 def test_inferior_handle_sigabrt(self):
 """Inferior calls abort() and handles the resultant SIGABRT.
@@ -47,6 +45,9 @@
 self.assertEqual(thread.GetStopReasonDataAtIndex(0),
  signo, "The stop signal should be SIGABRT")
 
+# Save the backtrace frames to compare to the handler backtrace later.
+signal_frames = thread.get_thread_frames()
+
 # Continue to breakpoint in abort handler
 bkpt = target.FindBreakpointByID(
 lldbutil.run_break_set_by_source_regexp(self, "Set a breakpoint here"))
@@ -58,13 +59,21 @@
 frame = thread.GetFrameAtIndex(0)
 self.assertEqual(frame.GetDisplayFunctionName(), "handler", "Unexpected break?")
 
+handler_frames = thread.get_thread_frames()
+
 # Expect that unwinding should find 'abort_caller'
-foundFoo = False
-for frame in thread:
+found_caller = False
+for frame in handler_frames:
 if frame.GetDisplayFunctionName() == "abort_caller":
-foundFoo = True
+found_caller = True
+break
+
+self.assertTrue(found_caller, "Unwinding did not find func that called abort")
 
-self.assertTrue(foundFoo, "Unwinding did not find func that called abort")
+# Check that frames present in both backtraces have the same addresses.
+# The signal handler backtrace has extra frames at the start.
+self.assertEqual(signal_frames, handler_frames[-len(signal_frames):],
+  "Common frames for signal and signal handler backtrace do not match")
 
 # Continue until we exit.
 process.Continue()
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/AArch64UnwindInfo.h"
 #include "lldb/Symbol/ArmUnwindInfo.h"
 #include "lldb/Symbol/CallFrameInfo.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
@@ -900,6 +901,11 @@
   // unwind out of sigtramp.
   if (m_frame_type == eTrapHandlerFrame && process) {
 m_fast_unwind_plan_sp.reset();
+
+unwind_plan_sp = GetAArch64LinuxTrapHandlerUnwindPlan(process->GetTarget());
+if (unwind_plan_sp)
+  return unwind_plan_sp;
+
 unwind_plan_sp =
 func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
 if (!unwind_plan_sp)
Index: lldb/source/Symbol/CMakeLists.txt
===
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -7,6 +7,7 @@
 endif()
 
 add_lldb_library(lldbSymbol
+  AArch64UnwindInfo.cpp
   ArmUnwindInfo.cpp
   Block.cpp
   CompactUnwindInfo.cpp
Index: lldb/source/Symbol/AArch64UnwindInfo.cpp
===
--- /dev/null
+++ lldb/source/Symbol/AArch64UnwindInfo.cpp
@@ -0,0 +1,63 @@

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

2021-10-19 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 380664.

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/examples/python/scripted_process/stack_core_scripted_process.py
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Index: lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -2,7 +2,7 @@
 Test python scripted process in lldb
 """
 
-import os
+import os, json, tempfile
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -10,14 +10,15 @@
 from lldbsuite.test import lldbutil
 from lldbsuite.test import lldbtest
 
-
 class ScriptedProcesTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
-self.source = "main.c"
+self.scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process']
+self.scripted_process_example_abspath = os.path.join(self.getSourceDir(),
+*self.scripted_process_example_relpath)
 
 def tearDown(self):
 TestBase.tearDown(self)
@@ -89,8 +90,19 @@
 for idx, reg in enumerate(registers, start=1):
 self.assertEqual(idx, int(reg.value, 16))
 
-@skipIfDarwin
-@skipUnlessDarwin
+def create_stack_skinny_corefile(self):
+self.build()
+target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
+self.assertTrue(process.IsValid(), "Process is invalid.")
+# FIXME: Use SBAPI to save the process corefile.
+stack_core = tempfile.NamedTemporaryFile()
+self.runCmd("process save-core -s stack  " + stack_core.name)
+self.assertTrue(os.path.exists(stack_core.name), "No stack-only corefile found.")
+self.assertTrue(self.dbg.DeleteTarget(target), "Couldn't delete target")
+print(stack_core.name)
+target = self.dbg.CreateTarget(None)
+return target.LoadCore(self.getBuildArtifact(stack_core.name))
+
 def test_launch_scripted_process_stack_frames(self):
 """Test that we can launch an lldb scripted process from the command
 line, check its process ID and read string from memory."""
@@ -101,24 +113,38 @@
 for module in target.modules:
 if 'a.out' in module.GetFileSpec().GetFilename():
 main_module = module
+break
 
 self.assertTrue(main_module, "Invalid main module.")
 error = target.SetModuleLoadAddress(main_module, 0)
 self.assertTrue(error.Success(), "Reloading main module at offset 0 failed.")
 
-scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process','my_scripted_process.py']
-self.runCmd("command script import " + os.path.join(self.getSourceDir(),
-*scripted_process_example_relpath))
+os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
+self.runCmd("command script import " + os.path.join(self.scripted_process_example_abspath,
+"stack_core_scripted_process.py"))
 
-process = target.GetProcess()
+corefile_process = self.create_stack_skinny_corefile()
+self.assertTrue(corefile_process, PROCESS_IS_VALID)
+
+structured_data = lldb.SBStructuredData()
+structured_data.SetFromJSON(json.dumps({
+"backing_target_idx" : self.dbg.GetIndexOfTarget(corefile_process.GetTarget())
+}))
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetProcessPluginName("ScriptedProcess")
+launch_info.SetScriptedProcessClassName("stack_core_scripted_process.StackCoreScriptedProcess")
+launch_info.SetScriptedProcessDictionary(structured_data)
+
+error = lldb.SBError()
+process = target.Launch(launch_info, error)
+self.assertTrue(error.Success(), error.GetCString())
 self.assertTrue(process, PROCESS_IS_VALID)
 self.assertEqual(process.GetProcessID(), 42)
-self.assertEqual(process.GetNumThreads(), 1)
 
+self.assertEqual(process.GetNumThreads(), 1)
 thread = process.GetSelectedThread()
 self.assertTrue(thread, "Invalid thread.")
-self.assertEqual(thread.GetThreadID(), 0x19)
-self.assertEqual(thread.GetName(), "MyScriptedThread.thread-1")
+self.assertEqual(thread.GetName(), 

[Lldb-commits] [PATCH] D112066: [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c2c67b46b55: [lldb] [Process/Utility] Fix 
value_regs/invalidate_regs for ARM (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112066

Files:
  lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -254,39 +254,38 @@
 static uint32_t g_s30_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 static uint32_t g_s31_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 
-static uint32_t g_d0_contains[] = {fpu_s0, fpu_s1, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_contains[] = {fpu_s2, fpu_s3, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_contains[] = {fpu_s4, fpu_s5, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_contains[] = {fpu_s6, fpu_s7, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_contains[] = {fpu_s8, fpu_s9, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_contains[] = {fpu_s10, fpu_s11, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_contains[] = {fpu_s12, fpu_s13, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_contains[] = {fpu_s14, fpu_s15, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_contains[] = {fpu_s16, fpu_s17, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_contains[] = {fpu_s18, fpu_s19, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_contains[] = {fpu_s20, fpu_s21, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_contains[] = {fpu_s22, fpu_s23, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_contains[] = {fpu_s24, fpu_s25, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_contains[] = {fpu_s26, fpu_s27, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_contains[] = {fpu_s28, fpu_s29, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_contains[] = {fpu_s30, fpu_s31, LLDB_INVALID_REGNUM};
-
-static uint32_t g_d0_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_invalidates[] = {fpu_q4, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_invalidates[] = {fpu_q4, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_invalidates[] = {fpu_q5, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_invalidates[] = {fpu_q5, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_invalidates[] = {fpu_q6, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_invalidates[] = {fpu_q6, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_invalidates[] = {fpu_q7, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_invalidates[] = {fpu_q7, LLDB_INVALID_REGNUM};
+static uint32_t g_d0_invalidates[] = {fpu_q0, fpu_s0, fpu_s1,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d1_invalidates[] = {fpu_q0, fpu_s2, fpu_s3,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d2_invalidates[] = {fpu_q1, fpu_s4, fpu_s5,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d3_invalidates[] = {fpu_q1, fpu_s6, fpu_s7,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d4_invalidates[] = {fpu_q2, fpu_s8, fpu_s9,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d5_invalidates[] = {fpu_q2, fpu_s10, fpu_s11,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d6_invalidates[] = {fpu_q3, fpu_s12, fpu_s13,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d7_invalidates[] = {fpu_q3, fpu_s14, fpu_s15,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d8_invalidates[] = {fpu_q4, fpu_s16, fpu_s17,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d9_invalidates[] = {fpu_q4, fpu_s18, fpu_s19,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d10_invalidates[] = {fpu_q5, fpu_s20, fpu_s21,
+   LLDB_INVALID_REGNUM};
+static uint32_t g_d11_invalidates[] = {fpu_q5, fpu_s22, fpu_s23,
+   LLDB_INVALID_REGNUM};
+static uint32_t g_d12_invalidates[] = {fpu_q6, fpu_s24, fpu_s25,
+   LLDB_INVALID_REGNUM};
+static uint32_t g_d13_invalidates[] = {fpu_q6, fpu_s26, fpu_s27,
+   LLDB_INVALID_REGNUM};
+static uint32_t g_d14_invalidates[] = {fpu_q7, 

[Lldb-commits] [lldb] 1c2c67b - [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM

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

Author: Michał Górny
Date: 2021-10-19T14:47:46+02:00
New Revision: 1c2c67b46b55a2a81ebc988c829e2eee13a4fec6

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

LOG: [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM

Fix incorrect values for value_regs, and incomplete values for
invalidate_regs in RegisterInfos_arm.  The value_regs entry needs
to list only one base (i.e. larger) register that needs to be read
to get the value for this register, while invalidate_regs needs to list
all other registers (including pseudo-register) whose values would
change when this register is written to.

While at it, introduce helper macros for the definitions.

7a8ba4ffbeecb5070926b80bb839a4d80539f1ac fixed a similar problem
for ARM64.

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
index 9eba19c071e3b..ace2e5a9f68b0 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -254,39 +254,38 @@ static uint32_t g_s29_invalidates[] = {fpu_d14, fpu_q7, 
LLDB_INVALID_REGNUM};
 static uint32_t g_s30_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 static uint32_t g_s31_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 
-static uint32_t g_d0_contains[] = {fpu_s0, fpu_s1, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_contains[] = {fpu_s2, fpu_s3, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_contains[] = {fpu_s4, fpu_s5, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_contains[] = {fpu_s6, fpu_s7, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_contains[] = {fpu_s8, fpu_s9, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_contains[] = {fpu_s10, fpu_s11, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_contains[] = {fpu_s12, fpu_s13, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_contains[] = {fpu_s14, fpu_s15, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_contains[] = {fpu_s16, fpu_s17, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_contains[] = {fpu_s18, fpu_s19, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_contains[] = {fpu_s20, fpu_s21, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_contains[] = {fpu_s22, fpu_s23, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_contains[] = {fpu_s24, fpu_s25, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_contains[] = {fpu_s26, fpu_s27, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_contains[] = {fpu_s28, fpu_s29, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_contains[] = {fpu_s30, fpu_s31, LLDB_INVALID_REGNUM};
-
-static uint32_t g_d0_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_invalidates[] = {fpu_q4, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_invalidates[] = {fpu_q4, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_invalidates[] = {fpu_q5, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_invalidates[] = {fpu_q5, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_invalidates[] = {fpu_q6, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_invalidates[] = {fpu_q6, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_invalidates[] = {fpu_q7, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_invalidates[] = {fpu_q7, LLDB_INVALID_REGNUM};
+static uint32_t g_d0_invalidates[] = {fpu_q0, fpu_s0, fpu_s1,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d1_invalidates[] = {fpu_q0, fpu_s2, fpu_s3,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d2_invalidates[] = {fpu_q1, fpu_s4, fpu_s5,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d3_invalidates[] = {fpu_q1, fpu_s6, fpu_s7,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d4_invalidates[] = {fpu_q2, fpu_s8, fpu_s9,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d5_invalidates[] = {fpu_q2, fpu_s10, fpu_s11,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d6_invalidates[] = {fpu_q3, fpu_s12, fpu_s13,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d7_invalidates[] = {fpu_q3, fpu_s14, fpu_s15,
+  

[Lldb-commits] [PATCH] D112066: [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM

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

rG7a8ba4ffbee 
 fixed a 
similar problem on aarch64.


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

https://reviews.llvm.org/D112066

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


[Lldb-commits] [PATCH] D112066: [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste.
Herald added a subscriber: kristof.beyls.
mgorny requested review of this revision.

Fix incorrect values for value_regs, and incomplete values for
invalidate_regs in RegisterInfos_arm.  The value_regs entry needs
to list only one base (i.e. larger) register that needs to be read
to get the value for this register, while invalidate_regs needs to list
all other registers (including pseudo-register) whose values would
change when this register is written to.

While at it, introduce helper macros for the definitions.


https://reviews.llvm.org/D112066

Files:
  lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -254,39 +254,38 @@
 static uint32_t g_s30_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 static uint32_t g_s31_invalidates[] = {fpu_d15, fpu_q7, LLDB_INVALID_REGNUM};
 
-static uint32_t g_d0_contains[] = {fpu_s0, fpu_s1, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_contains[] = {fpu_s2, fpu_s3, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_contains[] = {fpu_s4, fpu_s5, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_contains[] = {fpu_s6, fpu_s7, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_contains[] = {fpu_s8, fpu_s9, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_contains[] = {fpu_s10, fpu_s11, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_contains[] = {fpu_s12, fpu_s13, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_contains[] = {fpu_s14, fpu_s15, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_contains[] = {fpu_s16, fpu_s17, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_contains[] = {fpu_s18, fpu_s19, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_contains[] = {fpu_s20, fpu_s21, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_contains[] = {fpu_s22, fpu_s23, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_contains[] = {fpu_s24, fpu_s25, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_contains[] = {fpu_s26, fpu_s27, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_contains[] = {fpu_s28, fpu_s29, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_contains[] = {fpu_s30, fpu_s31, LLDB_INVALID_REGNUM};
-
-static uint32_t g_d0_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
-static uint32_t g_d1_invalidates[] = {fpu_q0, LLDB_INVALID_REGNUM};
-static uint32_t g_d2_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
-static uint32_t g_d3_invalidates[] = {fpu_q1, LLDB_INVALID_REGNUM};
-static uint32_t g_d4_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
-static uint32_t g_d5_invalidates[] = {fpu_q2, LLDB_INVALID_REGNUM};
-static uint32_t g_d6_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
-static uint32_t g_d7_invalidates[] = {fpu_q3, LLDB_INVALID_REGNUM};
-static uint32_t g_d8_invalidates[] = {fpu_q4, LLDB_INVALID_REGNUM};
-static uint32_t g_d9_invalidates[] = {fpu_q4, LLDB_INVALID_REGNUM};
-static uint32_t g_d10_invalidates[] = {fpu_q5, LLDB_INVALID_REGNUM};
-static uint32_t g_d11_invalidates[] = {fpu_q5, LLDB_INVALID_REGNUM};
-static uint32_t g_d12_invalidates[] = {fpu_q6, LLDB_INVALID_REGNUM};
-static uint32_t g_d13_invalidates[] = {fpu_q6, LLDB_INVALID_REGNUM};
-static uint32_t g_d14_invalidates[] = {fpu_q7, LLDB_INVALID_REGNUM};
-static uint32_t g_d15_invalidates[] = {fpu_q7, LLDB_INVALID_REGNUM};
+static uint32_t g_d0_invalidates[] = {fpu_q0, fpu_s0, fpu_s1,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d1_invalidates[] = {fpu_q0, fpu_s2, fpu_s3,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d2_invalidates[] = {fpu_q1, fpu_s4, fpu_s5,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d3_invalidates[] = {fpu_q1, fpu_s6, fpu_s7,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d4_invalidates[] = {fpu_q2, fpu_s8, fpu_s9,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d5_invalidates[] = {fpu_q2, fpu_s10, fpu_s11,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d6_invalidates[] = {fpu_q3, fpu_s12, fpu_s13,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d7_invalidates[] = {fpu_q3, fpu_s14, fpu_s15,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d8_invalidates[] = {fpu_q4, fpu_s16, fpu_s17,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d9_invalidates[] = {fpu_q4, fpu_s18, fpu_s19,
+  LLDB_INVALID_REGNUM};
+static uint32_t g_d10_invalidates[] = {fpu_q5, fpu_s20, fpu_s21,
+   LLDB_INVALID_REGNUM};
+static uint32_t g_d11_invalidates[] = {fpu_q5, fpu_s22, fpu_s23,
+   LLDB_INVALID_REGNUM};
+static uint32_t 

[Lldb-commits] [lldb] c6d7f24 - [lldb] [ABI/X86] Refactor ABIX86::AugmentRegisterInfo()

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

Author: Michał Górny
Date: 2021-10-19T13:36:38+02:00
New Revision: c6d7f248bda3439a06c630c35360d40dbfc06abe

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

LOG: [lldb] [ABI/X86] Refactor ABIX86::AugmentRegisterInfo()

Refactor ABIX86::AugmentRegisterInfo() and helper functions for better
readability.  This also fixes listing eax & co. as potential subregs
on 32-bit systems.

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

Added: 


Modified: 
lldb/source/Plugins/ABI/X86/ABIX86.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp 
b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index 0286140e4e24c..2615235cdd8fe 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -33,36 +33,40 @@ void ABIX86::Terminate() {
   ABIWindows_x86_64::Terminate();
 }
 
-enum class RegKind {
-  GPR32 = 0,
+namespace {
+enum RegKind {
+  GPR32,
   GPR16,
   GPR8h,
   GPR8,
+  MM,
+  YMM_YMMh,
+  YMM_XMM,
 
-  MM = 0,
+  RegKindCount
+};
+}
+
+struct RegData {
+  RegKind subreg_kind;
+  llvm::StringRef subreg_name;
+  llvm::Optional base_index;
 };
 
-typedef llvm::SmallDenseMap, 16>
-RegisterMap;
-
-static void addPartialRegisters(
-std::vector ,
-llvm::ArrayRef base_reg_indices, const RegisterMap _names,
-uint32_t base_size, RegKind name_index, lldb::Encoding encoding,
-lldb::Format format, uint32_t subreg_size, uint32_t subreg_offset = 0) {
-  for (uint32_t base_index : base_reg_indices) {
-if (base_index == LLDB_INVALID_REGNUM)
-  break;
-assert(base_index < regs.size());
+static void
+addPartialRegisters(std::vector ,
+llvm::ArrayRef subregs, uint32_t base_size,
+lldb::Encoding encoding, lldb::Format format,
+uint32_t subreg_size, uint32_t subreg_offset = 0) {
+  for (const RegData *subreg : subregs) {
+assert(subreg);
+uint32_t base_index = subreg->base_index.getValue();
 DynamicRegisterInfo::Register _reg = regs[base_index];
-llvm::StringRef subreg_name = reg_names.lookup(
-full_reg.name.GetStringRef())[static_cast(name_index)];
-if (subreg_name.empty() || full_reg.byte_size != base_size)
+if (full_reg.byte_size != base_size)
   continue;
 
-lldb_private::DynamicRegisterInfo::Register subreg{
-lldb_private::ConstString(subreg_name),
+lldb_private::DynamicRegisterInfo::Register new_reg{
+lldb_private::ConstString(subreg->subreg_name),
 lldb_private::ConstString(),
 lldb_private::ConstString("supplementary registers"),
 subreg_size,
@@ -77,10 +81,65 @@ static void addPartialRegisters(
 {},
 subreg_offset};
 
-addSupplementaryRegister(regs, subreg);
+addSupplementaryRegister(regs, new_reg);
   }
 }
 
+typedef llvm::SmallDenseMap, 64>
+BaseRegToRegsMap;
+
+#define GPRh(l)
\
+  {
\
+is64bit
\
+? BaseRegToRegsMap::value_type("r" l "x",  
\
+   {{GPR32, "e" l "x", llvm::None},
\
+{GPR16, l "x", llvm::None},
\
+{GPR8h, l "h", llvm::None},
\
+{GPR8, l "l", llvm::None}})
\
+: BaseRegToRegsMap::value_type("e" l "x", {{GPR16, l "x", llvm::None}, 
\
+   {GPR8h, l "h", llvm::None}, 
\
+   {GPR8, l "l", llvm::None}}) 
\
+  }
+
+#define GPR(r16)   
\
+  {
\
+is64bit
\
+? BaseRegToRegsMap::value_type("r" r16, {{GPR32, "e" r16, llvm::None}, 
\
+ {GPR16, r16, llvm::None}, 
\
+ {GPR8, r16 "l", llvm::None}}) 
\
+: BaseRegToRegsMap::value_type("e" r16, {{GPR16, r16, llvm::None}, 
\
+ {GPR8, r16 "l", llvm::None}}) 
\
+  }
+
+#define GPR64(n)   
\
+  {
\
+BaseRegToRegsMap::value_type("r" #n, {{GPR32, "r" #n "d", llvm::None}, 
\
+  {GPR16, "r" #n "w", 

[Lldb-commits] [lldb] 39f2b05 - [lldb] [Host] Make Terminal methods return llvm::Error

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

Author: Michał Górny
Date: 2021-10-19T13:31:03+02:00
New Revision: 39f2b059633ec1dc51b10b3fb48b616d87c273e3

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

LOG: [lldb] [Host] Make Terminal methods return llvm::Error

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

Added: 


Modified: 
lldb/include/lldb/Host/Terminal.h
lldb/source/Host/common/Terminal.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Target/Process.cpp
lldb/unittests/Host/posix/TerminalTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Terminal.h 
b/lldb/include/lldb/Host/Terminal.h
index ba70acf720d2d..f8f5d5d16ef90 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -12,9 +12,12 @@
 
 #include "lldb/Host/Config.h"
 #include "lldb/lldb-private.h"
+#include "llvm/Support/Error.h"
 
 namespace lldb_private {
 
+class TerminalState;
+
 class Terminal {
 public:
   Terminal(int fd = -1) : m_fd(fd) {}
@@ -31,12 +34,19 @@ class Terminal {
 
   void Clear() { m_fd = -1; }
 
-  bool SetEcho(bool enabled);
+  llvm::Error SetEcho(bool enabled);
 
-  bool SetCanonical(bool enabled);
+  llvm::Error SetCanonical(bool enabled);
 
 protected:
+  struct Data;
+
   int m_fd; // This may or may not be a terminal file descriptor
+
+  llvm::Expected GetData();
+  llvm::Error SetData(const Data );
+
+  friend class TerminalState;
 };
 
 /// \class TerminalState Terminal.h "lldb/Host/Terminal.h"
@@ -45,8 +55,6 @@ class Terminal {
 /// This class can be used to remember the terminal state for a file
 /// descriptor and later restore that state as it originally was.
 class TerminalState {
-  struct Data;
-
 public:
   /// Construct a new instance and optionally save terminal state.
   ///
@@ -125,10 +133,10 @@ class TerminalState {
   bool ProcessGroupIsValid() const;
 
   // Member variables
-  Terminal m_tty;   ///< A terminal
-  int m_tflags = -1;///< Cached tflags information.
-  std::unique_ptr m_data; ///< Platform-specific implementation.
-  lldb::pid_t m_process_group = -1; ///< Cached process group information.
+  Terminal m_tty; ///< A terminal
+  int m_tflags = -1;  ///< Cached tflags information.
+  std::unique_ptr m_data; ///< Platform-specific 
implementation.
+  lldb::pid_t m_process_group = -1;   ///< Cached process group 
information.
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Host/common/Terminal.cpp 
b/lldb/source/Host/common/Terminal.cpp
index 2be9a6d6b0ece..7050bae0c3c1c 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -21,71 +21,78 @@
 
 using namespace lldb_private;
 
+struct Terminal::Data {
+#if LLDB_ENABLE_TERMIOS
+  struct termios m_termios; ///< Cached terminal state information.
+#endif
+};
+
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
-bool Terminal::SetEcho(bool enabled) {
-  if (FileDescriptorIsValid()) {
+llvm::Expected Terminal::GetData() {
+  if (!FileDescriptorIsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid fd");
+
 #if LLDB_ENABLE_TERMIOS
-if (IsATerminal()) {
-  struct termios fd_termios;
-  if (::tcgetattr(m_fd, _termios) == 0) {
-bool set_corectly = false;
-if (enabled) {
-  if (fd_termios.c_lflag & ECHO)
-set_corectly = true;
-  else
-fd_termios.c_lflag |= ECHO;
-} else {
-  if (fd_termios.c_lflag & ECHO)
-fd_termios.c_lflag &= ~ECHO;
-  else
-set_corectly = true;
-}
-
-if (set_corectly)
-  return true;
-return ::tcsetattr(m_fd, TCSANOW, _termios) == 0;
-  }
-}
-#endif // #if LLDB_ENABLE_TERMIOS
-  }
-  return false;
+  if (!IsATerminal())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "fd not a terminal");
+
+  Data data;
+  if (::tcgetattr(m_fd, _termios) != 0)
+return llvm::createStringError(
+std::error_code(errno, std::generic_category()),
+"unable to get teletype attributes");
+  return data;
+#else // !LLDB_ENABLE_TERMIOS
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "termios support missing in LLDB");
+#endif // LLDB_ENABLE_TERMIOS
 }
 
-bool Terminal::SetCanonical(bool enabled) {
-  if (FileDescriptorIsValid()) {
+llvm::Error Terminal::SetData(const Terminal::Data ) {
 #if LLDB_ENABLE_TERMIOS
-if (IsATerminal()) {
-  struct termios fd_termios;
-  if (::tcgetattr(m_fd, _termios) == 0) {
-bool set_corectly = false;
-if 

[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39f2b059633e: [lldb] [Host] Make Terminal methods return 
llvm::Error (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111890

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Target/Process.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -51,11 +51,11 @@
 TEST_F(TerminalTest, SetEcho) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetEcho(true), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ECHO, 0U);
 
-  ASSERT_EQ(m_term.SetEcho(false), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ECHO, 0U);
 }
@@ -63,11 +63,11 @@
 TEST_F(TerminalTest, SetCanonical) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetCanonical(true), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ICANON, 0U);
 
-  ASSERT_EQ(m_term.SetCanonical(false), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -4349,8 +4349,9 @@
 const int read_fd = m_read_file.GetDescriptor();
 Terminal terminal(read_fd);
 TerminalState terminal_state(terminal, false);
-terminal.SetCanonical(false);
-terminal.SetEcho(false);
+// FIXME: error handling?
+llvm::consumeError(terminal.SetCanonical(false));
+llvm::consumeError(terminal.SetEcho(false));
 // FD_ZERO, FD_SET are not supported on windows
 #ifndef _WIN32
 const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -435,8 +435,9 @@
 TerminalState terminal_state(terminal);
 
 if (terminal.IsATerminal()) {
-  terminal.SetCanonical(false);
-  terminal.SetEcho(true);
+  // FIXME: error handling?
+  llvm::consumeError(terminal.SetCanonical(false));
+  llvm::consumeError(terminal.SetEcho(true));
 }
 
 ScriptInterpreterPythonImpl::Locker locker(
Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -21,71 +21,78 @@
 
 using namespace lldb_private;
 
+struct Terminal::Data {
+#if LLDB_ENABLE_TERMIOS
+  struct termios m_termios; ///< Cached terminal state information.
+#endif
+};
+
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
-bool Terminal::SetEcho(bool enabled) {
-  if (FileDescriptorIsValid()) {
+llvm::Expected Terminal::GetData() {
+  if (!FileDescriptorIsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid fd");
+
 #if LLDB_ENABLE_TERMIOS
-if (IsATerminal()) {
-  struct termios fd_termios;
-  if (::tcgetattr(m_fd, _termios) == 0) {
-bool set_corectly = false;
-if (enabled) {
-  if (fd_termios.c_lflag & ECHO)
-set_corectly = true;
-  else
-fd_termios.c_lflag |= ECHO;
-} else {
-  if (fd_termios.c_lflag & ECHO)
-fd_termios.c_lflag &= ~ECHO;
-  else
-set_corectly = true;
-}
-
-if (set_corectly)
-  return true;
-return ::tcsetattr(m_fd, TCSANOW, _termios) == 0;
-  }
-}
-#endif // #if LLDB_ENABLE_TERMIOS
-  }
-  return false;
+  if (!IsATerminal())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "fd not a terminal");
+
+  Data data;
+  if (::tcgetattr(m_fd, _termios) != 0)
+return llvm::createStringError(
+std::error_code(errno, std::generic_category()),
+"unable to get teletype attributes");
+  return data;
+#else // !LLDB_ENABLE_TERMIOS
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ 

[Lldb-commits] [lldb] 7dfb139 - [lldb] Adjust udt-layout.test after MS mangling change

2021-10-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-19T12:43:24+02:00
New Revision: 7dfb1395549c34f4b607055c01f8c510ead6b0db

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

LOG: [lldb] Adjust udt-layout.test after MS mangling change

The demangled name no longer contains the redundant name since D111715.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/PDB/udt-layout.test

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test 
b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
index 0ee9dcf6771bd..f114c200d0219 100644
--- a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
+++ b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
@@ -2,7 +2,7 @@ REQUIRES: system-windows, lld
 RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
 RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
 
-CHECK:(int) int C::abc = 123
+CHECK:(int) C::abc = 123
 CHECK:(List [16]) ls = {
 CHECK:  [15] = {
 CHECK:Prev = nullptr



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


[Lldb-commits] [PATCH] D112061: [lldb] Remove ConstString from GetPluginNameStatic of some plugins

2021-10-19 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
Herald added subscribers: sbc100, emaste.
labath requested review of this revision.
Herald added subscribers: MaskRay, aheejin.
Herald added a project: LLDB.

This patch deals with ObjectFile, ObjectContainer and OperatingSystem
plugins. I'll convert the other types in separate patches.

In order to enable piecemeal conversion, I am leaving some ConstStrings
in the lowest PluginManager layers. I'll convert those as the last step.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112061

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Core/PluginManager.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
  
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
  
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp
  lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
  lldb/source/Target/OperatingSystem.cpp

Index: lldb/source/Target/OperatingSystem.cpp
===
--- lldb/source/Target/OperatingSystem.cpp
+++ lldb/source/Target/OperatingSystem.cpp
@@ -17,10 +17,9 @@
  const char *plugin_name) {
   OperatingSystemCreateInstance create_callback = nullptr;
   if (plugin_name) {
-ConstString const_plugin_name(plugin_name);
 create_callback =
 PluginManager::GetOperatingSystemCreateCallbackForPluginName(
-const_plugin_name);
+plugin_name);
 if (create_callback) {
   std::unique_ptr instance_up(
   create_callback(process, true));
Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
===
--- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
+++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
@@ -36,14 +36,12 @@
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "python"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
   // lldb_private::PluginInterface Methods
-  llvm::StringRef GetPluginName() override {
-return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   // lldb_private::OperatingSystem Methods
   bool UpdateThreadList(lldb_private::ThreadList _thread_list,
Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
===
--- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -65,12 +65,7 @@
   return nullptr;
 }
 
-ConstString OperatingSystemPython::GetPluginNameStatic() {
-  static ConstString g_name("python");
-  return g_name;
-}
-
-const char *OperatingSystemPython::GetPluginDescriptionStatic() {
+llvm::StringRef OperatingSystemPython::GetPluginDescriptionStatic() {
   return "Operating system plug-in that gathers OS information from a python "
  "class that implements the necessary OperatingSystem functionality.";
 }
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
@@ -24,7 +24,7 @@
   static void Initialize();
   static void Terminate();
 
-  static ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "wasm"; }
   static const 

[Lldb-commits] [lldb] ee11612 - Revert "[lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*"

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

Author: Michał Górny
Date: 2021-10-19T12:31:25+02:00
New Revision: ee11612ee10edd0d1f219c302f1a0abe0b46ddb3

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

LOG: Revert "[lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*"

This reverts commit 5352ea4a721ef252129994111b83dc350ecc71da.  It seems
to have broken the arm buildbot.

Added: 


Modified: 
lldb/include/lldb/lldb-private-types.h
lldb/source/Plugins/ABI/X86/ABIX86.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/DynamicRegisterInfo.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index 3be7003cd0fb2..5e71b68630a95 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -51,10 +51,8 @@ struct RegisterInfo {
   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
   /// not null, all registers in this list will be read first, at which point
   /// the value for this register will be valid. For example, the value list
-  /// for ah would be eax (x86) or rax (x64). Register numbers are
-  /// of eRegisterKindLLDB. If multiple registers are listed, the final
-  /// value will be the concatenation of them.
-  uint32_t *value_regs;
+  /// for ah would be eax (x86) or rax (x64).
+  uint32_t *value_regs; //
   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
   /// not null, all registers in this list will be invalidated when the value 
of
   /// this register changes. For example, the invalidate list for eax would be

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp 
b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index 544efc298cd87..0286140e4e24c 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -33,40 +33,36 @@ void ABIX86::Terminate() {
   ABIWindows_x86_64::Terminate();
 }
 
-namespace {
-enum RegKind {
-  GPR32,
+enum class RegKind {
+  GPR32 = 0,
   GPR16,
   GPR8h,
   GPR8,
-  MM,
-  YMM_YMMh,
-  YMM_XMM,
 
-  RegKindCount
-};
-};
-
-struct RegData {
-  RegKind subreg_kind;
-  llvm::StringRef subreg_name;
-  llvm::Optional base_index;
+  MM = 0,
 };
 
-static void
-addPartialRegisters(std::vector ,
-llvm::ArrayRef subregs, uint32_t base_size,
-lldb::Encoding encoding, lldb::Format format,
-uint32_t subreg_size, uint32_t subreg_offset = 0) {
-  for (const RegData *subreg : subregs) {
-assert(subreg);
-uint32_t base_index = subreg->base_index.getValue();
+typedef llvm::SmallDenseMap, 16>
+RegisterMap;
+
+static void addPartialRegisters(
+std::vector ,
+llvm::ArrayRef base_reg_indices, const RegisterMap _names,
+uint32_t base_size, RegKind name_index, lldb::Encoding encoding,
+lldb::Format format, uint32_t subreg_size, uint32_t subreg_offset = 0) {
+  for (uint32_t base_index : base_reg_indices) {
+if (base_index == LLDB_INVALID_REGNUM)
+  break;
+assert(base_index < regs.size());
 DynamicRegisterInfo::Register _reg = regs[base_index];
-if (full_reg.byte_size != base_size)
+llvm::StringRef subreg_name = reg_names.lookup(
+full_reg.name.GetStringRef())[static_cast(name_index)];
+if (subreg_name.empty() || full_reg.byte_size != base_size)
   continue;
 
-lldb_private::DynamicRegisterInfo::Register new_reg{
-lldb_private::ConstString(subreg->subreg_name),
+lldb_private::DynamicRegisterInfo::Register subreg{
+lldb_private::ConstString(subreg_name),
 lldb_private::ConstString(),
 lldb_private::ConstString("supplementary registers"),
 subreg_size,
@@ -81,112 +77,10 @@ 
addPartialRegisters(std::vector ,
 {},
 subreg_offset};
 
-addSupplementaryRegister(regs, new_reg);
-  }
-}
-
-static void
-addCombinedRegisters(std::vector ,
- llvm::ArrayRef subregs1,
- llvm::ArrayRef subregs2, uint32_t base_size,
- lldb::Encoding encoding, lldb::Format format) {
-  for (auto it : llvm::zip(subregs1, subregs2)) {
-RegData *regdata1, *regdata2;
-std::tie(regdata1, regdata2) = it;
-assert(regdata1);
-assert(regdata2);
-
-// verify that we've got matching target registers
-if (regdata1->subreg_name != regdata2->subreg_name)
-  continue;
-
-uint32_t base_index1 = regdata1->base_index.getValue();
-uint32_t base_index2 = regdata2->base_index.getValue();
-if (regs[base_index1].byte_size != base_size ||
-regs[base_index2].byte_size != 

[Lldb-commits] [PATCH] D111989: [lldb] Reduce code duplication around inferior building

2021-10-19 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bac18be0e45: [lldb] Reduce code duplication around inferior 
building (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111989

Files:
  lldb/docs/testsuite/a-detailed-walkthrough.txt
  lldb/packages/Python/lldbsuite/test/README-TestSuite
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/builders/darwin.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
  
lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
  lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
  lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py

Index: lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
===
--- lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
+++ lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
@@ -21,7 +21,7 @@
 @no_debug_info_test  # Prevent the genaration of the dwarf version of this test
 def test_add_dsym_mid_execution(self):
 """Test that add-dsym mid-execution loads the symbols at the right place for a slid binary."""
-self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
+self.build(debug_info="dsym")
 exe = self.getBuildArtifact("a.out")
 
 self.target = self.dbg.CreateTarget(exe)
Index: lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
===
--- lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
+++ lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
@@ -54,7 +54,7 @@
 os.path.basename(self.exe))
 self.dsym_for_uuid = self.getBuildArtifact("dsym-for-uuid.sh")
 
-self.buildDefault(dictionary={'MAKE_DSYM': 'YES'})
+self.build(debug_info="dsym")
 self.assertTrue(os.path.exists(self.exe))
 self.assertTrue(os.path.exists(self.dsym))
 
Index: lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
===
--- lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
+++ lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
@@ -77,7 +77,7 @@
 return pwd_symlink
 
 def doBuild(self, pwd_symlink, setting_value):
-self.build(None, None, {'PWD': pwd_symlink})
+self.build(dictionary={'PWD': pwd_symlink})
 
 if setting_value:
 cmd = "settings set %s '%s'" % (_COMP_DIR_SYM_LINK_PROP, setting_value)
Index: lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
===
--- lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
+++ lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
@@ -27,14 +27,14 @@
 
 # Call the program generator to produce main.cpp, version 1.
 self.generate_main_cpp(version=1)
-self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
+self.build(debug_info="dsym")
 
 # Insert some delay and then call the program generator to produce
 # main.cpp, version 2.
 time.sleep(5)
 self.generate_main_cpp(version=101)
 # Now call make again, but this time don't generate the dSYM.
-self.buildDefault(dictionary={'MAKE_DSYM':'NO'})
+self.build(debug_info="dwarf")
 
 self.exe_name = 'a.out'
 self.do_add_dsym_with_error(self.exe_name)
@@ -45,7 +45,7 @@
 
 # Call the program generator to produce main.cpp, version 1.
 self.generate_main_cpp(version=1)
-self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
+self.build(debug_info="dsym")
 
 self.exe_name = 'a.out'
 self.do_add_dsym_with_success(self.exe_name)
@@ -56,7 +56,7 @@
 
 # Call the program generator to produce main.cpp, version 1.
 self.generate_main_cpp(version=1)
-self.buildDefault(dictionary={'MAKE_DSYM':'YES'})
+self.build(debug_info="dsym")
 
 self.exe_name = 'a.out'
 self.do_add_dsym_with_dSYM_bundle(self.exe_name)
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -162,9 +162,6 @@
 self._verbose_log_handler = None
 TestBase.tearDown(self)
 
-def build(self, *args, **kwargs):
-self.buildDefault(*args, **kwargs)
-
 def getLocalServerLogFile(self):
 

[Lldb-commits] [lldb] 8bac18b - [lldb] Reduce code duplication around inferior building

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

Author: Pavel Labath
Date: 2021-10-19T12:09:41+02:00
New Revision: 8bac18be0e45adc7b096375bf4f65635fb994df0

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

LOG: [lldb] Reduce code duplication around inferior building

We had two sets of build methods, whose bodies were largely
identical. This makes any kind of modification in their vicinity
repetitive and error-prone.

Replace each set with a single method taking an optional debug_info
parameter.

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

Added: 


Modified: 
lldb/docs/testsuite/a-detailed-walkthrough.txt
lldb/packages/Python/lldbsuite/test/README-TestSuite
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/builders/darwin.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py

lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py

Removed: 




diff  --git a/lldb/docs/testsuite/a-detailed-walkthrough.txt 
b/lldb/docs/testsuite/a-detailed-walkthrough.txt
index fff5a40d1da77..8d374d5d81ea0 100644
--- a/lldb/docs/testsuite/a-detailed-walkthrough.txt
+++ b/lldb/docs/testsuite/a-detailed-walkthrough.txt
@@ -73,7 +73,7 @@ Now let's look inside the test method:
 
 def test_set_output_path(self):
 """Test that setting target.process.output-path for the launched 
process works."""
-self.buildDefault()
+self.build()
 
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -96,49 +96,12 @@ Now let's look inside the test method:
 self.expect(output, exe=False,
 startstr = "This message should go to standard out.")
 
-The self.buildDefault() statement is used to build a default binary for this
-test instance.  For this particular test case, since we don't really care what
-debugging format is used, we instruct the build subsystem to build the default
-binary for us.  The base class TestBase has defined three instance methods:
-
-def buildDefault(self, architecture=None, compiler=None, dictionary=None):
-"""Platform specific way to build the default binaries."""
-module = __import__(sys.platform)
-if not module.buildDefault(self, architecture, compiler, dictionary):
-raise Exception("Don't know how to build default binary")
-
-def buildDsym(self, architecture=None, compiler=None, dictionary=None):
-"""Platform specific way to build binaries with dsym info."""
-module = __import__(sys.platform)
-if not module.buildDsym(self, architecture, compiler, dictionary):
-raise Exception("Don't know how to build binary with dsym")
-
-def buildDwarf(self, architecture=None, compiler=None, dictionary=None):
-"""Platform specific way to build binaries with dwarf maps."""
-module = __import__(sys.platform)
-if not module.buildDwarf(self, architecture, compiler, dictionary):
-raise Exception("Don't know how to build binary with dwarf")
-
-And the test/plugins/darwin.py provides the implementation for all three build
-methods using the makefile mechanism.  We envision that linux plugin can use a
-similar approach to accomplish the task of building the binaries.
-
-macOS provides an additional way to manipulate archived DWARF debug symbol
-files and produces dSYM files.  The buildDsym() instance method is used by the
-test method to build the binary with dsym info.  For an example of this,
-see test/array_types/TestArrayTypes.py:
-
-@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
-def test_with_dsym_and_run_command(self):
-"""Test 'frame variable var_name' on some variables with array 
types."""
-self.buildDsym()
-self.array_types()
-
-This method is decorated with a skipUnless decorator so that it will only gets
-included into the test suite if the platform it is running on is 'darwin', 
a.k.a.
-macOS.
-
-Type 'man dsymutil' for more details. 
+The self.build() statement is used to build a binary for this
+test instance. This will build the binary for the current debug info format. If
+we wanted to avoid running the test for every supported debug info format we
+could annotate it with @no_debug_info_test. The test would then only be run for
+the default format.  The logic for building a test binary resides in the 
builder
+modules (packages/Python/lldbsuite/test/builders/builder.py)
 
 After the binary is built, it 

[Lldb-commits] [PATCH] D111936: [lldb] Allow dumping the state of all scratch TypeSystems

2021-10-19 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a57d1e52680: [lldb] Allow dumping the state of all scratch 
TypeSystems (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111936

Files:
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/API/commands/target/dump/Makefile
  lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
  lldb/test/API/commands/target/dump/main.cpp

Index: lldb/test/API/commands/target/dump/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/target/dump/main.cpp
@@ -0,0 +1,7 @@
+struct DummyStruct {
+  int i;
+};
+
+DummyStruct s;
+
+int main() { return s.i; }
Index: lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
===
--- /dev/null
+++ lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
@@ -0,0 +1,33 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test_dumping(self):
+""" Tests dumping an empty and non-empty scratch AST. """
+self.build()
+self.createTestTarget()
+
+# Make sure DummyStruct is not in the scratch AST by default.
+self.expect("target dump typesystem", matching=False, substrs=["struct DummyStruct"])
+
+# Move DummyStruct into the scratch AST via the expression evaluator.
+# FIXME: Once there is an SB API for using variable paths on globals
+# then this should be done this way.
+self.expect_expr("s", result_type="DummyStruct")
+
+# Dump the scratch AST and make sure DummyStruct is in there.
+self.expect("target dump typesystem", substrs=["struct DummyStruct"])
+
+@no_debug_info_test
+def test_invalid_arg(self):
+""" Test an invalid invocation on 'target dump typesystem'. """
+self.build()
+self.createTestTarget()
+self.expect("target dump typesystem arg", error=True,
+substrs=["error: target dump typesystem doesn't take arguments."])
Index: lldb/test/API/commands/target/dump/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/target/dump/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -938,7 +938,8 @@
   LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
 #endif
 
-  void Dump(Stream );
+  /// \see lldb_private::TypeSystem::Dump
+  void Dump(llvm::raw_ostream ) override;
 
   /// Dump clang AST types from the symbol file.
   ///
@@ -1162,6 +1163,9 @@
 return GetForTarget(target, InferIsolatedASTKindFromLangOpts(lang_opts));
   }
 
+  /// \see lldb_private::TypeSystem::Dump
+  void Dump(llvm::raw_ostream ) override;
+
   UserExpression *
   GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
 lldb::LanguageType language,
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -8358,9 +8358,8 @@
 }
 #endif
 
-void TypeSystemClang::Dump(Stream ) {
-  Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl());
-  tu->dump(s.AsRawOstream());
+void TypeSystemClang::Dump(llvm::raw_ostream ) {
+  GetTranslationUnitDecl()->dump(output);
 }
 
 void TypeSystemClang::DumpFromSymbolFile(Stream ,
@@ -9746,6 +9745,41 @@
   return _ast.GetIsolatedAST(*ast_kind);
 }
 
+/// Returns a human-readable name that uniquely identifiers the sub-AST kind.
+static llvm::StringRef
+GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind) {
+  switch (kind) {
+  case ScratchTypeSystemClang::IsolatedASTKind::CppModules:
+return "C++ modules";
+  }
+  llvm_unreachable("Unimplemented IsolatedASTKind?");
+}
+
+void ScratchTypeSystemClang::Dump(llvm::raw_ostream ) {
+  // First dump the main scratch AST.
+  output << "State of scratch Clang type 

[Lldb-commits] [lldb] 9a57d1e - [lldb] Allow dumping the state of all scratch TypeSystems

2021-10-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-19T12:05:14+02:00
New Revision: 9a57d1e52680ac05c29d6d0d2cfbaf3b05a5cbce

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

LOG: [lldb] Allow dumping the state of all scratch TypeSystems

This adds the `target dump typesystem'`command which dumps the TypeSystem of the
target itself (aka the 'scratch TypeSystem'). This is similar to `target modules
dump ast` which dumps the AST of lldb::Modules associated with a selected
target.

Unlike `target modules dump ast`, the new command is not a subcommand of `target
modules dump` as it's not touching the modules of a target at all. Also unlike
`target modules dump ast` I tried to keep the implementation language-neutral,
so this patch moves our Clang `Dump` to the `TypeSystem` interface so it will
also dump the state of any future/downstream scratch TypeSystems (e.g., Swift).
That's also why the command just refers to a 'typesystem' instead of an 'ast'
(which is only how Clang is necessarily modelling the internal TypeSystem
state).

The main motivation for this patch is that I need to write some tests that check
for duplicates in the ScratchTypeSystemClang of a target. There is currently no
way to check for this at the moment (beside measuring memory consumption of
course). It's probably also useful for debugging LLDB itself.

Reviewed By: labath

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

Added: 
lldb/test/API/commands/target/dump/Makefile
lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
lldb/test/API/commands/target/dump/main.cpp

Modified: 
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index a37c1040b16e7..e695f65807671 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -392,6 +392,12 @@ class TypeSystem : public PluginInterface {
   lldb::opaque_compiler_type_t type, Stream *s,
   lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0;
 
+  /// Dump a textual representation of the internal TypeSystem state to the
+  /// given stream.
+  ///
+  /// This should not modify the state of the TypeSystem if possible.
+  virtual void Dump(llvm::raw_ostream ) = 0;
+
   // TODO: These methods appear unused. Should they be removed?
 
   virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0;

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3112216f8a352..e0a88a710fb97 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4990,6 +4990,55 @@ class CommandObjectMultiwordTargetStopHooks : public 
CommandObjectMultiword {
   ~CommandObjectMultiwordTargetStopHooks() override = default;
 };
 
+#pragma mark CommandObjectTargetDumpTypesystem
+
+/// Dumps the TypeSystem of the selected Target.
+class CommandObjectTargetDumpTypesystem : public CommandObjectParsed {
+public:
+  CommandObjectTargetDumpTypesystem(CommandInterpreter )
+  : CommandObjectParsed(
+interpreter, "target dump typesystem",
+"Dump the state of the target's internal type system.\n"
+"Intended to be used for debugging LLDB itself.",
+nullptr, eCommandRequiresTarget) {}
+
+  ~CommandObjectTargetDumpTypesystem() override = default;
+
+protected:
+  bool DoExecute(Args , CommandReturnObject ) override {
+if (!command.empty()) {
+  result.AppendError("target dump typesystem doesn't take arguments.");
+  return result.Succeeded();
+}
+
+// Go over every scratch TypeSystem and dump to the command output.
+for (TypeSystem *ts : GetSelectedTarget().GetScratchTypeSystems())
+  ts->Dump(result.GetOutputStream().AsRawOstream());
+
+result.SetStatus(eReturnStatusSuccessFinishResult);
+return result.Succeeded();
+  }
+};
+
+#pragma mark CommandObjectTargetDump
+
+/// Multi-word command for 'target dump'.
+class CommandObjectTargetDump : public CommandObjectMultiword {
+public:
+  // Constructors and Destructors
+  CommandObjectTargetDump(CommandInterpreter )
+  : CommandObjectMultiword(
+interpreter, "target dump",
+"Commands for dumping information about the target.",
+"target dump [typesystem]") {
+LoadSubCommand(
+"typesystem",
+

[Lldb-commits] [lldb] 134e181 - [lldb] change name demangling to be consistent between windows and linx

2021-10-19 Thread Andy Yankovsky via lldb-commits

Author: Lasse Folger
Date: 2021-10-19T12:04:37+02:00
New Revision: 134e1817f62c08cde1ed1f7e94e51425536085ac

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

LOG: [lldb] change name demangling to be consistent between windows and linx

When printing names in lldb on windows these names contain the full type 
information while on linux only the name is contained.

This change introduces a flag in the Microsoft demangler to control if the type 
information should be included.
With the flag enabled demangled name contains only the qualified name, e.g:
without flag -> with flag
int (*array2d)[10] -> array2d
int (*abc::array2d)[10] -> abc::array2d
const int *x -> x

For globals there is a second inconsistency which is not yet addressed by this 
change. On linux globals (in global namespace) are prefixed with :: while on 
windows they are not.

Reviewed By: teemperor, rnk

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

Added: 


Modified: 
lldb/source/Core/Mangled.cpp
llvm/include/llvm/Demangle/Demangle.h
llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
llvm/test/Demangle/ms-options.test
llvm/tools/llvm-undname/llvm-undname.cpp

Removed: 




diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 35b1082c3025d..e36d412896a93 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -131,9 +131,9 @@ void Mangled::SetValue(ConstString name) {
 static char *GetMSVCDemangledStr(const char *M) {
   char *demangled_cstr = llvm::microsoftDemangle(
   M, nullptr, nullptr, nullptr, nullptr,
-  llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
-llvm::MSDF_NoCallingConvention |
-llvm::MSDF_NoMemberType));
+  llvm::MSDemangleFlags(
+  llvm::MSDF_NoAccessSpecifier | llvm::MSDF_NoCallingConvention |
+  llvm::MSDF_NoMemberType | llvm::MSDF_NoVariableType));
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) 
{
 if (demangled_cstr && demangled_cstr[0])

diff  --git a/llvm/include/llvm/Demangle/Demangle.h 
b/llvm/include/llvm/Demangle/Demangle.h
index 8d61fa1c17f2f..521795f7a1f81 100644
--- a/llvm/include/llvm/Demangle/Demangle.h
+++ b/llvm/include/llvm/Demangle/Demangle.h
@@ -38,6 +38,7 @@ enum MSDemangleFlags {
   MSDF_NoCallingConvention = 1 << 2,
   MSDF_NoReturnType = 1 << 3,
   MSDF_NoMemberType = 1 << 4,
+  MSDF_NoVariableType = 1 << 5,
 };
 
 /// Demangles the Microsoft symbol pointed at by mangled_name and returns it.

diff  --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h 
b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
index 77446e9b0f079..7f3ee5a1d487f 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -80,6 +80,7 @@ enum OutputFlags {
   OF_NoAccessSpecifier = 4,
   OF_NoMemberType = 8,
   OF_NoReturnType = 16,
+  OF_NoVariableType = 32,
 };
 
 // Types

diff  --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp 
b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index 303207176be71..15d7056b29cb1 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -2361,6 +2361,8 @@ char *llvm::microsoftDemangle(const char *MangledName, 
size_t *NMangled,
 OF = OutputFlags(OF | OF_NoReturnType);
   if (Flags & MSDF_NoMemberType)
 OF = OutputFlags(OF | OF_NoMemberType);
+  if (Flags & MSDF_NoVariableType)
+OF = OutputFlags(OF | OF_NoVariableType);
 
   int InternalStatus = demangle_success;
   if (D.Error)

diff  --git a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp 
b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
index 9fe157bf0d2aa..56a07377c92ad 100644
--- a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
@@ -613,12 +613,12 @@ void VariableSymbolNode::output(OutputStream , 
OutputFlags Flags) const {
   if (!(Flags & OF_NoMemberType) && IsStatic)
 OS << "static ";
 
-  if (Type) {
+  if (!(Flags & OF_NoVariableType) && Type) {
 Type->outputPre(OS, Flags);
 outputSpaceIfNecessary(OS);
   }
   Name->output(OS, Flags);
-  if (Type)
+  if (!(Flags & OF_NoVariableType) && Type)
 Type->outputPost(OS, Flags);
 }
 

diff  --git a/llvm/test/Demangle/ms-options.test 
b/llvm/test/Demangle/ms-options.test
index 1699ad6f558a5..94663a5f9fc46 100644
--- a/llvm/test/Demangle/ms-options.test
+++ b/llvm/test/Demangle/ms-options.test
@@ -1,14 +1,43 @@
-; RUN: llvm-undname < %s | FileCheck %s
-; RUN: llvm-undname --no-calling-convention < %s | FileCheck %s 
--check-prefix=CHECK-NO-CALLING-CONV
-; RUN: llvm-undname --no-return-type < %s 

[Lldb-commits] [PATCH] D111715: [WIP] [lldb] change name demangling to be consistent between windows and linx

2021-10-19 Thread Andy Yankovsky via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG134e1817f62c: [lldb] change name demangling to be consistent 
between windows and linx (authored by lassefolger, committed by werat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111715

Files:
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
  llvm/test/Demangle/ms-options.test
  llvm/tools/llvm-undname/llvm-undname.cpp

Index: llvm/tools/llvm-undname/llvm-undname.cpp
===
--- llvm/tools/llvm-undname/llvm-undname.cpp
+++ llvm/tools/llvm-undname/llvm-undname.cpp
@@ -46,6 +46,9 @@
 cl::opt NoMemberType("no-member-type", cl::Optional,
cl::desc("skip member types"), cl::Hidden,
cl::init(false), cl::cat(UndNameCategory));
+cl::opt NoVariableType("no-variable-type", cl::Optional,
+ cl::desc("skip variable types"), cl::Hidden,
+ cl::init(false), cl::cat(UndNameCategory));
 cl::opt RawFile("raw-file", cl::Optional,
  cl::desc("for fuzzer data"), cl::Hidden,
  cl::cat(UndNameCategory));
@@ -68,6 +71,8 @@
 Flags = MSDemangleFlags(Flags | MSDF_NoReturnType);
   if (NoMemberType)
 Flags = MSDemangleFlags(Flags | MSDF_NoMemberType);
+  if (NoVariableType)
+Flags = MSDemangleFlags(Flags | MSDF_NoVariableType);
 
   size_t NRead;
   char *ResultBuf =
Index: llvm/test/Demangle/ms-options.test
===
--- llvm/test/Demangle/ms-options.test
+++ llvm/test/Demangle/ms-options.test
@@ -1,14 +1,43 @@
-; RUN: llvm-undname < %s | FileCheck %s
-; RUN: llvm-undname --no-calling-convention < %s | FileCheck %s --check-prefix=CHECK-NO-CALLING-CONV
-; RUN: llvm-undname --no-return-type < %s | FileCheck %s --check-prefix=CHECK-NO-RETURN
-; RUN: llvm-undname --no-access-specifier < %s | FileCheck %s --check-prefix=CHECK-NO-ACCESS
-; RUN: llvm-undname --no-member-type < %s | FileCheck %s --check-prefix=CHECK-NO-MEMBER-TYPE
-; RUN: llvm-undname --no-calling-convention --no-return-type --no-access-specifier --no-member-type < %s | FileCheck %s --check-prefix=CHECK-NO-ALL
-
-?func@MyClass@@UEAAHHH@Z
-; CHECK: public: virtual int __cdecl MyClass::func(int, int)
-; CHECK-NO-CALLING-CONV: public: virtual int MyClass::func(int, int)
-; CHECK-NO-RETURN: public: virtual __cdecl MyClass::func(int, int)
-; CHECK-NO-ACCESS: {{^}}virtual int __cdecl MyClass::func(int, int)
-; CHECK-NO-MEMBER-TYPE: public: int __cdecl MyClass::func(int, int)
-; CHECK-NO-ALL: {{^}}MyClass::func(int, int)
+; RUN: llvm-undname < %s | FileCheck %s
+; RUN: llvm-undname --no-calling-convention < %s | FileCheck %s --check-prefix=CHECK-NO-CALLING-CONV
+; RUN: llvm-undname --no-return-type < %s | FileCheck %s --check-prefix=CHECK-NO-RETURN
+; RUN: llvm-undname --no-access-specifier < %s | FileCheck %s --check-prefix=CHECK-NO-ACCESS
+; RUN: llvm-undname --no-member-type < %s | FileCheck %s --check-prefix=CHECK-NO-MEMBER-TYPE
+; RUN: llvm-undname --no-variable-type < %s | FileCheck %s --check-prefix=CHECK-NO-VARIABLE-TYPE
+; RUN: llvm-undname --no-calling-convention --no-return-type --no-access-specifier --no-member-type --no-variable-type < %s | FileCheck %s --check-prefix=CHECK-NO-ALL
+
+?func@MyClass@@UEAAHHH@Z
+; CHECK: public: virtual int __cdecl MyClass::func(int, int)
+; CHECK-NO-CALLING-CONV: public: virtual int MyClass::func(int, int)
+; CHECK-NO-RETURN: public: virtual __cdecl MyClass::func(int, int)
+; CHECK-NO-ACCESS: {{^}}virtual int __cdecl MyClass::func(int, int)
+; CHECK-NO-MEMBER-TYPE: public: int __cdecl MyClass::func(int, int)
+; CHECK-NO-VARIABLE-TYPE: public: virtual int __cdecl MyClass::func(int, int)
+; CHECK-NO-ALL: {{^}}MyClass::func(int, int)
+
+?array2d@@3PAY09HA
+; CHECK: int (*array2d)[10]
+; CHECK-NO-CALLING-CONV: int (*array2d)[10]
+; CHECK-NO-RETURN: int (*array2d)[10]
+; CHECK-NO-ACCESS: int (*array2d)[10]
+; CHECK-NO-MEMBER-TYPE: int (*array2d)[10]
+; CHECK-NO-VARIABLE-TYPE: array2d
+; CHECK-NO-ALL: array2d
+
+?a@abc@@3PAY09HA
+; CHECK: int (*abc::a)[10]
+; CHECK-NO-CALLING-CONV: int (*abc::a)[10]
+; CHECK-NO-RETURN: int (*abc::a)[10]
+; CHECK-NO-ACCESS: int (*abc::a)[10]
+; CHECK-NO-MEMBER-TYPE: int (*abc::a)[10]
+; CHECK-NO-VARIABLE-TYPE: abc::a
+; CHECK-NO-ALL: abc::a
+
+?x@@3PEAEEA
+; CHECK: unsigned char *x
+; CHECK-NO-CALLING-CONV: unsigned char *x
+; CHECK-NO-RETURN: unsigned char *x
+; CHECK-NO-ACCESS: unsigned char *x
+; CHECK-NO-MEMBER-TYPE: unsigned char *x
+; CHECK-NO-VARIABLE-TYPE: x
+; CHECK-NO-ALL: x
Index: llvm/lib/Demangle/MicrosoftDemangleNodes.cpp

[Lldb-commits] [PATCH] D111931: [lldb] Filter duplicates in Target::GetScratchTypeSystems

2021-10-19 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcfaa5c344d5b: [lldb] Filter duplicates in 
Target::GetScratchTypeSystems (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111931

Files:
  lldb/source/Target/Target.cpp
  lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py


Index: lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
@@ -0,0 +1,20 @@
+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__)
+
+@no_debug_info_test
+def test_FindTypes_on_scratch_AST(self):
+"""
+Tests FindTypes invoked with only LLDB's scratch AST present.
+"""
+target = self.dbg.GetDummyTarget()
+# There should be only one instance of 'unsigned long' in our single
+# scratch AST. Note: FindTypes/SBType hahave no filter by language, so
+# pick something that is unlikely to also be found in the scratch
+# TypeSystem of other language plugins.
+self.assertEqual(len(target.FindTypes("unsigned long")), 1)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -60,6 +60,7 @@
 #include "lldb/Utility/Timer.h"
 
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/SetVector.h"
 
 #include 
 #include 
@@ -2231,7 +2232,10 @@
   if (!m_valid)
 return {};
 
-  std::vector scratch_type_systems;
+  // Some TypeSystem instances are associated with several LanguageTypes so
+  // they will show up several times in the loop below. The SetVector filters
+  // out all duplicates as they serve no use for the caller.
+  llvm::SetVector scratch_type_systems;
 
   LanguageSet languages_for_expressions =
   Language::GetLanguagesSupportingTypeSystemsForExpressions();
@@ -2247,10 +2251,10 @@
  "system available",
  Language::GetNameForLanguageType(language));
 else
-  scratch_type_systems.emplace_back(_system_or_err.get());
+  scratch_type_systems.insert(_system_or_err.get());
   }
 
-  return scratch_type_systems;
+  return scratch_type_systems.takeVector();
 }
 
 PersistentExpressionState *


Index: lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
@@ -0,0 +1,20 @@
+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__)
+
+@no_debug_info_test
+def test_FindTypes_on_scratch_AST(self):
+"""
+Tests FindTypes invoked with only LLDB's scratch AST present.
+"""
+target = self.dbg.GetDummyTarget()
+# There should be only one instance of 'unsigned long' in our single
+# scratch AST. Note: FindTypes/SBType hahave no filter by language, so
+# pick something that is unlikely to also be found in the scratch
+# TypeSystem of other language plugins.
+self.assertEqual(len(target.FindTypes("unsigned long")), 1)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -60,6 +60,7 @@
 #include "lldb/Utility/Timer.h"
 
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/SetVector.h"
 
 #include 
 #include 
@@ -2231,7 +2232,10 @@
   if (!m_valid)
 return {};
 
-  std::vector scratch_type_systems;
+  // Some TypeSystem instances are associated with several LanguageTypes so
+  // they will show up several times in the loop below. The SetVector filters
+  // out all duplicates as they serve no use for the caller.
+  llvm::SetVector scratch_type_systems;
 
   LanguageSet languages_for_expressions =
   Language::GetLanguagesSupportingTypeSystemsForExpressions();
@@ -2247,10 +2251,10 @@
  "system available",
  Language::GetNameForLanguageType(language));
 else
-  scratch_type_systems.emplace_back(_system_or_err.get());
+  scratch_type_systems.insert(_system_or_err.get());
   }
 
-  return scratch_type_systems;
+  return scratch_type_systems.takeVector();
 }
 
 PersistentExpressionState *
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] cfaa5c3 - [lldb] Filter duplicates in Target::GetScratchTypeSystems

2021-10-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-19T11:49:47+02:00
New Revision: cfaa5c344d5bc73aae0ec39d57d98acf7463fccf

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

LOG: [lldb] Filter duplicates in Target::GetScratchTypeSystems

`Target::GetScratchTypeSystems` returns the list of scratch TypeSystems. The
current implementation is iterating over all LanguageType values and retrieves
the respective TypeSystem for each LanguageType.

All C/C++/Obj-C LanguageTypes are however mapped to the same
ScratchTypeSystemClang instance, so the current implementation adds this single
TypeSystem instance several times to the list of TypeSystems (once for every
LanguageType that we support).

The only observable effect of this is that `SBTarget.FindTypes` for builtin
types currently queries the ScratchTypeSystemClang several times (and also adds
the same result several times).

Reviewed By: bulbazord, labath

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

Added: 
lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py

Modified: 
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 995527e2e8da1..7f39da697eb0f 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -60,6 +60,7 @@
 #include "lldb/Utility/Timer.h"
 
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/SetVector.h"
 
 #include 
 #include 
@@ -2231,7 +2232,10 @@ std::vector 
Target::GetScratchTypeSystems(bool create_on_demand) {
   if (!m_valid)
 return {};
 
-  std::vector scratch_type_systems;
+  // Some TypeSystem instances are associated with several LanguageTypes so
+  // they will show up several times in the loop below. The SetVector filters
+  // out all duplicates as they serve no use for the caller.
+  llvm::SetVector scratch_type_systems;
 
   LanguageSet languages_for_expressions =
   Language::GetLanguagesSupportingTypeSystemsForExpressions();
@@ -2247,10 +2251,10 @@ std::vector 
Target::GetScratchTypeSystems(bool create_on_demand) {
  "system available",
  Language::GetNameForLanguageType(language));
 else
-  scratch_type_systems.emplace_back(_system_or_err.get());
+  scratch_type_systems.insert(_system_or_err.get());
   }
 
-  return scratch_type_systems;
+  return scratch_type_systems.takeVector();
 }
 
 PersistentExpressionState *

diff  --git a/lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py 
b/lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
new file mode 100644
index 0..634441196b93a
--- /dev/null
+++ b/lldb/test/API/lang/c/builtin-types/TestCBuiltinTypes.py
@@ -0,0 +1,20 @@
+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__)
+
+@no_debug_info_test
+def test_FindTypes_on_scratch_AST(self):
+"""
+Tests FindTypes invoked with only LLDB's scratch AST present.
+"""
+target = self.dbg.GetDummyTarget()
+# There should be only one instance of 'unsigned long' in our single
+# scratch AST. Note: FindTypes/SBType hahave no filter by language, so
+# pick something that is unlikely to also be found in the scratch
+# TypeSystem of other language plugins.
+self.assertEqual(len(target.FindTypes("unsigned long")), 1)



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


[Lldb-commits] [PATCH] D112058: [lldb/DWARF] Ignore debug info pointing to the low addresses

2021-10-19 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: clayborg, aadsm.
labath requested review of this revision.
Herald added a project: LLDB.

specifically, ignore addresses that point before the first code section.

This resurrects D87172  with several notable 
changes:

- it fixes a bug where the early exits in InitializeObject left 
m_first_code_address "initialized" to LLDB_INVALID_ADDRESS (0xfff..f), which 
caused _everything_ to be ignored.
- it extends the line table fix to function parsing as well, where it replaces 
a similar check which was checking the executable permissions of the section. 
This was insufficient because some position-independent elf executables can 
have an executable segment mapped at file address zero. (What makes this fix 
different is that it checks for the executable-ness of the sections contained 
within that segment, and those will not be at address zero.)
- It uses a different test case, with an elf file with near-zero addresses, and 
checks for both line table and function parsing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112058

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml

Index: lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml
@@ -0,0 +1,152 @@
+# RUN: yaml2obj %s > %t
+# RUN: %lldb %t -o "image dump line-table a.c" -o "image lookup -n _start" -o "image lookup -n f" -o exit | FileCheck %s
+
+# CHECK-LABEL: image dump line-table a.c
+# CHECK-NEXT: Line table for a.c
+# CHECK-NEXT: 0x0080: a.c:1
+# CHECK-NEXT: 0x0084: a.c:1
+# CHECK-NEXT: 0x0086: a.c:1
+# CHECK-EMPTY:
+# CHECK-NEXT: image lookup -n _start
+# CHECK-NEXT: 1 match found
+# CHECK-LABEL: image lookup -n f
+# CHECK-EMPTY:
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+ProgramHeaders:
+  - Type:PT_LOAD
+Flags:   [ PF_X, PF_R ]
+Offset:  0x
+FirstSec:.text
+LastSec: .text
+Align:   0x1000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x80
+AddressAlign:0x10
+Content: 554889E55DC3
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x1
+  - Name:.debug_line
+Type:SHT_PROGBITS
+AddressAlign:0x1
+DWARF:
+  debug_ranges:
+- Offset:  0x0
+  AddrSize:0x8
+  Entries:
+- LowOffset:   0x0
+  HighOffset:  0x6
+- LowOffset:   0x80
+  HighOffset:  0x86
+  debug_abbrev:
+- ID:  0
+  Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_string
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
+- Attribute:   DW_AT_stmt_list
+  Form:DW_FORM_sec_offset
+- Attribute:   DW_AT_low_pc
+  Form:DW_FORM_addr
+- Attribute:   DW_AT_ranges
+  Form:DW_FORM_sec_offset
+- Code:0x0002
+  Tag: DW_TAG_subprogram
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_low_pc
+  Form:DW_FORM_addr
+- Attribute:   DW_AT_high_pc
+  Form:DW_FORM_data4
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
+  debug_info:
+- Version: 4
+  AbbrevTableID:   0
+  AbbrOffset:  0x
+  AddrSize:8
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- CStr:Hand-written DWARF
+- CStr:a.c
+- Value:   0x
+- Value:   0x
+- Value:   0x
+- AbbrCode:0x0002
+  Values:
+- Value:   0x
+- Value:   0x0006
+- CStr:f
+- AbbrCode:0x0002
+  Values:
+

[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 380609.
mgorny marked 2 inline comments as done.
mgorny added a comment.

Make `Terminal::Data` private and befriend `TerminalState`.


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

https://reviews.llvm.org/D111890

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Target/Process.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -51,11 +51,11 @@
 TEST_F(TerminalTest, SetEcho) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetEcho(true), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ECHO, 0U);
 
-  ASSERT_EQ(m_term.SetEcho(false), true);
+  ASSERT_THAT_ERROR(m_term.SetEcho(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ECHO, 0U);
 }
@@ -63,11 +63,11 @@
 TEST_F(TerminalTest, SetCanonical) {
   struct termios terminfo;
 
-  ASSERT_EQ(m_term.SetCanonical(true), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(true), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_NE(terminfo.c_lflag & ICANON, 0U);
 
-  ASSERT_EQ(m_term.SetCanonical(false), true);
+  ASSERT_THAT_ERROR(m_term.SetCanonical(false), llvm::Succeeded());
   ASSERT_EQ(tcgetattr(m_fd, ), 0);
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -4349,8 +4349,9 @@
 const int read_fd = m_read_file.GetDescriptor();
 Terminal terminal(read_fd);
 TerminalState terminal_state(terminal, false);
-terminal.SetCanonical(false);
-terminal.SetEcho(false);
+// FIXME: error handling?
+llvm::consumeError(terminal.SetCanonical(false));
+llvm::consumeError(terminal.SetEcho(false));
 // FD_ZERO, FD_SET are not supported on windows
 #ifndef _WIN32
 const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -435,8 +435,9 @@
 TerminalState terminal_state(terminal);
 
 if (terminal.IsATerminal()) {
-  terminal.SetCanonical(false);
-  terminal.SetEcho(true);
+  // FIXME: error handling?
+  llvm::consumeError(terminal.SetCanonical(false));
+  llvm::consumeError(terminal.SetEcho(true));
 }
 
 ScriptInterpreterPythonImpl::Locker locker(
Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -21,71 +21,78 @@
 
 using namespace lldb_private;
 
+struct Terminal::Data {
+#if LLDB_ENABLE_TERMIOS
+  struct termios m_termios; ///< Cached terminal state information.
+#endif
+};
+
 bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
 
-bool Terminal::SetEcho(bool enabled) {
-  if (FileDescriptorIsValid()) {
+llvm::Expected Terminal::GetData() {
+  if (!FileDescriptorIsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid fd");
+
 #if LLDB_ENABLE_TERMIOS
-if (IsATerminal()) {
-  struct termios fd_termios;
-  if (::tcgetattr(m_fd, _termios) == 0) {
-bool set_corectly = false;
-if (enabled) {
-  if (fd_termios.c_lflag & ECHO)
-set_corectly = true;
-  else
-fd_termios.c_lflag |= ECHO;
-} else {
-  if (fd_termios.c_lflag & ECHO)
-fd_termios.c_lflag &= ~ECHO;
-  else
-set_corectly = true;
-}
-
-if (set_corectly)
-  return true;
-return ::tcsetattr(m_fd, TCSANOW, _termios) == 0;
-  }
-}
-#endif // #if LLDB_ENABLE_TERMIOS
-  }
-  return false;
+  if (!IsATerminal())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "fd not a terminal");
+
+  Data data;
+  if (::tcgetattr(m_fd, _termios) != 0)
+return llvm::createStringError(
+std::error_code(errno, std::generic_category()),
+"unable to get teletype attributes");
+  return data;
+#else // !LLDB_ENABLE_TERMIOS
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "termios support missing in LLDB");
+#endif // 

[Lldb-commits] [lldb] 5352ea4 - [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*

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

Author: Michał Górny
Date: 2021-10-19T10:31:07+02:00
New Revision: 5352ea4a721ef252129994111b83dc350ecc71da

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

LOG: [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*

gdbserver does not expose combined ymm* registers but rather XSAVE-style
split xmm* and ymm*h portions.  Extend value_regs to support combining
multiple registers and use it to create user-friendly ymm* registers
that are combined from split xmm* and ymm*h portions.

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

Added: 


Modified: 
lldb/include/lldb/lldb-private-types.h
lldb/source/Plugins/ABI/X86/ABIX86.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/DynamicRegisterInfo.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index 5e71b68630a9..3be7003cd0fb 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -51,8 +51,10 @@ struct RegisterInfo {
   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
   /// not null, all registers in this list will be read first, at which point
   /// the value for this register will be valid. For example, the value list
-  /// for ah would be eax (x86) or rax (x64).
-  uint32_t *value_regs; //
+  /// for ah would be eax (x86) or rax (x64). Register numbers are
+  /// of eRegisterKindLLDB. If multiple registers are listed, the final
+  /// value will be the concatenation of them.
+  uint32_t *value_regs;
   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
   /// not null, all registers in this list will be invalidated when the value 
of
   /// this register changes. For example, the invalidate list for eax would be

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp 
b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index 0286140e4e24..544efc298cd8 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -33,36 +33,40 @@ void ABIX86::Terminate() {
   ABIWindows_x86_64::Terminate();
 }
 
-enum class RegKind {
-  GPR32 = 0,
+namespace {
+enum RegKind {
+  GPR32,
   GPR16,
   GPR8h,
   GPR8,
+  MM,
+  YMM_YMMh,
+  YMM_XMM,
 
-  MM = 0,
+  RegKindCount
+};
+};
+
+struct RegData {
+  RegKind subreg_kind;
+  llvm::StringRef subreg_name;
+  llvm::Optional base_index;
 };
 
-typedef llvm::SmallDenseMap, 16>
-RegisterMap;
-
-static void addPartialRegisters(
-std::vector ,
-llvm::ArrayRef base_reg_indices, const RegisterMap _names,
-uint32_t base_size, RegKind name_index, lldb::Encoding encoding,
-lldb::Format format, uint32_t subreg_size, uint32_t subreg_offset = 0) {
-  for (uint32_t base_index : base_reg_indices) {
-if (base_index == LLDB_INVALID_REGNUM)
-  break;
-assert(base_index < regs.size());
+static void
+addPartialRegisters(std::vector ,
+llvm::ArrayRef subregs, uint32_t base_size,
+lldb::Encoding encoding, lldb::Format format,
+uint32_t subreg_size, uint32_t subreg_offset = 0) {
+  for (const RegData *subreg : subregs) {
+assert(subreg);
+uint32_t base_index = subreg->base_index.getValue();
 DynamicRegisterInfo::Register _reg = regs[base_index];
-llvm::StringRef subreg_name = reg_names.lookup(
-full_reg.name.GetStringRef())[static_cast(name_index)];
-if (subreg_name.empty() || full_reg.byte_size != base_size)
+if (full_reg.byte_size != base_size)
   continue;
 
-lldb_private::DynamicRegisterInfo::Register subreg{
-lldb_private::ConstString(subreg_name),
+lldb_private::DynamicRegisterInfo::Register new_reg{
+lldb_private::ConstString(subreg->subreg_name),
 lldb_private::ConstString(),
 lldb_private::ConstString("supplementary registers"),
 subreg_size,
@@ -77,10 +81,112 @@ static void addPartialRegisters(
 {},
 subreg_offset};
 
-addSupplementaryRegister(regs, subreg);
+addSupplementaryRegister(regs, new_reg);
+  }
+}
+
+static void
+addCombinedRegisters(std::vector ,
+ llvm::ArrayRef subregs1,
+ llvm::ArrayRef subregs2, uint32_t base_size,
+ lldb::Encoding encoding, lldb::Format format) {
+  for (auto it : llvm::zip(subregs1, subregs2)) {
+RegData *regdata1, *regdata2;
+std::tie(regdata1, regdata2) = it;
+assert(regdata1);
+assert(regdata2);
+
+// verify that we've got matching target registers
+if (regdata1->subreg_name != 

[Lldb-commits] [PATCH] D108937: [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5352ea4a721e: [lldb] [ABI/X86] Support combining xmm* and 
ymm*h regs into ymm* (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D108937?vs=380453=380607#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108937

Files:
  lldb/include/lldb/lldb-private-types.h
  lldb/source/Plugins/ABI/X86/ABIX86.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -199,6 +199,29 @@
 self.match("register read st0",
["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"])
 
+self.runCmd("register write xmm0 \"{0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 "
+"0xf8 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xb1 0xb2 0xb3 0xb4 0xb5 "
+"0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf 0xc0}"])
+
+self.runCmd("register write ymm0h \"{0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 "
+"0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xef 0xee 0xed 0xec 0xeb "
+"0xea 0xe9 0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}"])
+
+self.runCmd("register write ymm0 \"{0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 "
+"0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 "
+"0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec "
+"0xed 0xee 0xef}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 "
+"0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 "
+"0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}"])
+
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("X86")
@@ -361,6 +384,29 @@
 self.match("register read st0",
["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"])
 
+self.runCmd("register write xmm0 \"{0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 "
+"0xf8 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xb1 0xb2 0xb3 0xb4 0xb5 "
+"0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf 0xc0}"])
+
+self.runCmd("register write ymm0h \"{0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 "
+"0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 "
+"0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xef 0xee 0xed 0xec 0xeb "
+"0xea 0xe9 0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}"])
+
+self.runCmd("register write ymm0 \"{0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 "
+"0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 "
+"0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec "
+"0xed 0xee 0xef}\"")
+self.match("register read ymm0",
+   ["ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 "
+"0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 "
+"0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}"])
+
 @skipIfXmlSupportMissing
 @skipIfRemote
 @skipIfLLVMTargetMissing("AArch64")
Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -463,20 +463,11 @@
 m_sets[set].registers = m_set_reg_nums[set].data();
   }
 
-  // sort and unique all value registers and make sure each is terminated with
-  // LLDB_INVALID_REGNUM
+  // make sure value_regs are terminated with LLDB_INVALID_REGNUM
 
   for (reg_to_regs_map::iterator pos = 

[Lldb-commits] [PATCH] D111989: [lldb] Reduce code duplication around inferior building

2021-10-19 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.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111989

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


[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error

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



Comment at: lldb/include/lldb/Host/Terminal.h:21
 public:
+  struct Data;
+

mgorny wrote:
> labath wrote:
> > Move this into the protected section
> If I do that, I can't use it from `TerminalState`.
I see. I was expecting that TerminalState was a friend or something. Given the 
new setup I think it would make sense to make it a friend so that it can use 
Get/SetData instead of raw tc[gs]etattr calls (and hopefully avoid some ifdefs).


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

https://reviews.llvm.org/D111890

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


[Lldb-commits] [PATCH] D108937: [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*

2021-10-19 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.

Looks good. Thanks for your patience.




Comment at: lldb/source/Plugins/ABI/X86/ABIX86.cpp:36-52
+enum RegKind {
+  GPR32,
   GPR16,
   GPR8h,
   GPR8,
+  MM,
+  YMM_YMMh,

anonymous namespace here


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

https://reviews.llvm.org/D108937

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-server] Allow any protocol supported by lldb

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



Comment at: lldb/tools/lldb-server/lldb-gdbserver.cpp:237-249
+  if (!is_url) {
+// Ensure we have a port number for the connection.
+// Note: use rfind, because the host/port may look like "[::1]:12345".
+uint32_t connection_portno = 0;
+const std::string::size_type colon_pos = 
final_host_and_port.rfind(':');
+if (colon_pos != std::string::npos)
+  llvm::to_integer(final_host_and_port.substr(colon_pos + 1),

labath wrote:
> I am wondering what's the impact of removing this. If we get some 
> semi-reasonable message, then it'd be nice to get rid of it. Otherwise, we'll 
> have a weird difference between the user typing `host:0` and 
> `connect://host:0`.
If we don't get a reasonable error message, we could probably create one by 
pushing this check into the lower layers.


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-server] Allow any protocol supported by lldb

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

In D111964#3071292 , @mgorny wrote:

> In D111964#3069414 , @labath wrote:
>
>> What's the test strategy for this?
>
> Still thinking about it. I'm mostly PoC-ing this while other changes are 
> waiting.

For the current patch, I guess it would be sufficient to establish a connection 
using _any_ url.




Comment at: lldb/tools/lldb-server/lldb-gdbserver.cpp:237-249
+  if (!is_url) {
+// Ensure we have a port number for the connection.
+// Note: use rfind, because the host/port may look like "[::1]:12345".
+uint32_t connection_portno = 0;
+const std::string::size_type colon_pos = 
final_host_and_port.rfind(':');
+if (colon_pos != std::string::npos)
+  llvm::to_integer(final_host_and_port.substr(colon_pos + 1),

I am wondering what's the impact of removing this. If we get some 
semi-reasonable message, then it'd be nice to get rid of it. Otherwise, we'll 
have a weird difference between the user typing `host:0` and `connect://host:0`.


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-server] Allow any protocol supported by lldb

2021-10-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D111964#3072088 , @labath wrote:

> I think we could introduce something like `Connection::IsReliable` and key 
> that behavior off of that.
>
> Although I can't say I actually understand how the "ack" mode is supposed to 
> work. It seems like it would be very hard to recover from transmission errors 
> that affect the `$` or `#` parts of the packet.

FWICS, gdb uses "noack" mode unconditionally. I somewhat suspect that the "ack" 
mode might just be a historical thing that doesn't actually serve any purpose.


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [PATCH] D111964: [lldb] [lldb-server] Allow any protocol supported by lldb

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

In D111964#3071292 , @mgorny wrote:

>>> This is not fully functional yet, as lldb-server
>>> crashes when attempting to send long packets (e.g. target.xml contents).
>>
>> I am guessing you'll also want to disable QStartNoAckMode for these 
>> connections (?)
>
> I suppose this makes sense. Are you suggesting special-casing `serial://` or 
> do you have something else in mind?

I think we could introduce something like `Connection::IsReliable` and key that 
behavior off of that.

Although I can't say I actually understand how the "ack" mode is supposed to 
work. It seems like it would be very hard to recover from transmission errors 
that affect the `$` or `#` parts of the packet.


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

https://reviews.llvm.org/D111964

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


[Lldb-commits] [PATCH] D111981: [lldb] Fix missing dependency on libc++ from LLDB test suite on non-Darwin platforms

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

In D111981#3071414 , @dblaikie wrote:

> Oh, mostly my point was "the output changes after I explicitly run `ninja 
> cxx`" so it looks like the dependency didn't fully address the build 
> consistency issue, regardless of what the failure actually is?

This looks like a classic example of the reason why `if(TARGET FOO)` is 
discouraged in cmake.
The top level cmake file looks like this:

  add_subdirectory(projects) # libcxx IN LLVM_ENABLE_PROJECTS processed here
  
  if( LLVM_INCLUDE_TOOLS )
add_subdirectory(tools) # lldb IN LLVM_ENABLE_PROJECTS processed here
  endif()
  
  if( LLVM_INCLUDE_RUNTIMES )
add_subdirectory(runtimes) # libcxx in LLVM_ENABLE_RUNTIMES processed here
  endif()

If one enables libcxx via LLVM_ENABLE_PROJECTS (which is I guess what the apple 
folks are using) then all is fine, as the cxx target will be defined by the 
time we get to lldb. OTOH, if one uses LLVM_ENABLE_RUNTIMES, then the check 
will return false (and not add the dependency), even though the target will be 
defined afterwards (and will be found by clang at runtime).
I think (but I haven't verified) that this could be fixed by replacing `TARGET 
cxx` with `libcxx IN LLVM_ENABLE_PROJECTS OR libcxx IN LLVM_ENABLE_RUNTIMES`.

>> Can you apply https://reviews.llvm.org/D111978 and see what the error output 
>> with that patch is? It should give you exit status/description and stderr.
>
> Sure, I'll give that a go (was going to test it once it was submitted), but 
> emulating something similar to the test, by debugging the binary directly:
>
>   $ ./bin/lldb 
> ./lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.test_with_run_command_dwarf/a.out
>   (lldb) target create 
> "./lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.test_with_run_command_dwarf/a.out"
>   Current executable set to 
> '/usr/local/google/home/blaikie/dev/llvm/build/release/lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.test_with_run_command_dwarf/a.out'
>  (x86_64).
>   (lldb) start
>   error: 'start' is not a valid command.
>   (lldb) r
>   warning: (x86_64) /lib/x86_64-linux-gnu/ld-2.32.so Unable to initialize 
> decompressor for section '.debug_abbrev': zlib is not available
>   warning: (x86_64) /lib/x86_64-linux-gnu/ld-2.32.so Unable to initialize 
> decompressor for section '.debug_info': zlib is not available
>   Process 3723631 launched: 
> '/usr/local/google/home/blaikie/dev/llvm/build/release/lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.test_with_run_command_dwarf/a.out'
>  (x86_64)
>   warning: (x86_64) /lib/x86_64-linux-gnu/ld-2.32.so Unable to initialize 
> decompressor for section '.debug_aranges': zlib is not available
>   warning: (x86_64) /lib64/ld-linux-x86-64.so.2 Unable to initialize 
> decompressor for section '.debug_abbrev': zlib is not available
>   warning: (x86_64) /lib64/ld-linux-x86-64.so.2 Unable to initialize 
> decompressor for section '.debug_info': zlib is not available
>   
> /usr/local/google/home/blaikie/dev/llvm/build/release/lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.test_with_run_command_dwarf/a.out:
>  error while loading shared libraries: libc++.so.1: cannot open shared object 
> file: No such file or directory
>
> I don't /think/ there's any reason (given the current Cmake 
> configuration/code/etc) that the binary should be able to find libc++.so.1? 
> In the libc++ tests (not the lldb libc++ tests, but the libc++ libc++ tests) 
> they specify -rpath when compiling libc++ binaries against the just-built 
> libc++ so they'll find the just-built libc++.so. I don't see anything like 
> that in the lldb libc++ tests/build.

Yeah, we'd have to take some positive action to make that hapen.
I think the best way to go about that is to call 
`registerSharedLibrariesWithTarget` under the right circumstances. That would 
ensure ((DY)LD_LIBRARY_)PATH is set, and also copy the library for remote 
tests. I'm just not entirely sure what are "the right circumstances".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111981

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


[Lldb-commits] [lldb] 957a5e9 - [lldb] Fix nullptr dereference in AppleObjCRuntimeV2

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

Author: Jonas Devlieghere
Date: 2021-10-18T23:30:31-07:00
New Revision: 957a5e987444d3193575d6ad8afe6c75da00d794

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

LOG: [lldb] Fix nullptr dereference in AppleObjCRuntimeV2

Fix a potential nullptr dereference in AppleObjCRuntimeV2 by checking
the result of GetClassInfoUtilityFunction and returning a failure if
it's null.

The DynamicClassInfoExtractor was already doign the right thing, but the
SharedCacheClassInfoExtractor was missing this check.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index eaab24c3bf682..091bd3752d072 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1995,6 +1995,11 @@ 
AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap() {
   const uint32_t num_classes = 128 * 1024;
 
   UtilityFunction *get_class_info_code = GetClassInfoUtilityFunction(exe_ctx);
+  if (!get_class_info_code) {
+// The callee will have already logged a useful error message.
+return DescriptorMapUpdateResult::Fail();
+  }
+
   FunctionCaller *get_shared_cache_class_info_function =
   get_class_info_code->GetFunctionCaller();
 



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