[Lldb-commits] [lldb] eecef3a - [lldb][test] Enable fix-its for the test case that expects them enabled

2020-03-04 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-03-05T10:31:07+03:00
New Revision: eecef3af2ca8b27f4070be41c73bff989a096f9b

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

LOG: [lldb][test] Enable fix-its for the test case that expects them enabled

Fix-its were intentionally disabled by TestBase.setUp so that incorrect 
expressions in tests
don't pass just because Clang thinks it has a fix-it.

Added: 


Modified: 
lldb/test/API/commands/expression/fixits/TestFixIts.py

Removed: 




diff  --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py 
b/lldb/test/API/commands/expression/fixits/TestFixIts.py
index 75fe43ec7fe1..7aca1c5aa863 100644
--- a/lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -29,6 +29,10 @@ def test_with_target(self):
 
 def test_with_dummy_target(self):
 """Test calling expressions in the dummy target with errors that can 
be fixed by the FixIts."""
+
+# Enable fix-its as they were intentionally disabled by TestBase.setUp.
+self.runCmd("settings set target.auto-apply-fixits true")
+
 ret_val = lldb.SBCommandReturnObject()
 result = self.dbg.GetCommandInterpreter().HandleCommand("expression 
((1 << 16) - 1))", ret_val)
 self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "The 
expression was successful.")



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


[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-04 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa31130f6fcf2: [lldb][testsuite] Create a SBDebugger instance 
for each test (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74903

Files:
  lldb/bindings/interface/SBPlatform.i
  lldb/include/lldb/API/SBPlatform.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBPlatform.cpp
  
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
  
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
  lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
  lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
  
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
  lldb/test/API/macosx/load-kext/TestLoadKext.py
  lldb/test/API/python_api/file_handle/TestFileHandle.py
  
lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Index: lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
===
--- lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,14 +10,6 @@
 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-super(TestPlatformProcessConnect, self).setUp()
-self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-def tearDown(self):
-lldb.DBG.SetSelectedPlatform(self._initial_platform)
-super(TestPlatformProcessConnect, self).tearDown()
-
 @llgs_test
 @no_debug_info_test
 @skipIf(remote=False)
@@ -66,16 +58,10 @@
 
 socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-new_debugger = lldb.SBDebugger.Create()
-new_debugger.SetAsync(False)
-
-def del_debugger(new_debugger=new_debugger):
-del new_debugger
-self.addTearDownHook(del_debugger)
+self.dbg.SetAsync(False)
 
 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-new_debugger.SetSelectedPlatform(new_platform)
-new_interpreter = new_debugger.GetCommandInterpreter()
+self.dbg.SetSelectedPlatform(new_platform)
 
 if unix_protocol:
 connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
@@ -84,13 +70,13 @@
 
 command = "platform connect %s" % (connect_url)
 result = lldb.SBCommandReturnObject()
-new_interpreter.HandleCommand(command, result)
+self.dbg.GetCommandInterpreter().HandleCommand(command, result)
 self.assertTrue(
 result.Succeeded(),
 "platform process connect failed: %s" %
 result.GetOutput())
 
-target = new_debugger.GetSelectedTarget()
+target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
 thread = process.GetThreadAtIndex(0)
 
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -82,12 +82,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = lldbtest.Base.compute_mydir(__file__)
 
-# The way this class interacts with the debugger is different
-# than normal.   Most of these test cases will mess with the
-# debugger I/O streams, so we want a fresh debugger for each
-# test so those mutations don't interfere with each other.

[Lldb-commits] [lldb] a31130f - [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-04 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-03-05T10:12:54+03:00
New Revision: a31130f6fcf27518b31a8ac1f5971a42fc24837e

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

LOG: [lldb][testsuite] Create a SBDebugger instance for each test

Some tests set settings and don't clean them up, this leads to side effects in 
other tests.
The patch removes a global debugger instance with a per-test debugger to avoid 
such effects.

>From what I see, lldb.DBG was needed to determine the platform before a test 
>is run,
lldb.selected_platform is used for this purpose now. Though, this required 
adding a new function
to the SBPlatform interface.

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

Added: 


Modified: 
lldb/bindings/interface/SBPlatform.i
lldb/include/lldb/API/SBPlatform.h
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBPlatform.cpp

lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py

lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py

lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py

lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py

lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
lldb/test/API/macosx/load-kext/TestLoadKext.py
lldb/test/API/python_api/file_handle/TestFileHandle.py

lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Removed: 




diff  --git a/lldb/bindings/interface/SBPlatform.i 
b/lldb/bindings/interface/SBPlatform.i
index 9baa2eb970c6..1f52edb0232c 100644
--- a/lldb/bindings/interface/SBPlatform.i
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -115,6 +115,8 @@ public:
 
 ~SBPlatform();
 
+static SBPlatform GetHostPlatform();
+
 bool
 IsValid () const;
 

diff  --git a/lldb/include/lldb/API/SBPlatform.h 
b/lldb/include/lldb/API/SBPlatform.h
index 58dafc235c64..7fac182a0dd1 100644
--- a/lldb/include/lldb/API/SBPlatform.h
+++ b/lldb/include/lldb/API/SBPlatform.h
@@ -97,6 +97,8 @@ class LLDB_API SBPlatform {
 
   ~SBPlatform();
 
+  static SBPlatform GetHostPlatform();
+
   explicit operator bool() const;
 
   bool IsValid() const;

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index ec17cb7c2569..b0d2db7655ff 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -172,7 +172,7 @@ def fn(self):
 skip_for_debug_info = _match_decorator_property(
 debug_info, self.getDebugInfo())
 skip_for_triple = _match_decorator_property(
-triple, lldb.DBG.GetSelectedPlatform().GetTriple())
+triple, lldb.selected_platform.GetTriple())
 skip_for_remote = _match_decorator_property(
 remote, lldb.remote_platform is not None)
 

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 5dddc996eda5..991e29d7e6b0 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -774,16 +774,6 @@ def visit(prefix, dir, names):
 raise
 
 
-def setSetting(setting, value):
-import lldb
-ci = lldb.DBG.GetCommandInterpreter()
-res = lldb.SBCommandReturnObject()
-cmd = 'setting set %s %s'%(setting, value)
-print(cmd)
-ci.HandleCommand(cmd, res, False)
-if not res.Succeeded():
-raise Exception('failed to run "%s"'%cmd)
-
 # 

Re: [Lldb-commits] [lldb] e98ef0a - [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp

2020-03-04 Thread Jim Ingham via lldb-commits
We should really have a low-frequency bot that just runs the whole testsuite 
with all the logs turned on and make sure that doesn't crash...

Jim


> On Mar 4, 2020, at 10:56 AM, Raphael “Teemperor” Isemann via lldb-commits 
>  wrote:
> 
> Yeah this whole thing is a disaster and it’s puzzling that we don’t test the 
> whole logging but instead just crash on the end user machine. I’m currently 
> writing a test that gives all this code at least coverage and then I guess we 
> have to fix all of these bugs.
> 
>> On Mar 4, 2020, at 10:53 AM, Shafik Yaghmour  wrote:
>> 
>> This is a lot of errors, did it the index use to start at one before? 
>> 
>> There is a type below, noted inline
>> 
>>> On Mar 4, 2020, at 10:33 AM, Raphael Isemann via lldb-commits 
>>>  wrote:
>>> 
>>> 
>>> Author: Raphael Isemann
>>> Date: 2020-03-04T10:32:50-08:00
>>> New Revision: e98ef0af2c725f12dc60556a039e947ddeeb9f42
>>> 
>>> URL: 
>>> https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42
>>> DIFF: 
>>> https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42.diff
>>> 
>>> LOG: [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp
>>> 
>>> Added: 
>>> 
>>> 
>>> Modified: 
>>>   lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>>> 
>>> Removed: 
>>> 
>>> 
>>> 
>>> 
>>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
>>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>>> index 4d98d9cbdda3..6a8c7bd46559 100644
>>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>>> @@ -190,8 +190,8 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>> 
>>>  if (log) {
>>>LLDB_LOG(log,
>>> - "CompleteTagDecl on (ASTContext*){1} Completing "
>>> - "(TagDecl*){2} named {3}",
>>> + "CompleteTagDecl on (ASTContext*){0} Completing "
>>> + "(TagDecl*){1} named {2}",
>>> m_clang_ast_context->getDisplayName(), tag_decl,
>>> tag_decl->getName());
>>> 
>>> @@ -220,7 +220,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>>  ClangASTImporter::NamespaceMapSP namespace_map =
>>>  m_ast_importer_sp->GetNamespaceMap(namespace_context);
>>> 
>>> -  LLDB_LOGV(log, "  CTD Inspecting namespace map{1} ({2} entries)",
>>> +  LLDB_LOGV(log, "  CTD Inspecting namespace map{0} ({1} entries)",
>>>namespace_map.get(), namespace_map->size());
>>> 
>>>  if (!namespace_map)
>>> @@ -229,7 +229,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>>  for (ClangASTImporter::NamespaceMap::iterator i = 
>>> namespace_map->begin(),
>>>e = namespace_map->end();
>>>   i != e && !found; ++i) {
>>> -LLDB_LOG(log, "  CTD Searching namespace {1} in module {2}",
>>> +LLDB_LOG(log, "  CTD Searching namespace {0} in module {1}",
>>> i->second.GetName(), i->first->GetFileSpec().GetFilename());
>>> 
>>>TypeList types;
>>> @@ -478,12 +478,12 @@ void ClangASTSource::FindExternalLexicalDecls(
>>>std::string ast_dump = ClangUtil::DumpDecl(decl);
>>>if (const NamedDecl *context_named_decl =
>>>dyn_cast(context_decl))
>>> -  LLDB_LOG(log, "  FELD Adding [to {1}Decl {2}] lexical {3}Decl 
>>> {4}",
>>> +  LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl 
>>> 34}”,
>> 
>> 
>> Typo should be {3} not 34}
>> 
>> 
>>>   context_named_decl->getDeclKindName(),
>>>   context_named_decl->getName(), decl->getDeclKindName(),
>>>   ast_dump);
>>>else
>>> -  LLDB_LOG(log, "  FELD Adding lexical {1}Decl {2}",
>>> +  LLDB_LOG(log, "  FELD Adding lexical {0}Decl {1}",
>>>   decl->getDeclKindName(), ast_dump);
>>>  }
>>> 
>>> @@ -527,19 +527,19 @@ void 
>>> ClangASTSource::FindExternalVisibleDecls(NameSearchContext ) {
>>>if (!context.m_decl_context)
>>>  LLDB_LOG(log,
>>>   "ClangASTSource::FindExternalVisibleDecls on "
>>> -   "(ASTContext*){1} '{2}' for '{3}' in a NULL DeclContext",
>>> +   "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
>>>   m_ast_context, m_clang_ast_context->getDisplayName(), name);
>>>else if (const NamedDecl *context_named_decl =
>>> dyn_cast(context.m_decl_context))
>>>  LLDB_LOG(log,
>>>   "ClangASTSource::FindExternalVisibleDecls on "
>>> -   "(ASTContext*){1} '{2}' for '{3}' in '{4}'",
>>> +   "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
>>>   m_ast_context, m_clang_ast_context->getDisplayName(), name,
>>>   

[Lldb-commits] [lldb] 70b8f95 - [lldb][NFC] Use C++11 for loop in ClangASTSource::FindExternalLexicalDecls

2020-03-04 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-03-04T12:57:05-08:00
New Revision: 70b8f95813106491166fc9f18fa90a0866024ffc

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

LOG: [lldb][NFC] Use C++11 for loop in ClangASTSource::FindExternalLexicalDecls

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index c231cae58d2d..0b94b8d4b25c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -466,10 +466,7 @@ void ClangASTSource::FindExternalLexicalDecls(
 
   // Indicates whether we skipped any Decls of the original DeclContext.
   bool SkippedDecls = false;
-  for (DeclContext::decl_iterator iter = original_decl_context->decls_begin();
-   iter != original_decl_context->decls_end(); ++iter) {
-Decl *decl = *iter;
-
+  for (Decl *decl : original_decl_context->decls()) {
 // The predicate function returns true if the passed declaration kind is
 // the one we are looking for.
 // See clang::ExternalASTSource::FindExternalLexicalDecls()



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


[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked an inline comment as done.
aprantl added inline comments.



Comment at: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm:25
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct Nested
+// CHECK-DAG: -FieldDecl {{.*}} in A fromb 'StructB'
+

Note that the *Field* decl still comes from A, but its type (see above) doesn't.


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

https://reviews.llvm.org/D75488



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


[Lldb-commits] [lldb] 4ab2ea9 - [lldb] Fix typo in ClangASTSource logging statement

2020-03-04 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-03-04T11:05:48-08:00
New Revision: 4ab2ea9fc09d93ef136a690f3f94d3c791540fcf

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

LOG: [lldb] Fix typo in ClangASTSource logging statement

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 6a8c7bd46559..c231cae58d2d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -478,7 +478,7 @@ void ClangASTSource::FindExternalLexicalDecls(
 std::string ast_dump = ClangUtil::DumpDecl(decl);
 if (const NamedDecl *context_named_decl =
 dyn_cast(context_decl))
-  LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl 34}",
+  LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl {3}",
context_named_decl->getDeclKindName(),
context_named_decl->getName(), decl->getDeclKindName(),
ast_dump);



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


Re: [Lldb-commits] [lldb] e98ef0a - [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp

2020-03-04 Thread Raphael “Teemperor” Isemann via lldb-commits
Yeah this whole thing is a disaster and it’s puzzling that we don’t test the 
whole logging but instead just crash on the end user machine. I’m currently 
writing a test that gives all this code at least coverage and then I guess we 
have to fix all of these bugs.

> On Mar 4, 2020, at 10:53 AM, Shafik Yaghmour  wrote:
> 
> This is a lot of errors, did it the index use to start at one before? 
> 
> There is a type below, noted inline
> 
>> On Mar 4, 2020, at 10:33 AM, Raphael Isemann via lldb-commits 
>>  wrote:
>> 
>> 
>> Author: Raphael Isemann
>> Date: 2020-03-04T10:32:50-08:00
>> New Revision: e98ef0af2c725f12dc60556a039e947ddeeb9f42
>> 
>> URL: 
>> https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42.diff
>> 
>> LOG: [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> 
>> Removed: 
>> 
>> 
>> 
>> 
>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> index 4d98d9cbdda3..6a8c7bd46559 100644
>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> @@ -190,8 +190,8 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>> 
>>  if (log) {
>>LLDB_LOG(log,
>> - "CompleteTagDecl on (ASTContext*){1} Completing "
>> - "(TagDecl*){2} named {3}",
>> + "CompleteTagDecl on (ASTContext*){0} Completing "
>> + "(TagDecl*){1} named {2}",
>> m_clang_ast_context->getDisplayName(), tag_decl,
>> tag_decl->getName());
>> 
>> @@ -220,7 +220,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>  ClangASTImporter::NamespaceMapSP namespace_map =
>>  m_ast_importer_sp->GetNamespaceMap(namespace_context);
>> 
>> -  LLDB_LOGV(log, "  CTD Inspecting namespace map{1} ({2} entries)",
>> +  LLDB_LOGV(log, "  CTD Inspecting namespace map{0} ({1} entries)",
>>namespace_map.get(), namespace_map->size());
>> 
>>  if (!namespace_map)
>> @@ -229,7 +229,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>>  for (ClangASTImporter::NamespaceMap::iterator i = 
>> namespace_map->begin(),
>>e = namespace_map->end();
>>   i != e && !found; ++i) {
>> -LLDB_LOG(log, "  CTD Searching namespace {1} in module {2}",
>> +LLDB_LOG(log, "  CTD Searching namespace {0} in module {1}",
>> i->second.GetName(), i->first->GetFileSpec().GetFilename());
>> 
>>TypeList types;
>> @@ -478,12 +478,12 @@ void ClangASTSource::FindExternalLexicalDecls(
>>std::string ast_dump = ClangUtil::DumpDecl(decl);
>>if (const NamedDecl *context_named_decl =
>>dyn_cast(context_decl))
>> -  LLDB_LOG(log, "  FELD Adding [to {1}Decl {2}] lexical {3}Decl 
>> {4}",
>> +  LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl 
>> 34}”,
> 
> 
> Typo should be {3} not 34}
> 
> 
>>   context_named_decl->getDeclKindName(),
>>   context_named_decl->getName(), decl->getDeclKindName(),
>>   ast_dump);
>>else
>> -  LLDB_LOG(log, "  FELD Adding lexical {1}Decl {2}",
>> +  LLDB_LOG(log, "  FELD Adding lexical {0}Decl {1}",
>>   decl->getDeclKindName(), ast_dump);
>>  }
>> 
>> @@ -527,19 +527,19 @@ void 
>> ClangASTSource::FindExternalVisibleDecls(NameSearchContext ) {
>>if (!context.m_decl_context)
>>  LLDB_LOG(log,
>>   "ClangASTSource::FindExternalVisibleDecls on "
>> -   "(ASTContext*){1} '{2}' for '{3}' in a NULL DeclContext",
>> +   "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
>>   m_ast_context, m_clang_ast_context->getDisplayName(), name);
>>else if (const NamedDecl *context_named_decl =
>> dyn_cast(context.m_decl_context))
>>  LLDB_LOG(log,
>>   "ClangASTSource::FindExternalVisibleDecls on "
>> -   "(ASTContext*){1} '{2}' for '{3}' in '{4}'",
>> +   "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
>>   m_ast_context, m_clang_ast_context->getDisplayName(), name,
>>   context_named_decl->getName());
>>else
>>  LLDB_LOG(log,
>>   "ClangASTSource::FindExternalVisibleDecls on "
>> -   "(ASTContext*){1} '{2}' for '{3}' in a '{4}'",
>> +   "(ASTContext*){0} '{1}' for '{2}' in a '{3}'",
>>   m_ast_context, m_clang_ast_context->getDisplayName(), name,
>>   

Re: [Lldb-commits] [lldb] e98ef0a - [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp

2020-03-04 Thread Shafik Yaghmour via lldb-commits
This is a lot of errors, did it the index use to start at one before? 

There is a type below, noted inline

> On Mar 4, 2020, at 10:33 AM, Raphael Isemann via lldb-commits 
>  wrote:
> 
> 
> Author: Raphael Isemann
> Date: 2020-03-04T10:32:50-08:00
> New Revision: e98ef0af2c725f12dc60556a039e947ddeeb9f42
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42
> DIFF: 
> https://github.com/llvm/llvm-project/commit/e98ef0af2c725f12dc60556a039e947ddeeb9f42.diff
> 
> LOG: [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp
> 
> Added: 
> 
> 
> Modified: 
>lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
> b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> index 4d98d9cbdda3..6a8c7bd46559 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> @@ -190,8 +190,8 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
> 
>   if (log) {
> LLDB_LOG(log,
> - "CompleteTagDecl on (ASTContext*){1} Completing "
> - "(TagDecl*){2} named {3}",
> + "CompleteTagDecl on (ASTContext*){0} Completing "
> + "(TagDecl*){1} named {2}",
>  m_clang_ast_context->getDisplayName(), tag_decl,
>  tag_decl->getName());
> 
> @@ -220,7 +220,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>   ClangASTImporter::NamespaceMapSP namespace_map =
>   m_ast_importer_sp->GetNamespaceMap(namespace_context);
> 
> -  LLDB_LOGV(log, "  CTD Inspecting namespace map{1} ({2} entries)",
> +  LLDB_LOGV(log, "  CTD Inspecting namespace map{0} ({1} entries)",
> namespace_map.get(), namespace_map->size());
> 
>   if (!namespace_map)
> @@ -229,7 +229,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
>   for (ClangASTImporter::NamespaceMap::iterator i = 
> namespace_map->begin(),
> e = namespace_map->end();
>i != e && !found; ++i) {
> -LLDB_LOG(log, "  CTD Searching namespace {1} in module {2}",
> +LLDB_LOG(log, "  CTD Searching namespace {0} in module {1}",
>  i->second.GetName(), i->first->GetFileSpec().GetFilename());
> 
> TypeList types;
> @@ -478,12 +478,12 @@ void ClangASTSource::FindExternalLexicalDecls(
> std::string ast_dump = ClangUtil::DumpDecl(decl);
> if (const NamedDecl *context_named_decl =
> dyn_cast(context_decl))
> -  LLDB_LOG(log, "  FELD Adding [to {1}Decl {2}] lexical {3}Decl {4}",
> +  LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl 34}”,


Typo should be {3} not 34}


>context_named_decl->getDeclKindName(),
>context_named_decl->getName(), decl->getDeclKindName(),
>ast_dump);
> else
> -  LLDB_LOG(log, "  FELD Adding lexical {1}Decl {2}",
> +  LLDB_LOG(log, "  FELD Adding lexical {0}Decl {1}",
>decl->getDeclKindName(), ast_dump);
>   }
> 
> @@ -527,19 +527,19 @@ void 
> ClangASTSource::FindExternalVisibleDecls(NameSearchContext ) {
> if (!context.m_decl_context)
>   LLDB_LOG(log,
>"ClangASTSource::FindExternalVisibleDecls on "
> -   "(ASTContext*){1} '{2}' for '{3}' in a NULL DeclContext",
> +   "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
>m_ast_context, m_clang_ast_context->getDisplayName(), name);
> else if (const NamedDecl *context_named_decl =
>  dyn_cast(context.m_decl_context))
>   LLDB_LOG(log,
>"ClangASTSource::FindExternalVisibleDecls on "
> -   "(ASTContext*){1} '{2}' for '{3}' in '{4}'",
> +   "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
>m_ast_context, m_clang_ast_context->getDisplayName(), name,
>context_named_decl->getName());
> else
>   LLDB_LOG(log,
>"ClangASTSource::FindExternalVisibleDecls on "
> -   "(ASTContext*){1} '{2}' for '{3}' in a '{4}'",
> +   "(ASTContext*){0} '{1}' for '{2}' in a '{3}'",
>m_ast_context, m_clang_ast_context->getDisplayName(), name,
>context.m_decl_context->getDeclKindName());
>   }
> @@ -631,7 +631,7 @@ void ClangASTSource::FindExternalVisibleDecls(
>   if (log) {
> const char *name_string = type_sp->GetName().GetCString();
> 
> -LLDB_LOG(log, "  CAS::FEVD Matching type found for \"{1}\": {2}", 
> name,
> +LLDB_LOG(log, "  CAS::FEVD Matching type found for \"{0}\": {1}", 
> name,
>  (name_string ? 

[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 248244.
aprantl marked an inline comment as done.
aprantl added a comment.

Hardcode triple in test


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

https://reviews.llvm.org/D75488

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm

Index: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
@@ -0,0 +1,41 @@
+// RUN: %clang --target=x86_64-apple-macosx -g -gmodules \
+// RUN:-fmodules -fmodules-cache-path=%t.cache \
+// RUN:-c -o %t.o %s -I%S/Inputs
+// RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck %s
+// Verify that the owning module information from DWARF is preserved in the AST. 
+
+@import A;
+
+Typedef t1;
+// CHECK-DAG: TypedefDecl {{.*}} imported in A Typedef
+
+TopLevelStruct s1;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct TopLevelStruct
+// CHECK-DAG: -FieldDecl {{.*}} in A a 'int'
+
+Struct s2;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct
+
+StructB s3;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A.B struct
+// CHECK-DAG: -FieldDecl {{.*}} in A.B b 'int'
+
+Nested s4;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct Nested
+// CHECK-DAG: -FieldDecl {{.*}} in A fromb 'StructB'
+
+Enum e1;
+// CHECK-DAG: EnumDecl {{.*}} imported in A Enum_e
+// CHECK-DAG: -EnumConstantDecl {{.*}} imported in A a
+
+SomeClass *obj1;
+// CHECK-DAG: ObjCInterfaceDecl {{.*}} imported in A SomeClass
+
+Template t2;
+// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A struct Template
+
+Namespace::InNamespace t3;
+// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A struct InNamespace
+
+Namespace::AlsoInNamespace t4;
+// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A.B struct AlsoInNamespace
Index: lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
===
--- lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
+++ lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.cpp', '.m', '.s', '.test', '.ll']
+config.suffixes = ['.cpp', '.m', '.mm', '.s', '.test', '.ll']
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
@@ -0,0 +1,6 @@
+module A {
+  header "A.h"
+  module B {
+header "B.h"
+  }
+}
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
@@ -0,0 +1,8 @@
+typedef struct {
+  int b;
+} StructB;
+
+namespace Namespace {
+template struct AlsoInNamespace { T field; };
+ extern template struct AlsoInNamespace;
+}
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
@@ -0,0 +1,30 @@
+#include "B.h" // -*- ObjC -*-
+
+typedef int Typedef;
+
+struct TopLevelStruct {
+  int a;
+};
+
+typedef struct Struct_s {
+  int a;
+} Struct;
+
+struct Nested {
+  StructB fromb;
+};
+
+typedef enum Enum_e {
+  a = 0
+} Enum;
+
+@interface SomeClass {}
+@end
+
+template struct Template { T field; };
+extern template struct Template;
+
+namespace Namespace {
+template struct InNamespace { T field; };
+extern template struct InNamespace;
+}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -78,6 +78,7 @@
   DIEToDeclContextMap;
   typedef std::multimap
   DeclContextToDIEMap;
+  typedef llvm::DenseMap DIEToModuleMap;
   typedef llvm::DenseMap
   DIEToDeclMap;
   typedef llvm::DenseMap DeclToDIEMap;
@@ -87,6 +88,7 @@
   DeclToDIEMap m_decl_to_die;
   DIEToDeclContextMap m_die_to_decl_ctx;
   DeclContextToDIEMap m_decl_ctx_to_die;
+  DIEToModuleMap m_die_to_module;
   std::unique_ptr m_clang_ast_importer_up;
   /// @}
 
@@ -140,6 +142,7 @@
 
   clang::DeclContext *GetClangDeclContextContainingDIE(const DWARFDIE ,
DWARFDIE *decl_ctx_die);
+  unsigned 

[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 248241.
aprantl marked 3 inline comments as done.
aprantl added a comment.

Address feedback from Pavel.


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

https://reviews.llvm.org/D75488

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm

Index: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
@@ -0,0 +1,40 @@
+// RUN: %clang_host -g -gmodules -fmodules -fmodules-cache-path=%t.cache \
+// RUN:-c -o %t.o %s -I%S/Inputs
+// RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck %s
+// Verify that the owning module information from DWARF is preserved in the AST. 
+
+@import A;
+
+Typedef t1;
+// CHECK-DAG: TypedefDecl {{.*}} imported in A Typedef
+
+TopLevelStruct s1;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct TopLevelStruct
+// CHECK-DAG: -FieldDecl {{.*}} in A a 'int'
+
+Struct s2;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct
+
+StructB s3;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A.B struct
+// CHECK-DAG: -FieldDecl {{.*}} in A.B b 'int'
+
+Nested s4;
+// CHECK-DAG: CXXRecordDecl {{.*}} imported in A struct Nested
+// CHECK-DAG: -FieldDecl {{.*}} in A fromb 'StructB'
+
+Enum e1;
+// CHECK-DAG: EnumDecl {{.*}} imported in A Enum_e
+// CHECK-DAG: -EnumConstantDecl {{.*}} imported in A a
+
+SomeClass *obj1;
+// CHECK-DAG: ObjCInterfaceDecl {{.*}} imported in A SomeClass
+
+Template t2;
+// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A struct Template
+
+Namespace::InNamespace t3;
+// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A struct InNamespace
+
+Namespace::AlsoInNamespace t4;
+// CHECK-DAG: ClassTemplateSpecializationDecl {{.*}} imported in A.B struct AlsoInNamespace
Index: lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
===
--- lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
+++ lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.cpp', '.m', '.s', '.test', '.ll']
+config.suffixes = ['.cpp', '.m', '.mm', '.s', '.test', '.ll']
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
@@ -0,0 +1,6 @@
+module A {
+  header "A.h"
+  module B {
+header "B.h"
+  }
+}
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
@@ -0,0 +1,8 @@
+typedef struct {
+  int b;
+} StructB;
+
+namespace Namespace {
+template struct AlsoInNamespace { T field; };
+ extern template struct AlsoInNamespace;
+}
Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
@@ -0,0 +1,30 @@
+#include "B.h" // -*- ObjC -*-
+
+typedef int Typedef;
+
+struct TopLevelStruct {
+  int a;
+};
+
+typedef struct Struct_s {
+  int a;
+} Struct;
+
+struct Nested {
+  StructB fromb;
+};
+
+typedef enum Enum_e {
+  a = 0
+} Enum;
+
+@interface SomeClass {}
+@end
+
+template struct Template { T field; };
+extern template struct Template;
+
+namespace Namespace {
+template struct InNamespace { T field; };
+extern template struct InNamespace;
+}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -78,6 +78,7 @@
   DIEToDeclContextMap;
   typedef std::multimap
   DeclContextToDIEMap;
+  typedef llvm::DenseMap DIEToModuleMap;
   typedef llvm::DenseMap
   DIEToDeclMap;
   typedef llvm::DenseMap DeclToDIEMap;
@@ -87,6 +88,7 @@
   DeclToDIEMap m_decl_to_die;
   DIEToDeclContextMap m_die_to_decl_ctx;
   DeclContextToDIEMap m_decl_ctx_to_die;
+  DIEToModuleMap m_die_to_module;
   std::unique_ptr m_clang_ast_importer_up;
   /// @}
 
@@ -140,6 +142,7 @@
 
   clang::DeclContext *GetClangDeclContextContainingDIE(const DWARFDIE ,
DWARFDIE *decl_ctx_die);
+  unsigned GetOwningModuleID(const DWARFDIE );
 
   bool 

[Lldb-commits] [PATCH] D75626: Add support for owning module information to TypeSystemClang.

2020-03-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: labath, jingham, teemperor, shafik.
aprantl added a child revision: D75488: Preserve the owning module information 
from DWARF in the synthesized AST.

This was split out from https://reviews.llvm.org/D75488.


https://reviews.llvm.org/D75626

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/TypeSystem.cpp
  lldb/unittests/Symbol/TestTypeSystemClang.cpp
  lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Index: lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
===
--- lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
+++ lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
@@ -27,7 +27,7 @@
 }
 
 inline CompilerType createRecord(TypeSystemClang , llvm::StringRef name) {
-  return ast.CreateRecordType(ast.getASTContext().getTranslationUnitDecl(),
+  return ast.CreateRecordType(ast.getASTContext().getTranslationUnitDecl(), 0,
   lldb::AccessType::eAccessPublic, name, 0,
   lldb::LanguageType::eLanguageTypeC);
 }
Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/Declaration.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "gtest/gtest.h"
 
@@ -258,8 +259,9 @@
   EXPECT_TRUE(basic_compiler_type.IsValid());
 
   CompilerType enum_type =
-  ast.CreateEnumerationType("my_enum", ast.GetTranslationUnitDecl(),
+  ast.CreateEnumerationType("my_enum", ast.GetTranslationUnitDecl(), 0,
 Declaration(), basic_compiler_type, scoped);
+
   CompilerType t = ast.GetEnumerationIntegerType(enum_type);
   // Check that the type we put in at the start is found again.
   EXPECT_EQ(basic_compiler_type.GetTypeName(), t.GetTypeName());
@@ -267,13 +269,37 @@
   }
 }
 
+TEST_F(TestTypeSystemClang, TestOwningModule) {
+  TypeSystemClang ast("module_ast", HostInfo::GetTargetTriple());
+  CompilerType basic_compiler_type = ast.GetBasicType(BasicType::eBasicTypeInt);
+  CompilerType enum_type =
+  ast.CreateEnumerationType("my_enum", ast.GetTranslationUnitDecl(), 100,
+Declaration(), basic_compiler_type, false);
+  auto *ed = TypeSystemClang::GetAsEnumDecl(enum_type);
+  EXPECT_FALSE(!ed);
+  EXPECT_EQ(ed->getOwningModuleID(), 100u);
+
+  CompilerType record_type = ast.CreateRecordType(
+  nullptr, 200, lldb::eAccessPublic, "FooRecord", clang::TTK_Struct,
+  lldb::eLanguageTypeC_plus_plus, nullptr);
+  auto *rd = TypeSystemClang::GetAsRecordDecl(record_type);
+  EXPECT_FALSE(!rd);
+  EXPECT_EQ(rd->getOwningModuleID(), 200u);
+
+  CompilerType class_type = ast.CreateObjCClass(
+  "objc_class", ast.GetTranslationUnitDecl(), 300, false, false);
+  auto *cd = TypeSystemClang::GetAsObjCInterfaceDecl(class_type);
+  EXPECT_FALSE(!cd);
+  EXPECT_EQ(cd->getOwningModuleID(), 300u);
+}
+
 TEST_F(TestTypeSystemClang, TestIsClangType) {
   clang::ASTContext  = m_ast->getASTContext();
   lldb::opaque_compiler_type_t bool_ctype =
   TypeSystemClang::GetOpaqueCompilerType(, lldb::eBasicTypeBool);
   CompilerType bool_type(m_ast.get(), bool_ctype);
   CompilerType record_type = m_ast->CreateRecordType(
-  nullptr, lldb::eAccessPublic, "FooRecord", clang::TTK_Struct,
+  nullptr, 100, lldb::eAccessPublic, "FooRecord", clang::TTK_Struct,
   lldb::eLanguageTypeC_plus_plus, nullptr);
   // Clang builtin type and record type should pass
   EXPECT_TRUE(ClangUtil::IsClangType(bool_type));
@@ -285,7 +311,7 @@
 
 TEST_F(TestTypeSystemClang, TestRemoveFastQualifiers) {
   CompilerType record_type = m_ast->CreateRecordType(
-  nullptr, lldb::eAccessPublic, "FooRecord", clang::TTK_Struct,
+  nullptr, 0, lldb::eAccessPublic, "FooRecord", clang::TTK_Struct,
   

[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-04 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

Seems great to me.  Getting the host platform is a generally useful thing to be 
able to do, and I can't think of anything you would want to add to this, so 
that is fine to.


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

https://reviews.llvm.org/D74903



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


[Lldb-commits] [lldb] e98ef0a - [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp

2020-03-04 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-03-04T10:32:50-08:00
New Revision: e98ef0af2c725f12dc60556a039e947ddeeb9f42

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

LOG: [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 4d98d9cbdda3..6a8c7bd46559 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -190,8 +190,8 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
 
   if (log) {
 LLDB_LOG(log,
- "CompleteTagDecl on (ASTContext*){1} Completing "
- "(TagDecl*){2} named {3}",
+ "CompleteTagDecl on (ASTContext*){0} Completing "
+ "(TagDecl*){1} named {2}",
  m_clang_ast_context->getDisplayName(), tag_decl,
  tag_decl->getName());
 
@@ -220,7 +220,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   ClangASTImporter::NamespaceMapSP namespace_map =
   m_ast_importer_sp->GetNamespaceMap(namespace_context);
 
-  LLDB_LOGV(log, "  CTD Inspecting namespace map{1} ({2} entries)",
+  LLDB_LOGV(log, "  CTD Inspecting namespace map{0} ({1} entries)",
 namespace_map.get(), namespace_map->size());
 
   if (!namespace_map)
@@ -229,7 +229,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
 e = namespace_map->end();
i != e && !found; ++i) {
-LLDB_LOG(log, "  CTD Searching namespace {1} in module {2}",
+LLDB_LOG(log, "  CTD Searching namespace {0} in module {1}",
  i->second.GetName(), i->first->GetFileSpec().GetFilename());
 
 TypeList types;
@@ -478,12 +478,12 @@ void ClangASTSource::FindExternalLexicalDecls(
 std::string ast_dump = ClangUtil::DumpDecl(decl);
 if (const NamedDecl *context_named_decl =
 dyn_cast(context_decl))
-  LLDB_LOG(log, "  FELD Adding [to {1}Decl {2}] lexical {3}Decl {4}",
+  LLDB_LOG(log, "  FELD Adding [to {0}Decl {1}] lexical {2}Decl 34}",
context_named_decl->getDeclKindName(),
context_named_decl->getName(), decl->getDeclKindName(),
ast_dump);
 else
-  LLDB_LOG(log, "  FELD Adding lexical {1}Decl {2}",
+  LLDB_LOG(log, "  FELD Adding lexical {0}Decl {1}",
decl->getDeclKindName(), ast_dump);
   }
 
@@ -527,19 +527,19 @@ void 
ClangASTSource::FindExternalVisibleDecls(NameSearchContext ) {
 if (!context.m_decl_context)
   LLDB_LOG(log,
"ClangASTSource::FindExternalVisibleDecls on "
-   "(ASTContext*){1} '{2}' for '{3}' in a NULL DeclContext",
+   "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
m_ast_context, m_clang_ast_context->getDisplayName(), name);
 else if (const NamedDecl *context_named_decl =
  dyn_cast(context.m_decl_context))
   LLDB_LOG(log,
"ClangASTSource::FindExternalVisibleDecls on "
-   "(ASTContext*){1} '{2}' for '{3}' in '{4}'",
+   "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
m_ast_context, m_clang_ast_context->getDisplayName(), name,
context_named_decl->getName());
 else
   LLDB_LOG(log,
"ClangASTSource::FindExternalVisibleDecls on "
-   "(ASTContext*){1} '{2}' for '{3}' in a '{4}'",
+   "(ASTContext*){0} '{1}' for '{2}' in a '{3}'",
m_ast_context, m_clang_ast_context->getDisplayName(), name,
context.m_decl_context->getDeclKindName());
   }
@@ -631,7 +631,7 @@ void ClangASTSource::FindExternalVisibleDecls(
   if (log) {
 const char *name_string = type_sp->GetName().GetCString();
 
-LLDB_LOG(log, "  CAS::FEVD Matching type found for \"{1}\": {2}", name,
+LLDB_LOG(log, "  CAS::FEVD Matching type found for \"{0}\": {1}", name,
  (name_string ? name_string : ""));
   }
 
@@ -682,7 +682,7 @@ void ClangASTSource::FillNamespaceMap(
 std::pair(
 module_sp, found_namespace_decl));
 
-LLDB_LOG(log, "  CAS::FEVD Found namespace {1} in module {2}", name,
+LLDB_LOG(log, "  CAS::FEVD Found namespace {0} in module {1}", name,
  module_sp->GetFileSpec().GetFilename());

[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-04 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 248213.
tatyana-krasnukha added a comment.

Added `--all` property to `settings clear` + added a test


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D75537

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/expression/fixits/TestFixIts.py
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -522,6 +522,36 @@
 self.expect("settings remove ''", error=True,
 substrs=["'settings remove' command requires a valid variable name"])
 
+def test_settings_clear_all(self):
+# Save the initial state of settings.
+command_interpreter = self.dbg.GetCommandInterpreter()
+self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+result = lldb.SBCommandReturnObject()
+command_interpreter.HandleCommand("settings show", result)
+default_values = result.GetOutput()
+
+# Change a dictionary.
+self.runCmd("settings set target.env-vars a=1 b=2 c=3")
+# Change an array.
+self.runCmd("settings set target.run-args a b c")
+# Change a single boolean value.
+self.runCmd("settings set auto-confirm true")
+# Change a single integer value.
+self.runCmd("settings set term-width 120")
+
+# Clear everything.
+self.runCmd("settings clear --all")
+
+# Apply Setup commands again.
+for s in self.setUpCommands():
+self.runCmd(s)
+
+# Check that settings have their default values after clearing.
+command_interpreter.HandleCommand("settings show", result)
+after_clear = result.GetOutput()
+self.maxDiff = None # Disable diff limit to compare setting dumps.
+self.assertEqual(default_values, after_clear)
+
 def test_all_settings_exist(self):
 self.expect("settings show",
 substrs=["auto-confirm",
Index: lldb/test/API/commands/expression/fixits/TestFixIts.py
===
--- lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -29,6 +29,10 @@
 
 def test_with_dummy_target(self):
 """Test calling expressions in the dummy target with errors that can be fixed by the FixIts."""
+
+# Enable fix-its as they were intentionally disabled by TestBase.setUp.
+self.runCmd("settings set target.auto-apply-fixits true")
+
 ret_val = lldb.SBCommandReturnObject()
 result = self.dbg.GetCommandInterpreter().HandleCommand("expression ((1 << 16) - 1))", ret_val)
 self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "The expression was successful.")
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@
 Desc<"The file from which to read the settings.">;
 }
 
+let Command = "settings clear" in {
+  def setclear_all : Option<"all", "a">,
+Desc<"Clear all settings.">;
+}
+
 let Command = "breakpoint list" in {
   // FIXME: We need to add an "internal" command, and then add this sort of
   // thing to it. But I need to see it for now, and don't want to wait.
Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1043,13 +1043,16 @@
 };
 
 // CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
 
 class CommandObjectSettingsClear : public CommandObjectParsed {
 public:
   CommandObjectSettingsClear(CommandInterpreter )
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) {
+"Clear a debugger setting array, dictionary, or string. "
+"If '-a' option is specified, it clears all settings.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1077,9 +1080,47 @@
   request, nullptr);
   }
 
+   Options *GetOptions() override { return _options; }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() = default;
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  const int short_option = 

[Lldb-commits] [lldb] 0ab109d - [lldb][NFC] Modernize logging UserExpression

2020-03-04 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-03-04T09:04:54-08:00
New Revision: 0ab109d43d9d8389fe686ee8df4a82634f246b55

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

LOG: [lldb][NFC] Modernize logging UserExpression

Added: 


Modified: 
lldb/source/Expression/UserExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index 3bfb5f27e6c6..0243cc0c3750 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -168,8 +168,8 @@ UserExpression::Evaluate(ExecutionContext _ctx,
 
   Target *target = exe_ctx.GetTargetPtr();
   if (!target) {
-LLDB_LOGF(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
-   "run expressions.");
+LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
+  "run expressions.");
 error.SetErrorString("expression passed a null target");
 return lldb::eExpressionSetupError;
   }
@@ -178,9 +178,8 @@ UserExpression::Evaluate(ExecutionContext _ctx,
 
   if (process == nullptr || process->GetState() != lldb::eStateStopped) {
 if (execution_policy == eExecutionPolicyAlways) {
-  LLDB_LOGF(log,
-"== [UserExpression::Evaluate] Expression may not run, but "
-"is not constant ==");
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but 
"
+"is not constant ==");
 
   error.SetErrorString("expression needed to run but couldn't");
 
@@ -225,15 +224,13 @@ UserExpression::Evaluate(ExecutionContext _ctx,
desired_type, options, ctx_obj,
error));
   if (error.Fail()) {
-if (log)
-  LLDB_LOGF(log, "== [UserExpression::Evaluate] Getting expression: %s ==",
-error.AsCString());
+LLDB_LOG(log, "== [UserExpression::Evaluate] Getting expression: {0} ==",
+ error.AsCString());
 return lldb::eExpressionSetupError;
   }
 
-  if (log)
-LLDB_LOGF(log, "== [UserExpression::Evaluate] Parsing expression %s ==",
-  expr.str().c_str());
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Parsing expression {0} ==",
+   expr.str());
 
   const bool keep_expression_in_memory = true;
   const bool generate_debug_info = options.GetGenerateDebugInfo();
@@ -306,10 +303,8 @@ UserExpression::Evaluate(ExecutionContext _ctx,
 
 if (execution_policy == eExecutionPolicyNever &&
 !user_expression_sp->CanInterpret()) {
-  if (log)
-LLDB_LOGF(log,
-  "== [UserExpression::Evaluate] Expression may not run, but "
-  "is not constant ==");
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but 
"
+"is not constant ==");
 
   if (!diagnostic_manager.Diagnostics().size())
 error.SetExpressionError(lldb::eExpressionSetupError,
@@ -329,17 +324,15 @@ UserExpression::Evaluate(ExecutionContext _ctx,
 
   diagnostic_manager.Clear();
 
-  if (log)
-LLDB_LOGF(log, "== [UserExpression::Evaluate] Executing expression 
==");
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Executing expression ==");
 
   execution_results =
   user_expression_sp->Execute(diagnostic_manager, exe_ctx, options,
   user_expression_sp, expr_result);
 
   if (execution_results != lldb::eExpressionCompleted) {
-if (log)
-  LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
- "abnormally ==");
+LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
+  "abnormally ==");
 
 if (!diagnostic_manager.Diagnostics().size())
   error.SetExpressionError(
@@ -351,15 +344,13 @@ UserExpression::Evaluate(ExecutionContext _ctx,
 if (expr_result) {
   result_valobj_sp = expr_result->GetValueObject();
 
-  if (log)
-LLDB_LOGF(log,
-  "== [UserExpression::Evaluate] Execution completed "
-  "normally with result %s ==",
-  result_valobj_sp->GetValueAsCString());
+  LLDB_LOG(log,
+   "== [UserExpression::Evaluate] Execution completed "
+   "normally with result %s ==",
+   result_valobj_sp->GetValueAsCString());
 } else {
-  if (log)
-LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
-   "normally with no result ==");
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
+

[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2020-03-04 Thread Hans Wennborg via Phabricator via lldb-commits
hans added a comment.

There were some concerns raised on this patch, and also in PR44780.

I think at this point it's safer to revert these changes and start over. I've 
pushed the revert in 916be8fd6a0a0feea4cefcbeb0c22c65848d7a2e 
 and will 
merge that to 10.x after it's baked a little.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70764



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


[Lldb-commits] [PATCH] D75607: [lldb] Use llvm::MC for register numbers in AArch64 ABIs

2020-03-04 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp:29-32
+  if (name == "pc")
+return {LLDB_INVALID_REGNUM, arm64_dwarf::pc};
+  if (name == "cpsr")
+return {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr};

This is here to ensure identical behavior to the previous code, but I am not 
sure it is really needed/correct. 
[[https://developer.arm.com/docs/ihi0057/c/dwarf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4
 | Arm-dwarf spec ]] does not assign a register number to the pc (number 32, 
used by lldb, is reserved) or cpsr (number 33 is assigned to ELR_mode).

Llvm does not use either of these numbers, so at least no llvm-based toolchain 
should be generating them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75607



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


[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-03-04 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c17cc531f9f: [lldb] Make BreakpointResolver hold weak_ptr 
instead of raw pointer to… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D74557?vs=244727=248166#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -622,7 +622,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -153,17 +153,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint ) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP ) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint();
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -180,7 +180,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP , ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint ) override {
+  CopyForBreakpoint(lldb::BreakpointSP ) override {
 lldb::BreakpointResolverSP ret_sp(
-new RSBreakpointResolver(, m_kernel_name));
+new RSBreakpointResolver(breakpoint, m_kernel_name));
 return ret_sp;
   }
 
@@ -100,7 +100,7 @@
   

[Lldb-commits] [PATCH] D75607: [lldb] Use llvm::MC for register numbers in AArch64 ABIs

2020-03-04 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, jasonmolenda.
Herald added subscribers: kristof.beyls, aprantl.
Herald added a project: LLDB.
labath marked an inline comment as done.
labath added inline comments.



Comment at: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp:29-32
+  if (name == "pc")
+return {LLDB_INVALID_REGNUM, arm64_dwarf::pc};
+  if (name == "cpsr")
+return {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr};

This is here to ensure identical behavior to the previous code, but I am not 
sure it is really needed/correct. 
[[https://developer.arm.com/docs/ihi0057/c/dwarf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4
 | Arm-dwarf spec ]] does not assign a register number to the pc (number 32, 
used by lldb, is reserved) or cpsr (number 33 is assigned to ELR_mode).

Llvm does not use either of these numbers, so at least no llvm-based toolchain 
should be generating them.


This is equivalent to previous patches (e.g. 07355c1c0 
) for the 
x86 ABIs.

One name fixup is needed -- lldb refers to the floating/vector registers by
their vector name (vN). Llvm does not use this name, so we map it to qN,
representing the register as a single 128 bit value (this choice is fairly
arbitrary -- any other name would also work fine as they all have the same
DWARF number).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75607

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h

Index: lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
+++ lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
@@ -9,10 +9,10 @@
 #ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
 #define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
 
-#include "lldb/Target/ABI.h"
+#include "Plugins/ABI/AArch64/ABIAArch64.h"
 #include "lldb/lldb-private.h"
 
-class ABISysV_arm64 : public lldb_private::RegInfoBasedABI {
+class ABISysV_arm64 : public ABIAArch64 {
 public:
   ~ABISysV_arm64() override = default;
 
@@ -65,9 +65,6 @@
 return true;
   }
 
-  const lldb_private::RegisterInfo *
-  GetRegisterInfoArray(uint32_t ) override;
-
   bool GetPointerReturnRegister(const char *) override;
 
   // Static Functions
@@ -92,7 +89,7 @@
lldb_private::CompilerType _type) const override;
 
 private:
-  using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
+  using ABIAArch64::ABIAArch64; // Call CreateInstance instead.
 };
 
 #endif // LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
Index: lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
@@ -33,1626 +33,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static RegisterInfo g_register_infos[] = {
-//  NAME   ALT   SZ OFF ENCODING  FORMAT
-//  EH_FRAME DWARF  GENERIC
-//  PROCESS PLUGIN  LLDB NATIVE
-//  == ===   == === = ===
-//  ===  == ===
-//  === ==
-{"x0",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1,
-  LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"x1",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2,
-  LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"x2",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3,
-  LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"x3",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4,
-  LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"x4",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5,
-  LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 

[Lldb-commits] [lldb] 6c17cc5 - [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-03-04 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-03-04T16:56:50+03:00
New Revision: 6c17cc531f9f4ee94f2298200fc4813c02999d78

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

LOG: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to 
breakpoint

This prevents calling Breakpoint::shared_from_this of an object that is not 
owned by any shared_ptr.

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

Added: 


Modified: 
lldb/include/lldb/Breakpoint/BreakpointResolver.h
lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
lldb/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
lldb/include/lldb/Target/LanguageRuntime.h
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Breakpoint/BreakpointResolver.cpp
lldb/source/Breakpoint/BreakpointResolverAddress.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Breakpoint/BreakpointResolverScripted.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h

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

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h

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

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

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
lldb/source/Target/LanguageRuntime.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolver.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolver.h
index 9201b643ce6f..3029f70ce9c3 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolver.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolver.h
@@ -44,7 +44,8 @@ class BreakpointResolver : public Searcher {
   ///   The breakpoint that owns this resolver.
   /// \param[in] resolverType
   ///   The concrete breakpoint resolver type for this breakpoint.
-  BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType,
+  BreakpointResolver(const lldb::BreakpointSP ,
+ unsigned char resolverType,
  lldb::addr_t offset = 0);
 
   /// The Destructor is virtual, all significant breakpoint resolvers derive
@@ -55,7 +56,15 @@ class BreakpointResolver : public Searcher {
   ///
   /// \param[in] bkpt
   ///   The breakpoint that owns this resolver.
-  void SetBreakpoint(Breakpoint *bkpt);
+  void SetBreakpoint(const lldb::BreakpointSP );
+
+  /// This gets the breakpoint for this resolver.
+  lldb::BreakpointSP GetBreakpoint() const {
+auto breakpoint_sp = m_breakpoint.expired() ? lldb::BreakpointSP() :
+  m_breakpoint.lock();
+assert(breakpoint_sp);
+return breakpoint_sp;
+  }
 
   /// This updates the offset for this breakpoint.  All the locations
   /// currently set for this breakpoint will have their offset adjusted when
@@ -149,7 +158,7 @@ class BreakpointResolver : public Searcher {
   static ResolverTy NameToResolverTy(llvm::StringRef name);
 
   virtual lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint ) = 0;
+  CopyForBreakpoint(lldb::BreakpointSP ) = 0;
 
 protected:
   // Used for serializing resolver options:
@@ -202,15 +211,15 @@ class BreakpointResolver : public Searcher {
   lldb::BreakpointLocationSP AddLocation(Address loc_addr,
  bool *new_location = nullptr);
 
-  Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
-  lldb::addr_t m_offset;// A random offset the user asked us to add to any
-// breakpoints we set.
-
 private:
   /// Helper for \p SetSCMatchesByLine.
   void AddLocation(SearchFilter , const SymbolContext ,
bool skip_prologue, llvm::StringRef log_ident);
 
+  lldb::BreakpointWP m_breakpoint; // This is the breakpoint we add locations 
to.
+  lldb::addr_t m_offset;// A random offset the user asked us to add to any
+// breakpoints we set.
+
   // Subclass identifier (for llvm isa/dyn_cast)
   const unsigned char SubclassID;
   DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);

diff  --git 

[Lldb-commits] [lldb] b1324e7 - [lldb][NFC] Move local variables near to their usage

2020-03-04 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-03-04T16:56:51+03:00
New Revision: b1324e74da2661e799b9fad037948e70d002b771

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

LOG: [lldb][NFC] Move local variables near to their usage

Added: 


Modified: 
lldb/source/Breakpoint/BreakpointResolverName.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 551cd83b093a..2eb0d3ab5888 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -249,13 +249,6 @@ void BreakpointResolverName::AddNameLookup(ConstString 
name,
 Searcher::CallbackReturn
 BreakpointResolverName::SearchCallback(SearchFilter ,
SymbolContext , Address *addr) {
-  SymbolContextList func_list;
-  // SymbolContextList sym_list;
-
-  uint32_t i;
-  bool new_location;
-  Address break_addr;
-
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
 
   if (m_class_name) {
@@ -264,6 +257,7 @@ BreakpointResolverName::SearchCallback(SearchFilter ,
 return Searcher::eCallbackReturnStop;
   }
 
+  SymbolContextList func_list;
   bool filter_by_cu =
   (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
   bool filter_by_language = (m_language != eLanguageTypeUnknown);
@@ -334,11 +328,12 @@ BreakpointResolverName::SearchCallback(SearchFilter 
,
 
   BreakpointSP breakpoint_sp = GetBreakpoint();
   Breakpoint  = *breakpoint_sp;
+  Address break_addr;
 
   // Remove any duplicates between the function list and the symbol list
   SymbolContext sc;
   if (func_list.GetSize()) {
-for (i = 0; i < func_list.GetSize(); i++) {
+for (uint32_t i = 0; i < func_list.GetSize(); i++) {
   if (func_list.GetContextAtIndex(i, sc)) {
 bool is_reexported = false;
 
@@ -381,6 +376,7 @@ BreakpointResolverName::SearchCallback(SearchFilter ,
 
 if (break_addr.IsValid()) {
   if (filter.AddressPasses(break_addr)) {
+bool new_location;
 BreakpointLocationSP bp_loc_sp(
 AddLocation(break_addr, _location));
 bp_loc_sp->SetIsReExported(is_reexported);



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


[Lldb-commits] [lldb] 3245dd5 - [lldb] Reduce duplication in CommandObjectDisassemble

2020-03-04 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-03-04T13:47:35+01:00
New Revision: 3245dd59b124cbfce8cdce1f2c90e843d57d8722

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

LOG: [lldb] Reduce duplication in CommandObjectDisassemble

This command had nearly identical code for the "then" and "else"
branches of the "if (m_options.num_instructions != 0)" condition.

This patch factors out the common parts of the two blocks to reduce
duplication.

Added: 


Modified: 
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/test/Shell/Commands/Inputs/command-disassemble-process.lldbinit
lldb/test/Shell/Commands/command-disassemble-process.yaml

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index d51313357fee..0645119767da 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -424,94 +424,64 @@ bool CommandObjectDisassemble::DoExecute(Args ,
 } else
   ranges.push_back(range);
 
-if (m_options.num_instructions != 0) {
-  if (ranges.empty()) {
-// The default action is to disassemble the current frame function.
-if (frame) {
-  SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
-   eSymbolContextSymbol));
-  if (sc.function)
-range.GetBaseAddress() =
-sc.function->GetAddressRange().GetBaseAddress();
-  else if (sc.symbol && sc.symbol->ValueIsAddress())
-range.GetBaseAddress() = sc.symbol->GetAddress();
-  else
-range.GetBaseAddress() = frame->GetFrameCodeAddress();
-}
-
-if (!range.GetBaseAddress().IsValid()) {
-  result.AppendError("invalid frame");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-}
+if (ranges.empty()) {
+  // The default action is to disassemble the current frame function.
+  if (frame) {
+SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
+ eSymbolContextSymbol));
+if (sc.function)
+  range = sc.function->GetAddressRange();
+else if (sc.symbol && sc.symbol->ValueIsAddress()) {
+  range.GetBaseAddress() = sc.symbol->GetAddress();
+  range.SetByteSize(sc.symbol->GetByteSize());
+} else
+  range.GetBaseAddress() = frame->GetFrameCodeAddress();
   }
-
-  bool print_sc_header = ranges.size() > 1;
-  for (AddressRange cur_range : ranges) {
-if (Disassembler::Disassemble(
-GetDebugger(), m_options.arch, plugin_name, flavor_string,
-m_exe_ctx, cur_range.GetBaseAddress(),
-m_options.num_instructions, m_options.show_mixed,
-m_options.show_mixed ? m_options.num_lines_context : 0, 
options,
-result.GetOutputStream())) {
-  result.SetStatus(eReturnStatusSuccessFinishResult);
-} else {
-  if (m_options.start_addr != LLDB_INVALID_ADDRESS)
-result.AppendErrorWithFormat(
-"Failed to disassemble memory at 0x%8.8" PRIx64 ".\n",
-m_options.start_addr);
-  else if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS)
-result.AppendErrorWithFormat(
-"Failed to disassemble memory in function at 0x%8.8" PRIx64
-".\n",
-m_options.symbol_containing_addr);
-  result.SetStatus(eReturnStatusFailed);
-}
-  }
-  if (print_sc_header)
-result.AppendMessage("\n");
-} else {
-  if (ranges.empty()) {
-// The default action is to disassemble the current frame function.
-if (frame) {
-  SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
-   eSymbolContextSymbol));
-  if (sc.function)
-range = sc.function->GetAddressRange();
-  else if (sc.symbol && sc.symbol->ValueIsAddress()) {
-range.GetBaseAddress() = sc.symbol->GetAddress();
-range.SetByteSize(sc.symbol->GetByteSize());
-  } else
-range.GetBaseAddress() = frame->GetFrameCodeAddress();
-} else {
-  result.AppendError("invalid frame");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-}
-ranges.push_back(range);
+  if (!range.GetBaseAddress().IsValid()) {
+result.AppendError("invalid frame");
+result.SetStatus(eReturnStatusFailed);
+return false;
   }
+  ranges.push_back(range);
+}
 
-  bool 

[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-04 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a reviewer: jingham.
labath added a comment.
This revision is now accepted and ready to land.

This is a great cleanup.

I don't believe the addition of the new SBPlatform interface is an issue, but 
I've added @jingham just in case he has any thoughts on that. Please give him a 
chance to comment on this.


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

https://reviews.llvm.org/D74903



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


[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a reviewer: jingham.
labath added a subscriber: jingham.
labath added a comment.

Clearing all settings is a reasonable operation, so I don't have any problem 
with it per se. I'm just wondering, given that this is not something that one 
would want to do very often (and it can have catastrophic results), whether 
this operation should not be more explicit. "settings clear --all" for instance 
? Adding @jingham for the interface aspects.

It would also be nice to add a test case for the new command.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D75537



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


[Lldb-commits] [PATCH] D73016: [lldb/CMake] Make it possible to disable plugins at configuration time

2020-03-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looking this over again, I do see two open questions.

The first is that there is a disconnect between the place which *declares* 
something to be a plugin (the PLUGIN argument to add_lldb_library), and the 
place which *disables* something as a plugin (the macro invocation in the 
parent CMakeLists.txt). This creates a lot of potential for confusion and 
inconsistencies -- and indeed this patch already introduces some of those.

The second is the boilerplate required to disable the relevant tests. Right now 
you've just added the couple of features that you needed to disable the plugins 
of your choosing, but if we did that for all plugins, the code to do that would 
become fairly repetitive.

I am wondering if there isn't a way to solve both of these problems. For 
example, if we moved the disabling logic to the `add_lldb_library` function, 
then we could guarantee that only "real" plugins are eligible for being 
disabled. Also, since we already maintain a list of all plugin libraries, we 
could use this list to generate the appropriate lit features.

This would mean that we would not be able to reuse the llvm logic for skipping 
a directory, but that is literally just 4 lines of code, so I don't think it 
would be much of an issue. That may even make sense, because that llvm 
machinery was meant for disabling tools or entire subprojects, and not as a 
fine-grained control mechanism like this. In fact, this feature is kind of more 
similar to one choosing which components go into libLLVM.so, which is handled 
by a separate mechanism (LLVM_DYLIB_COMPONENTS).

Finally (though I don't know if you would consider this a feature or not), this 
way we might be able to arrange things so that the relevant plugins still get 
built even though they don't make their way into liblldb. That way one could 
still ensure that the relevant plugins build properly, and their unit tests 
could still run.




Comment at: lldb/source/Plugins/LanguageRuntime/CMakeLists.txt:1-3
+add_lldb_plugin_subdirectory(CPlusPlus)
+add_lldb_plugin_subdirectory(ObjC)
+add_lldb_plugin_subdirectory(RenderScript)

This isn't right. The actual plugins are located one level down 
(CPlusPlus/ItaniumABI, ObjC/AppleObjCRuntime, RenderScript/RenderScriptRuntime)



Comment at: lldb/source/Plugins/Process/CMakeLists.txt:1-19
 if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
-  add_subdirectory(Linux)
-  add_subdirectory(POSIX)
+  add_lldb_plugin_subdirectory(Linux)
+  add_lldb_plugin_subdirectory(POSIX)
 elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-  add_subdirectory(FreeBSD)
-  add_subdirectory(POSIX)
+  add_lldb_plugin_subdirectory(FreeBSD)
+  add_lldb_plugin_subdirectory(POSIX)
 elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")

Some of these (Utility, Linux, NetBSD) aren't "real" plugins.


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

https://reviews.llvm.org/D73016



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


[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This sounds like it could be useful though I can't say I really no much about 
modules.

I appreciate the effort in splitting this patch up, but I am wondering if we 
couldn't do this is one more step. Would it be possible to split the TypeSystem 
changes into a patch of its own (with some TypeSystemClang unit tests), and 
then have separate a patch where SymbolFileDWARF starts making use of this 
functionality? I think that would make easier to follow what's going in the two 
subsystems/plugins as well as reduce some of the noise caused by the interface 
changes.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:224
+if (auto *rd = llvm::dyn_cast(tag_decl))
+  for (auto *f : rd->fields())
+TypeSystemClang::SetOwningModule(f, owning_module);

Maybe spell out the type here? I have no idea what's the type of this..



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:57-78
+  /// The Layout is as follows:
+  /// \verbatim
+  /// bit 0..30 ... Owning Module ID.
+  /// bit 31 .. IsCompleteObjCClass.
+  /// \endverbatim
   uint32_t _payload;
 public:

Maybe it would be simpler to have a struct full of bitfields and then just 
memcpy it to/from the uint32_t in the constructor/destructor?



Comment at: lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h:24
+extern template struct InNamespace;
+}

How about a case where A.h defines a type which references a type from B.h 
(e.g. contains it as a member variable) ?



Comment at: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm:1
+// RUN: %clang_host -g -gmodules -fmodules -fmodules-cache-path=%t.cache \
+// RUN:-c -o %t.o %s -I%S/Inputs

I think this test will fail on windows. At least it did fail for me when I 
manually forced a windows target here (linux was fine though). I think the 
problem is that lldb does not know how to open an unlinked COFF file.

I think it would be better to hardcode a triple here instead of using 
%clang_host.


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

https://reviews.llvm.org/D75488



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