[Lldb-commits] [lldb] a0fb69d - [lldb][DWARF5] Enable macro evaluation

2022-09-14 Thread Pavel Kosov via lldb-commits

Author: Pavel Kosov
Date: 2022-09-14T11:32:07+03:00
New Revision: a0fb69d17b4d7501a85554010727837340e7b52f

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

LOG: [lldb][DWARF5] Enable macro evaluation

Patch enables handing of DWARFv5 DW_MACRO_define_strx and DW_MACRO_undef_strx

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg

Reviewed By: clayborg

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

Added: 
lldb/test/API/lang/c/macro/Makefile
lldb/test/API/lang/c/macro/TestMacro.py
lldb/test/API/lang/c/macro/main.c

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/test/API/commands/expression/macros/Makefile
lldb/test/API/commands/expression/macros/TestMacros.py

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
index 37e28a09f3c45..c357033aa91d7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -92,8 +92,8 @@ const DWARFDataExtractor 
&DWARFContext::getOrLoadLocListsData() {
 }
 
 const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() {
-  return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None,
-  m_data_debug_macro);
+  return LoadOrGetSection(eSectionTypeDWARFDebugMacro,
+  eSectionTypeDWARFDebugMacro, m_data_debug_macro);
 }
 
 const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() {

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
index 19c6448c4e74a..d7a43a3f9c68b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
@@ -16,6 +16,11 @@
 using namespace lldb_private;
 using namespace lldb_private::dwarf;
 
+uint64_t DWARFStrOffsetsInfo::GetOffset(uint64_t index) const {
+  uint64_t offset = cu_str_offset + data.GetDWARFSizeOfOffset() * index;
+  return data.GetU32(&offset);
+}
+
 DWARFDebugMacroHeader
 DWARFDebugMacroHeader::ParseHeader(const DWARFDataExtractor &debug_macro_data,
lldb::offset_t *offset) {
@@ -59,7 +64,8 @@ void DWARFDebugMacroHeader::SkipOperandTable(
 
 void DWARFDebugMacroEntry::ReadMacroEntries(
 const DWARFDataExtractor &debug_macro_data,
-const DWARFDataExtractor &debug_str_data, const bool offset_is_64_bit,
+const DWARFDataExtractor &debug_str_data,
+const DWARFStrOffsetsInfo *str_offsets_info, const bool offset_is_64_bit,
 lldb::offset_t *offset, SymbolFileDWARF *sym_file_dwarf,
 DebugMacrosSP &debug_macros_sp) {
   llvm::dwarf::MacroEntryType type =
@@ -97,6 +103,22 @@ void DWARFDebugMacroEntry::ReadMacroEntries(
 debug_macros_sp->AddMacroEntry(
 DebugMacroEntry::CreateUndefEntry(line, macro_str));
   break;
+case DW_MACRO_define_strx:
+case DW_MACRO_undef_strx:
+  line = debug_macro_data.GetULEB128(offset);
+  str_offset = debug_macro_data.GetULEB128(offset);
+  if (!str_offsets_info)
+// Can't do much in this case, skip all such entries
+continue;
+  str_offset = str_offsets_info->GetOffset(str_offset);
+  macro_str = debug_str_data.GetCStr(&str_offset);
+  if (type == DW_MACRO_define_strx)
+debug_macros_sp->AddMacroEntry(
+DebugMacroEntry::CreateDefineEntry(line, macro_str));
+  else
+debug_macros_sp->AddMacroEntry(
+DebugMacroEntry::CreateUndefEntry(line, macro_str));
+  break;
 case DW_MACRO_start_file:
   line = debug_macro_data.GetULEB128(offset);
   debug_line_file_idx = debug_macro_data.GetULEB128(offset);
@@ -113,7 +135,7 @@ void DWARFDebugMacroEntry::ReadMacroEntries(
   else
 new_offset = debug_macro_data.GetU32(offset);
   debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateIndirectEntry(
-  sym_file_dwarf->ParseDebugMacros(&new_offset)));
+  sym_file_dwarf->ParseDebugMacros(&new_offset, str_offsets_info)));
   break;
 default:
   // TODO: Add support for other standard operations.

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
index cbf762458331b..27be105b5949a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
@@ -24,6 +24,17 @@ class DWARFDataExtractor;
 
 class SymbolFi

[Lldb-commits] [PATCH] D130062: [lldb][DWARF5] Enable macro evaluation

2022-09-14 Thread Pavel Kosov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0fb69d17b4d: [lldb][DWARF5] Enable macro evaluation 
(authored by kpdev42).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130062

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/API/commands/expression/macros/Makefile
  lldb/test/API/commands/expression/macros/TestMacros.py
  lldb/test/API/lang/c/macro/Makefile
  lldb/test/API/lang/c/macro/TestMacro.py
  lldb/test/API/lang/c/macro/main.c

Index: lldb/test/API/lang/c/macro/main.c
===
--- /dev/null
+++ lldb/test/API/lang/c/macro/main.c
@@ -0,0 +1,7 @@
+#define DM 10
+#define DF(x) (42 + (x))
+
+int main (int argc, char const *argv[])
+{
+return 0;  Set break point at this line.
+}
Index: lldb/test/API/lang/c/macro/TestMacro.py
===
--- /dev/null
+++ lldb/test/API/lang/c/macro/TestMacro.py
@@ -0,0 +1,31 @@
+"""Tests lldb macro evaluation."""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MacroTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+# Find the line number to break inside main().
+self.line = line_number('main.c', '// Set break point at this line.')
+
+def test(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Break inside the main.
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("expr DM + DF(10)", VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['int', '62'])
+
Index: lldb/test/API/lang/c/macro/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/c/macro/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -fdebug-macro
+
+include Makefile.rules
Index: lldb/test/API/commands/expression/macros/TestMacros.py
===
--- lldb/test/API/commands/expression/macros/TestMacros.py
+++ lldb/test/API/commands/expression/macros/TestMacros.py
@@ -8,12 +8,6 @@
 
 class TestMacros(TestBase):
 
-@expectedFailureAll(
-compiler="clang",
-bugnumber="clang does not emit .debug_macro[.dwo] sections.")
-@expectedFailureAll(
-debug_info="dwo",
-bugnumber="GCC produces multiple .debug_macro.dwo sections and the spec is unclear as to what it means")
 @expectedFailureAll(
 hostoslist=["windows"],
 compiler="gcc",
Index: lldb/test/API/commands/expression/macros/Makefile
===
--- lldb/test/API/commands/expression/macros/Makefile
+++ lldb/test/API/commands/expression/macros/Makefile
@@ -5,5 +5,6 @@
 # GCC produces incorrect .debug_macro section when "-include" option is used:
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93075.
 NO_TEST_COMMON_H := 1
+CFLAGS_EXTRAS := -fdebug-macro
 
 include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -55,6 +55,8 @@
 class SymbolFileDWARFDwo;
 class SymbolFileDWARFDwp;
 
+class DWARFStrOffsetsInfo;
+
 #define DIE_IS_BEING_PARSED ((lldb_private::Type *)1)
 
 class SymbolFileDWARF : public lldb_private::SymbolFileCommon,
@@ -246,7 +248,9 @@
 
   bool Supports_DW_AT_APPLE_objc_complete_type(DWARFUnit *cu);
 
-  lldb_private::DebugMacrosSP ParseDebugMacros(lldb::offset_t *offset);
+  lldb_private::DebugMacrosSP
+  ParseDebugMacros(lldb::offset_t *offset,
+   const DWARFStrOffsetsInfo *str_offsets_info);
 
   static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1194,7 +1194,8 @@
 }
 
 lldb_private::DebugMacrosSP
-SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) {
+SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset,
+  

[Lldb-commits] [PATCH] D132316: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2

2022-09-14 Thread Sebastian Neubauer via Phabricator via lldb-commits
sebastian-ne accepted this revision.
sebastian-ne added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132316

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


[Lldb-commits] [lldb] d079bf3 - [lldb] Enable (un-xfail) some dwarf tests for arm

2022-09-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2022-09-14T11:35:16+02:00
New Revision: d079bf33decf25a40a219d7ea47d84ecdb61b5e6

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

LOG: [lldb] Enable (un-xfail) some dwarf tests for arm

These are passing now that the relocation assertion has been removed in
D132954.

Relocations still remain unimplemented though, so it's possible this may
start to fail due to unrelated changes. If that happens very often, we
may just need to disable (skip) the test instead.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll

lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
lldb/test/Shell/SymbolFile/DWARF/split-optimized.c

Removed: 




diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll 
b/lldb/test/Shell/SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll
index ee39599e7c388..c61012b605352 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll
+++ b/lldb/test/Shell/SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll
@@ -1,4 +1,3 @@
-; XFAIL: target-arm && linux-gnu
 ; UNSUPPORTED: system-windows
 ;
 ; This test verifies that we do the right thing with DIFlagExportSymbols which 
is the new

diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
 
b/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
index bede0eab90d2c..5cc39bc351b29 100644
--- 
a/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
+++ 
b/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
@@ -1,4 +1,3 @@
-// XFAIL: target-arm && linux-gnu
 // UNSUPPORTED: system-windows
 //
 // Test to verify we are correctly generating anonymous flags when parsing

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/split-optimized.c 
b/lldb/test/Shell/SymbolFile/DWARF/split-optimized.c
index b024c22f88b88..2db4e861c4369 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/split-optimized.c
+++ b/lldb/test/Shell/SymbolFile/DWARF/split-optimized.c
@@ -6,9 +6,6 @@
 // This test uses lldb's embedded python interpreter
 // REQUIRES: python
 
-// ObjectFileELF::ApplyRelocations does not implement arm32.
-// XFAIL: target-arm && linux-gnu
-
 // RUN: %clang_host %s -fno-standalone-debug -glldb \
 // RUN:   -gdwarf-5 -gpubnames -gsplit-dwarf -O3 -c -o %t1.o
 



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


[Lldb-commits] [PATCH] D132954: lldb: Add support for R_386_32 relocations to ObjectFileELF

2022-09-14 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Yeah, we can enable them. I've done that now in  d079bf33 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132954

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


[Lldb-commits] [PATCH] D133446: [LLDB][NativePDB] Global ctor and dtor should be global decls.

2022-09-14 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D133446#3787362 , @zequanwu wrote:

> In D133446#3786561 , @labath wrote:
>
>> In D133446#3780961 , @zequanwu 
>> wrote:
>>
>>> In D133446#3779600 , @labath 
>>> wrote:
>>>
 I believe that this fixes the crash, but the names of generated functions 
 still look fairly weird. Could we create them using their mangled name 
 instead? That way, someone might actually call them, if he was so inclined.
>>>
>>> It looks like they don't have mangled name stored in pdb.
>>
>> Hmm.. That's unfortunate. In that case, I'm wondering if this shouldn't be 
>> handled somehow directly inside `MSVCUndecoratedNameParser`. What does the 
>> function return right now? Do you think that result is going to be useful 
>> for other users of that class?
>
> `MSVCUndecoratedNameParser` expects a undercoated name of a entity(class, 
> function, variable, etc) and returns the a pair of {pointer to parent decl 
> context, base name of the entity}.

Hmm... are you sure about that? `CreateDeclInfoForUndecoratedName` returns a 
{decl ctx, base name} pair. `MSVCUndecoratedNameParser` returns (creates) an 
array of `MSVCUndecoratedNameSpecifier`s. My question was about what those 
specifiers are specifically for the inputs we're talking about here (`static 
void B::dynamic atexit destructor for 'glob'()` or such), and whether those 
outputs "make sense" for some user of that class (it's clear that they don't 
make sense here).

Basically, I'm trying to see whether it's possible (desirable?) to move this 
logic into the parser class. The parser already does a lot of string 
manipulation, so checking for these strings there would make more sense to me 
than doing some sort of a pre-parse from the outside.

>> Also, I'm still continuing to be amazed (and scared) by the amount of name 
>> parsing that is going on here. Have you checked that there's no better way 
>> to associate an entity with its enclosing context?
>
> If the entity is a global variable, we don't have any other ways to know if 
> its enclosing context is record or namespace.  If the entity is record or 
> function, then we can know if its enclosing context is a record by looking at 
> its type info but need to fall back to parse name again if it's inside a 
> namespace. The issue is there isn't a way to represent namespaces in PDB, and 
> they are just embedded into the name strings.

Hmm.. well, that's unfortunate, but I guess we'll have to live with it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133446

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


[Lldb-commits] [PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-09-14 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov updated this revision to Diff 460036.
mizvekov marked an inline comment as not done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/complex-int.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/complex-conversion.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/t

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve created this revision.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

A common debugging pattern is to set a breakpoint that only stops after
a number of hits is recorded. The current implementation never resets
the hit count of breakpoints; as such, if a user re-`run`s their
program, the debugger will never stop on such a breakpoint again.

This behavior is arguably undesirable, as it renders such breakpoints
ineffective on all but the first run. This commit changes the
implementation of the `Will{Launch, Attach}` methods so that they reset
the _target's_ breakpoint hitcounts.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133858

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/Process.cpp
  
lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
  
lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
  lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp

Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char const *argv[]) {
+  printf("Set a breakpoint here.\n");
+  return 0;
+}
Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
@@ -0,0 +1,58 @@
+"""
+Test breakpoint hit count is reset when target runs.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class HitcountResetUponRun(TestBase):
+BREAKPOINT_TEXT = 'Set a breakpoint here'
+
+def check_stopped_at_breakpoint_and_hit_once(self, thread, breakpoint):
+frame0 = thread.GetFrameAtIndex(0)
+location1 = breakpoint.FindLocationByAddress(frame0.GetPC())
+self.assertTrue(location1)
+self.assertEqual(location1.GetHitCount(), 1)
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+def test_hitcount_reset_upon_run(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+breakpoint = target.BreakpointCreateBySourceRegex(
+self.BREAKPOINT_TEXT, lldb.SBFileSpec('main.cpp'))
+self.assertTrue(
+breakpoint.IsValid() and breakpoint.GetNumLocations() == 1,
+VALID_BREAKPOINT)
+
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+from lldbsuite.test.lldbutil import get_stopped_thread
+
+# Verify 1st breakpoint location is hit.
+thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint")
+self.check_stopped_at_breakpoint_and_hit_once(thread, breakpoint)
+
+# Relaunch
+process.Kill()
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Verify the hit counts are still one.
+thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint")
+self.check_stopped_at_breakpoint_and_hit_once(thread, breakpoint)
Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreak

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: lldb/source/Breakpoint/Breakpoint.cpp:332
+void Breakpoint::ResetHitCount() {
+  m_hit_counter.Reset();
+  for (size_t i = 0; i < GetNumLocations(); ++i)

By the way, I don' think this counter is ever incremented anywhere. I'll 
removing it in a separate patch and see what happens


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [PATCH] D133790: Fix heap-use-after-free when clearing DIEs in fission compile units.

2022-09-14 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f3def30ca86: Fix heap-use-after-free when clearing DIEs in 
fission compile units. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133790

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -598,7 +598,7 @@
   m_die_array.clear();
   m_die_array.shrink_to_fit();
 
-  if (m_dwo)
+  if (m_dwo && !m_dwo->m_cancel_scopes)
 m_dwo->ClearDIEsRWLocked();
 }
 


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -598,7 +598,7 @@
   m_die_array.clear();
   m_die_array.shrink_to_fit();
 
-  if (m_dwo)
+  if (m_dwo && !m_dwo->m_cancel_scopes)
 m_dwo->ClearDIEsRWLocked();
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1f3def3 - Fix heap-use-after-free when clearing DIEs in fission compile units.

2022-09-14 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2022-09-14T06:52:47-07:00
New Revision: 1f3def30ca86a35a173cb1fe10e3e73d2a0d0f6f

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

LOG: Fix heap-use-after-free when clearing DIEs in fission compile units.

D131437 caused heap-use-after-free failures when testing 
TestCreateAfterAttach.py in asan mode, and "regular" crashes outside of asan.

This appears to be due to a mismatch in a couple places where we choose to 
clear the DIEs. When we clear the DIE of a skeleton unit, we unconditionally 
clear the DIE of the DWO unit if it exists. However, `~ScopedExtractDIEs()` 
only looks at the skeleton unit when deciding to clear. If we decide to clear 
the skeleton unit because it is now unused, we end up clearing the DWO unit 
that _is_ used. This change adds a guard by checking `m_cancel_scopes` to 
prevent clearing the DWO unit.

This is 100% reproducible by running TestCreateAfterAttach.py in asan mode, 
although it only seems to reproduce in our internal build, so no test case is 
added here. If someone has suggestions on how to write one, I can add it.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index c61ae22f43fd..8e258ee0d7bd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -598,7 +598,7 @@ void DWARFUnit::ClearDIEsRWLocked() {
   m_die_array.clear();
   m_die_array.shrink_to_fit();
 
-  if (m_dwo)
+  if (m_dwo && !m_dwo->m_cancel_scopes)
 m_dwo->ClearDIEsRWLocked();
 }
 



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


[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added inline comments.



Comment at: lldb/source/Breakpoint/Breakpoint.cpp:332
+void Breakpoint::ResetHitCount() {
+  m_hit_counter.Reset();
+  for (size_t i = 0; i < GetNumLocations(); ++i)

fdeazeve wrote:
> By the way, I don' think this counter is ever incremented anywhere. I'll 
> removing it in a separate patch and see what happens
Ah, nvm, `Breakpoint` is a `friend` of `BreakpointLocation`, and the latter 
increments this counter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [lldb] 154db06 - [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 1

2022-09-14 Thread John Ericson via lldb-commits

Author: John Ericson
Date: 2022-09-14T10:58:47-04:00
New Revision: 154db06ce0d6c80ec900718b764e56ff90d360a0

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

LOG: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are 
better-suited, part 1

A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/\$\{CMAKE_CFG_INTDIR}/lib(${LLVM_LIBDIR_SUFFIX})?\>` -> 
`${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/\$\{CMAKE_CFG_INTDIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `compiler-rt/cmake/Modules/CompilerRTUtils.cmake`

because these were "entry points" where we wanted to tread carefully not not 
introduce a "loop" which would end with an undefined variable being expanded to 
nothing.

There are many more occurrences without `CMAKE_CFG_INTDIR`, but those are left 
for D132316 as they have proved somewhat tricky to fix.

This hopefully increases readability overall, and also decreases the usages of 
`LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

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

Added: 


Modified: 
lldb/test/API/CMakeLists.txt
llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 121844d8098e..1a055c47480d 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -45,10 +45,10 @@ set(LLDB_TEST_COMMON_ARGS_VAR
 # Set the path to the default lldb test executable.
 set(LLDB_DEFAULT_TEST_EXECUTABLE 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")
 
-set(LLDB_DEFAULT_TEST_DSYMUTIL 
"${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
+set(LLDB_DEFAULT_TEST_DSYMUTIL 
"${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
 
 if (TARGET clang)
-  set(LLDB_DEFAULT_TEST_COMPILER 
"${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
+  set(LLDB_DEFAULT_TEST_COMPILER 
"${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
 else()
   set(LLDB_DEFAULT_TEST_COMPILER "")
 endif()

diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 8e2b78f1b85c..fd4999fff676 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -88,7 +88,7 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND NOT MSVC)
 
   set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_BINARY_DIR}/libllvm-c.exports)
 
-  set(LIB_DIR ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(LIB_DIR ${LLVM_LIBRARY_DIR})
   set(LIB_NAME ${LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}LLVM)
   set(LIB_PATH ${LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
   set(LIB_EXPORTS_PATH ${LIB_NAME}.exports)
@@ -136,7 +136,7 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND MSVC)
 
   # Get the full name to the libs so the python script understands them.
   foreach(lib ${LIB_NAMES})
-list(APPEND FULL_LIB_NAMES 
${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib)
+list(APPEND FULL_LIB_NAMES ${LLVM_LIBRARY_DIR}/${lib}.lib)
   endforeach()
 
   # Need to separate lib names with newlines.



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


[Lldb-commits] [PATCH] D133828: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 1

2022-09-14 Thread John Ericson via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG154db06ce0d6: [CMake] Avoid `LLVM_BINARY_DIR` when other 
more specific variable are better… (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133828

Files:
  lldb/test/API/CMakeLists.txt
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -88,7 +88,7 @@
 
   set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_BINARY_DIR}/libllvm-c.exports)
 
-  set(LIB_DIR ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(LIB_DIR ${LLVM_LIBRARY_DIR})
   set(LIB_NAME ${LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}LLVM)
   set(LIB_PATH ${LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
   set(LIB_EXPORTS_PATH ${LIB_NAME}.exports)
@@ -136,7 +136,7 @@
 
   # Get the full name to the libs so the python script understands them.
   foreach(lib ${LIB_NAMES})
-list(APPEND FULL_LIB_NAMES 
${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib)
+list(APPEND FULL_LIB_NAMES ${LLVM_LIBRARY_DIR}/${lib}.lib)
   endforeach()
 
   # Need to separate lib names with newlines.
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -45,10 +45,10 @@
 # Set the path to the default lldb test executable.
 set(LLDB_DEFAULT_TEST_EXECUTABLE 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")
 
-set(LLDB_DEFAULT_TEST_DSYMUTIL 
"${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
+set(LLDB_DEFAULT_TEST_DSYMUTIL 
"${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
 
 if (TARGET clang)
-  set(LLDB_DEFAULT_TEST_COMPILER 
"${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
+  set(LLDB_DEFAULT_TEST_COMPILER 
"${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
 else()
   set(LLDB_DEFAULT_TEST_COMPILER "")
 endif()


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -88,7 +88,7 @@
 
   set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_BINARY_DIR}/libllvm-c.exports)
 
-  set(LIB_DIR ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(LIB_DIR ${LLVM_LIBRARY_DIR})
   set(LIB_NAME ${LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}LLVM)
   set(LIB_PATH ${LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
   set(LIB_EXPORTS_PATH ${LIB_NAME}.exports)
@@ -136,7 +136,7 @@
 
   # Get the full name to the libs so the python script understands them.
   foreach(lib ${LIB_NAMES})
-list(APPEND FULL_LIB_NAMES ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${lib}.lib)
+list(APPEND FULL_LIB_NAMES ${LLVM_LIBRARY_DIR}/${lib}.lib)
   endforeach()
 
   # Need to separate lib names with newlines.
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -45,10 +45,10 @@
 # Set the path to the default lldb test executable.
 set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")
 
-set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
+set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
 
 if (TARGET clang)
-  set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
+  set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
 else()
   set(LLDB_DEFAULT_TEST_COMPILER "")
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D130062: [lldb][DWARF5] Enable macro evaluation

2022-09-14 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

This test fails to compile on Darwin

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/46816/testReport/junit/lldb-api/commands_expression_macros/TestMacros_py/
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/46811/

Can you please add a @skipIfDarwin decorator?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130062

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


[Lldb-commits] [PATCH] D130062: [lldb][DWARF5] Enable macro evaluation

2022-09-14 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Out of curiosity — did you get an email notification from the bot?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130062

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


[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

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



Comment at: lldb/source/Target/Process.cpp:2763-2766
+static void ResetHitCounts(Process &Proc) {
+  for (const auto &BP : Proc.GetTarget().GetBreakpointList().Breakpoints())
+BP->ResetHitCount();
+}

Can this be a private member so we don't have to pass in `*this`? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added inline comments.



Comment at: lldb/source/Target/Process.cpp:2763-2766
+static void ResetHitCounts(Process &Proc) {
+  for (const auto &BP : Proc.GetTarget().GetBreakpointList().Breakpoints())
+BP->ResetHitCount();
+}

JDevlieghere wrote:
> Can this be a private member so we don't have to pass in `*this`? 
No strong preferences on my part, but I had made it a free function because it 
can be implemented in terms of the public behaviour, i.e. it doesn't rely on 
implementation details.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [PATCH] D130062: [lldb][DWARF5] Enable macro evaluation

2022-09-14 Thread Pavel Kosov via Phabricator via lldb-commits
kpdev42 added a comment.

In D130062#3789671 , @aprantl wrote:

> Out of curiosity — did you get an email notification from the bot?

Hi, yes, I will add a priority to these notifications to react faster, sorry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130062

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


[Lldb-commits] [lldb] da45904 - Revert "[lldb][DWARF5] Enable macro evaluation"

2022-09-14 Thread Stella Stamenova via lldb-commits

Author: Stella Stamenova
Date: 2022-09-14T09:30:49-07:00
New Revision: da459043f8c5d4187c798cc13a48bc7f7c1bd81a

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

LOG: Revert "[lldb][DWARF5] Enable macro evaluation"

This reverts commit a0fb69d17b4d7501a85554010727837340e7b52f.

This broke the windows lldb bot: 
https://lab.llvm.org/buildbot/#/builders/83/builds/23666

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/test/API/commands/expression/macros/Makefile
lldb/test/API/commands/expression/macros/TestMacros.py

Removed: 
lldb/test/API/lang/c/macro/Makefile
lldb/test/API/lang/c/macro/TestMacro.py
lldb/test/API/lang/c/macro/main.c



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
index c357033aa91d7..37e28a09f3c45 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -92,8 +92,8 @@ const DWARFDataExtractor 
&DWARFContext::getOrLoadLocListsData() {
 }
 
 const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() {
-  return LoadOrGetSection(eSectionTypeDWARFDebugMacro,
-  eSectionTypeDWARFDebugMacro, m_data_debug_macro);
+  return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None,
+  m_data_debug_macro);
 }
 
 const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() {

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
index d7a43a3f9c68b..19c6448c4e74a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
@@ -16,11 +16,6 @@
 using namespace lldb_private;
 using namespace lldb_private::dwarf;
 
-uint64_t DWARFStrOffsetsInfo::GetOffset(uint64_t index) const {
-  uint64_t offset = cu_str_offset + data.GetDWARFSizeOfOffset() * index;
-  return data.GetU32(&offset);
-}
-
 DWARFDebugMacroHeader
 DWARFDebugMacroHeader::ParseHeader(const DWARFDataExtractor &debug_macro_data,
lldb::offset_t *offset) {
@@ -64,8 +59,7 @@ void DWARFDebugMacroHeader::SkipOperandTable(
 
 void DWARFDebugMacroEntry::ReadMacroEntries(
 const DWARFDataExtractor &debug_macro_data,
-const DWARFDataExtractor &debug_str_data,
-const DWARFStrOffsetsInfo *str_offsets_info, const bool offset_is_64_bit,
+const DWARFDataExtractor &debug_str_data, const bool offset_is_64_bit,
 lldb::offset_t *offset, SymbolFileDWARF *sym_file_dwarf,
 DebugMacrosSP &debug_macros_sp) {
   llvm::dwarf::MacroEntryType type =
@@ -103,22 +97,6 @@ void DWARFDebugMacroEntry::ReadMacroEntries(
 debug_macros_sp->AddMacroEntry(
 DebugMacroEntry::CreateUndefEntry(line, macro_str));
   break;
-case DW_MACRO_define_strx:
-case DW_MACRO_undef_strx:
-  line = debug_macro_data.GetULEB128(offset);
-  str_offset = debug_macro_data.GetULEB128(offset);
-  if (!str_offsets_info)
-// Can't do much in this case, skip all such entries
-continue;
-  str_offset = str_offsets_info->GetOffset(str_offset);
-  macro_str = debug_str_data.GetCStr(&str_offset);
-  if (type == DW_MACRO_define_strx)
-debug_macros_sp->AddMacroEntry(
-DebugMacroEntry::CreateDefineEntry(line, macro_str));
-  else
-debug_macros_sp->AddMacroEntry(
-DebugMacroEntry::CreateUndefEntry(line, macro_str));
-  break;
 case DW_MACRO_start_file:
   line = debug_macro_data.GetULEB128(offset);
   debug_line_file_idx = debug_macro_data.GetULEB128(offset);
@@ -135,7 +113,7 @@ void DWARFDebugMacroEntry::ReadMacroEntries(
   else
 new_offset = debug_macro_data.GetU32(offset);
   debug_macros_sp->AddMacroEntry(DebugMacroEntry::CreateIndirectEntry(
-  sym_file_dwarf->ParseDebugMacros(&new_offset, str_offsets_info)));
+  sym_file_dwarf->ParseDebugMacros(&new_offset)));
   break;
 default:
   // TODO: Add support for other standard operations.

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
index 27be105b5949a..cbf762458331b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
@@ -24,17 +24,6 @@ class DWARFDataExtractor;
 
 class SymbolFileDWARF;
 
-class DWARFStrOffsetsInfo {

[Lldb-commits] [PATCH] D133876: [lldb][tests] Move C++ gmodules tests into new gmodules/ subdirectory

2022-09-14 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is in preparation for adding more gmodules
tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133876

Files:
  lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py
  lldb/test/API/lang/cpp/gmodules-templates/a.h
  lldb/test/API/lang/cpp/gmodules-templates/b.h
  lldb/test/API/lang/cpp/gmodules-templates/main.cpp
  lldb/test/API/lang/cpp/gmodules-templates/memory.h
  lldb/test/API/lang/cpp/gmodules-templates/module.modulemap
  lldb/test/API/lang/cpp/gmodules/Makefile
  lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/test/API/lang/cpp/gmodules/basic/Makefile
  lldb/test/API/lang/cpp/gmodules/basic/TestWithModuleDebugging.py
  lldb/test/API/lang/cpp/gmodules/basic/main.cpp
  lldb/test/API/lang/cpp/gmodules/basic/pch.h
  lldb/test/API/lang/cpp/gmodules/main.cpp
  lldb/test/API/lang/cpp/gmodules/pch.h
  lldb/test/API/lang/cpp/gmodules/templates/TestGModules.py
  lldb/test/API/lang/cpp/gmodules/templates/a.h
  lldb/test/API/lang/cpp/gmodules/templates/b.h
  lldb/test/API/lang/cpp/gmodules/templates/main.cpp
  lldb/test/API/lang/cpp/gmodules/templates/memory.h
  lldb/test/API/lang/cpp/gmodules/templates/module.modulemap

Index: lldb/test/API/lang/cpp/gmodules-templates/module.modulemap
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules-templates/module.modulemap
@@ -1,11 +0,0 @@
-module A {
-  header "a.h"
-}
-
-module B {
-  header "b.h"
-}
-
-module std {
-  header "memory.h"
-}
Index: lldb/test/API/lang/cpp/gmodules-templates/memory.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules-templates/memory.h
@@ -1,8 +0,0 @@
-#ifndef MEMORY_H
-#define MEMORY_H
-namespace my_std {
-  template class unique_ptr {
-T t;
-  };
-}
-#endif
Index: lldb/test/API/lang/cpp/gmodules-templates/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules-templates/main.cpp
@@ -1,9 +0,0 @@
-#include "b.h"
-
-int main(int argc, const char * argv[])
-{
-Module m;
-// Test that the type Module which contains a field that is a
-// template instantiation can be fully resolved.
-return 0; //% self.assertTrue(self.frame().FindVariable('m').GetChildAtIndex(0).GetChildAtIndex(0).GetChildAtIndex(0).GetName() == 'buffer', 'find template specializations in imported modules')
-}
Index: lldb/test/API/lang/cpp/gmodules-templates/b.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules-templates/b.h
@@ -1,6 +0,0 @@
-#include "a.h"
-#include "memory.h"
-
-class Module {
-  my_std::unique_ptr MBptr;
-};
Index: lldb/test/API/lang/cpp/gmodules-templates/a.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules-templates/a.h
@@ -1,7 +0,0 @@
-#include "memory.h"
-
-class MemoryBuffer { int buffer = 42; };
-
-struct SrcBuffer {
-  my_std::unique_ptr Buffer;
-};
Index: lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py
@@ -1,6 +0,0 @@
-import lldbsuite.test.lldbinline as lldbinline
-from lldbsuite.test.decorators import *
-
-lldbinline.MakeInlineTest(__file__, globals(), [
-expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr36107",
-debug_info="gmodules")])
Index: lldb/test/API/lang/cpp/gmodules/pch.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules/pch.h
@@ -1,17 +0,0 @@
-template
-class GenericContainer {
-  private:
-T storage;
-
-  public:
-GenericContainer(T value) {
-  storage = value;
-};
-};
-
-typedef GenericContainer IntContainer;
-
-struct Foo {
-  class Bar;
-  Bar *bar;
-};
Index: lldb/test/API/lang/cpp/gmodules/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules/main.cpp
@@ -1,8 +0,0 @@
-class Foo::Bar { int i = 123; };
-
-int main(int argc, const char * argv[])
-{
-IntContainer test(42);
-Foo::Bar bar;
-return 0; // break here
-}
Index: lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
@@ -1,92 +0,0 @@
-import lldb
-import os
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestWithGmodulesDebugInfo(TestBase):
-
-@skipIf(bugnumber="llvm.org/pr36146", oslist=["linux

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

Resetting the hit counts on rerun is a more useful behavior, so this is all 
fine.  But the Target is the one that does all the breakpoint management, so I 
think the resetting should go through the Target, not the Process.  And we 
generally delegate "do on all breakpoints" operations to the BreakpointList, so 
it would be more consistent with the current structure to go 
Process::WillLaunch -> Target::ResetHitCounts -> BreakpointList::ResetHitCounts.




Comment at: lldb/source/Target/Process.cpp:2763-2766
+static void ResetHitCounts(Process &Proc) {
+  for (const auto &BP : Proc.GetTarget().GetBreakpointList().Breakpoints())
+BP->ResetHitCount();
+}

fdeazeve wrote:
> JDevlieghere wrote:
> > Can this be a private member so we don't have to pass in `*this`? 
> No strong preferences on my part, but I had made it a free function because 
> it can be implemented in terms of the public behaviour, i.e. it doesn't rely 
> on implementation details.
Resetting all the hit counts in a BreakpointList seems to me a job of the 
BreakpointList.  Also, while DoWillLaunch/Attach is where this action belongs, 
which is how the Process gets involved, the Target is the one that manages the 
breakpoints in general.  So I think it would be better to have the Target do 
ResetHitCounts, and these Process calls should just dial up it's Target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [PATCH] D130062: [lldb][DWARF5] Enable macro evaluation

2022-09-14 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D130062#3789858 , @kpdev42 wrote:

> In D130062#3789671 , @aprantl wrote:
>
>> Out of curiosity — did you get an email notification from the bot?
>
> Hi, yes, I will add a priority to these notifications to react faster, sorry

Great. I was asking because we had issues with the bot not sending these out 
recently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130062

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


[Lldb-commits] [PATCH] D133446: [LLDB][NativePDB] Global ctor and dtor should be global decls.

2022-09-14 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu added a comment.

In D133446#3788956 , @labath wrote:

> In D133446#3787362 , @zequanwu 
> wrote:
>
>> In D133446#3786561 , @labath wrote:
>>
>>> In D133446#3780961 , @zequanwu 
>>> wrote:
>>>
 In D133446#3779600 , @labath 
 wrote:

> I believe that this fixes the crash, but the names of generated functions 
> still look fairly weird. Could we create them using their mangled name 
> instead? That way, someone might actually call them, if he was so 
> inclined.

 It looks like they don't have mangled name stored in pdb.
>>>
>>> Hmm.. That's unfortunate. In that case, I'm wondering if this shouldn't be 
>>> handled somehow directly inside `MSVCUndecoratedNameParser`. What does the 
>>> function return right now? Do you think that result is going to be useful 
>>> for other users of that class?
>>
>> `MSVCUndecoratedNameParser` expects a undercoated name of a entity(class, 
>> function, variable, etc) and returns the a pair of {pointer to parent decl 
>> context, base name of the entity}.
>
> Hmm... are you sure about that? `CreateDeclInfoForUndecoratedName` returns a 
> {decl ctx, base name} pair. `MSVCUndecoratedNameParser` returns (creates) an 
> array of `MSVCUndecoratedNameSpecifier`s. My question was about what those 
> specifiers are specifically for the inputs we're talking about here (`static 
> void B::dynamic atexit destructor for 'glob'()` or such), and whether those 
> outputs "make sense" for some user of that class (it's clear that they don't 
> make sense here).
>
> Basically, I'm trying to see whether it's possible (desirable?) to move this 
> logic into the parser class. The parser already does a lot of string 
> manipulation, so checking for these strings there would make more sense to me 
> than doing some sort of a pre-parse from the outside.

Sorry, I misunderstood you and copied the wrong function name there. And yeah, 
I think the logic should be moved into `MSVCUndecoratedNameParser`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133446

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


[Lldb-commits] [PATCH] D133446: [LLDB][NativePDB] Global ctor and dtor should be global decls.

2022-09-14 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu updated this revision to Diff 460152.
zequanwu added a comment.

Move the logic into `MSVCUndecoratedNameParser`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133446

Files:
  lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/test/Shell/SymbolFile/NativePDB/global-ctor-dtor.cpp


Index: lldb/test/Shell/SymbolFile/NativePDB/global-ctor-dtor.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/global-ctor-dtor.cpp
@@ -0,0 +1,30 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// Global ctor and dtor should be globals decls.
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -GS- -fno-addrsig -c 
/Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe 
-pdb:%t.pdb -force
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols --dump-ast %t.exe | 
FileCheck %s
+
+struct A {
+  ~A() {};
+};
+struct B {
+  static A glob;
+};
+
+A B::glob = A();
+int main() {
+  return 0;
+}
+
+// CHECK:  static void B::`dynamic initializer for 'glob'();
+// CHECK-NEXT: static void B::`dynamic atexit destructor for 'glob'();
+// CHECK-NEXT: int main();
+// CHECK-NEXT: static void _GLOBAL__sub_I_global_ctor_dtor.cpp();
+// CHECK-NEXT: struct A {
+// CHECK-NEXT: ~A();
+// CHECK-NEXT: };
+// CHECK-NEXT: struct B {
+// CHECK-NEXT: static A glob;
+// CHECK-NEXT: };
Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -537,7 +537,7 @@
   MSVCUndecoratedNameParser parser(name);
   llvm::ArrayRef specs = parser.GetSpecifiers();
 
-  auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
+  auto *context = FromCompilerDeclContext(GetTranslationUnitDecl());
 
   llvm::StringRef uname = specs.back().GetBaseName();
   specs = specs.drop_back();
@@ -1226,7 +1226,6 @@
   llvm::StringRef proc_name = proc.Name;
   proc_name.consume_front(context_name);
   proc_name.consume_front("::");
-
   clang::FunctionDecl *function_decl =
   CreateFunctionDecl(func_id, proc_name, proc.FunctionType, func_ct,
  func_type->getNumParams(), storage, false, parent);
Index: lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
@@ -11,6 +11,13 @@
 #include 
 
 MSVCUndecoratedNameParser::MSVCUndecoratedNameParser(llvm::StringRef name) {
+  // Global ctor and dtor are global functions.
+  if (name.contains("dynamic initializer for") ||
+  name.contains("dynamic atexit destructor for")) {
+m_specifiers.emplace_back(name, name);
+return;
+  }
+
   std::size_t last_base_start = 0;
 
   std::stack stack;


Index: lldb/test/Shell/SymbolFile/NativePDB/global-ctor-dtor.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/global-ctor-dtor.cpp
@@ -0,0 +1,30 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// Global ctor and dtor should be globals decls.
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -GS- -fno-addrsig -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb -force
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols --dump-ast %t.exe | FileCheck %s
+
+struct A {
+  ~A() {};
+};
+struct B {
+  static A glob;
+};
+
+A B::glob = A();
+int main() {
+  return 0;
+}
+
+// CHECK:  static void B::`dynamic initializer for 'glob'();
+// CHECK-NEXT: static void B::`dynamic atexit destructor for 'glob'();
+// CHECK-NEXT: int main();
+// CHECK-NEXT: static void _GLOBAL__sub_I_global_ctor_dtor.cpp();
+// CHECK-NEXT: struct A {
+// CHECK-NEXT: ~A();
+// CHECK-NEXT: };
+// CHECK-NEXT: struct B {
+// CHECK-NEXT: static A glob;
+// CHECK-NEXT: };
Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -537,7 +537,7 @@
   MSVCUndecoratedNameParser parser(name);
   llvm::ArrayRef specs = parser.GetSpecifiers();
 
-  auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
+  auto *context = FromCompilerDeclContext(GetTranslationUnitDecl());
 
   llvm::StringRef uname = specs.back().GetBaseName();
   specs = specs.drop_back();
@@ -1226,7 +1226,6 @@
   llvm::StringRef proc_name = proc.Name;
   proc_name.consume_front(context_name)

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve updated this revision to Diff 460165.
fdeazeve added a comment.

Addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointList.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointList.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  
lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
  
lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
  lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp

Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char const *argv[]) {
+  printf("Set a breakpoint here.\n");
+  return 0;
+}
Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
@@ -0,0 +1,58 @@
+"""
+Test breakpoint hit count is reset when target runs.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class HitcountResetUponRun(TestBase):
+BREAKPOINT_TEXT = 'Set a breakpoint here'
+
+def check_stopped_at_breakpoint_and_hit_once(self, thread, breakpoint):
+frame0 = thread.GetFrameAtIndex(0)
+location1 = breakpoint.FindLocationByAddress(frame0.GetPC())
+self.assertTrue(location1)
+self.assertEqual(location1.GetHitCount(), 1)
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+def test_hitcount_reset_upon_run(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+breakpoint = target.BreakpointCreateBySourceRegex(
+self.BREAKPOINT_TEXT, lldb.SBFileSpec('main.cpp'))
+self.assertTrue(
+breakpoint.IsValid() and breakpoint.GetNumLocations() == 1,
+VALID_BREAKPOINT)
+
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+from lldbsuite.test.lldbutil import get_stopped_thread
+
+# Verify 1st breakpoint location is hit.
+thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint")
+self.check_stopped_at_breakpoint_and_hit_once(thread, breakpoint)
+
+# Relaunch
+process.Kill()
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Verify the hit counts are still one.
+thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint")
+self.check_stopped_at_breakpoint_and_hit_once(thread, breakpoint)
Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -313,8 +313,9 @@
 substrs=['stopped',
  'stop reason = breakpoint'])
 
-# The breakpoint should have a hit count of 2.
-lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 2)
+  

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added a comment.

In D133858#3790013 , @jingham wrote:

> Resetting the hit counts on rerun is a more useful behavior, so this is all 
> fine.  But the Target is the one that does all the breakpoint management, so 
> I think the resetting should go through the Target, not the Process.  And we 
> generally delegate "do on all breakpoints" operations to the BreakpointList, 
> so it would be more consistent with the current structure to go 
> Process::WillLaunch -> Target::ResetHitCounts -> 
> BreakpointList::ResetHitCounts.

This makes sense! I've fixed this in the latest revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added inline comments.



Comment at: lldb/source/Breakpoint/Breakpoint.cpp:334
+  for (size_t i = 0; i < GetNumLocations(); ++i)
+GetLocationAtIndex(i)->ResetHitCount();
+}

@jingham actually, should I apply the same idea to BreakpointLocationList?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [lldb] 3b44c9a - [lldb][tests] Move C++ gmodules tests into new gmodules/ subdirectory

2022-09-14 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-09-14T14:45:35-04:00
New Revision: 3b44c9af8efd95aba7b4f351e5175ebf02e7b396

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

LOG: [lldb][tests] Move C++ gmodules tests into new gmodules/ subdirectory

This is in preparation for adding more gmodules
tests.

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

Added: 
lldb/test/API/lang/cpp/gmodules/basic/Makefile
lldb/test/API/lang/cpp/gmodules/basic/TestWithModuleDebugging.py
lldb/test/API/lang/cpp/gmodules/basic/main.cpp
lldb/test/API/lang/cpp/gmodules/basic/pch.h
lldb/test/API/lang/cpp/gmodules/templates/TestGModules.py
lldb/test/API/lang/cpp/gmodules/templates/a.h
lldb/test/API/lang/cpp/gmodules/templates/b.h
lldb/test/API/lang/cpp/gmodules/templates/main.cpp
lldb/test/API/lang/cpp/gmodules/templates/memory.h
lldb/test/API/lang/cpp/gmodules/templates/module.modulemap

Modified: 


Removed: 
lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py
lldb/test/API/lang/cpp/gmodules-templates/a.h
lldb/test/API/lang/cpp/gmodules-templates/b.h
lldb/test/API/lang/cpp/gmodules-templates/main.cpp
lldb/test/API/lang/cpp/gmodules-templates/memory.h
lldb/test/API/lang/cpp/gmodules-templates/module.modulemap
lldb/test/API/lang/cpp/gmodules/Makefile
lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
lldb/test/API/lang/cpp/gmodules/main.cpp
lldb/test/API/lang/cpp/gmodules/pch.h



diff  --git a/lldb/test/API/lang/cpp/gmodules/Makefile 
b/lldb/test/API/lang/cpp/gmodules/basic/Makefile
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules/Makefile
rename to lldb/test/API/lang/cpp/gmodules/basic/Makefile

diff  --git a/lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py 
b/lldb/test/API/lang/cpp/gmodules/basic/TestWithModuleDebugging.py
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
rename to lldb/test/API/lang/cpp/gmodules/basic/TestWithModuleDebugging.py

diff  --git a/lldb/test/API/lang/cpp/gmodules/main.cpp 
b/lldb/test/API/lang/cpp/gmodules/basic/main.cpp
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules/main.cpp
rename to lldb/test/API/lang/cpp/gmodules/basic/main.cpp

diff  --git a/lldb/test/API/lang/cpp/gmodules/pch.h 
b/lldb/test/API/lang/cpp/gmodules/basic/pch.h
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules/pch.h
rename to lldb/test/API/lang/cpp/gmodules/basic/pch.h

diff  --git a/lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py 
b/lldb/test/API/lang/cpp/gmodules/templates/TestGModules.py
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py
rename to lldb/test/API/lang/cpp/gmodules/templates/TestGModules.py

diff  --git a/lldb/test/API/lang/cpp/gmodules-templates/a.h 
b/lldb/test/API/lang/cpp/gmodules/templates/a.h
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules-templates/a.h
rename to lldb/test/API/lang/cpp/gmodules/templates/a.h

diff  --git a/lldb/test/API/lang/cpp/gmodules-templates/b.h 
b/lldb/test/API/lang/cpp/gmodules/templates/b.h
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules-templates/b.h
rename to lldb/test/API/lang/cpp/gmodules/templates/b.h

diff  --git a/lldb/test/API/lang/cpp/gmodules-templates/main.cpp 
b/lldb/test/API/lang/cpp/gmodules/templates/main.cpp
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules-templates/main.cpp
rename to lldb/test/API/lang/cpp/gmodules/templates/main.cpp

diff  --git a/lldb/test/API/lang/cpp/gmodules-templates/memory.h 
b/lldb/test/API/lang/cpp/gmodules/templates/memory.h
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules-templates/memory.h
rename to lldb/test/API/lang/cpp/gmodules/templates/memory.h

diff  --git a/lldb/test/API/lang/cpp/gmodules-templates/module.modulemap 
b/lldb/test/API/lang/cpp/gmodules/templates/module.modulemap
similarity index 100%
rename from lldb/test/API/lang/cpp/gmodules-templates/module.modulemap
rename to lldb/test/API/lang/cpp/gmodules/templates/module.modulemap



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


[Lldb-commits] [PATCH] D133876: [lldb][tests][NFC] Move C++ gmodules tests into new gmodules/ subdirectory

2022-09-14 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b44c9af8efd: [lldb][tests] Move C++ gmodules tests into new 
gmodules/ subdirectory (authored by Michael137).

Changed prior to commit:
  https://reviews.llvm.org/D133876?vs=460143&id=460169#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133876

Files:
  lldb/test/API/lang/cpp/gmodules-templates/TestGModules.py
  lldb/test/API/lang/cpp/gmodules-templates/a.h
  lldb/test/API/lang/cpp/gmodules-templates/b.h
  lldb/test/API/lang/cpp/gmodules-templates/main.cpp
  lldb/test/API/lang/cpp/gmodules-templates/memory.h
  lldb/test/API/lang/cpp/gmodules-templates/module.modulemap
  lldb/test/API/lang/cpp/gmodules/Makefile
  lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/test/API/lang/cpp/gmodules/basic/Makefile
  lldb/test/API/lang/cpp/gmodules/basic/TestWithModuleDebugging.py
  lldb/test/API/lang/cpp/gmodules/basic/main.cpp
  lldb/test/API/lang/cpp/gmodules/basic/pch.h
  lldb/test/API/lang/cpp/gmodules/main.cpp
  lldb/test/API/lang/cpp/gmodules/pch.h
  lldb/test/API/lang/cpp/gmodules/templates/TestGModules.py
  lldb/test/API/lang/cpp/gmodules/templates/a.h
  lldb/test/API/lang/cpp/gmodules/templates/b.h
  lldb/test/API/lang/cpp/gmodules/templates/main.cpp
  lldb/test/API/lang/cpp/gmodules/templates/memory.h
  lldb/test/API/lang/cpp/gmodules/templates/module.modulemap




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


[Lldb-commits] [PATCH] D133042: Add auto deduce source map setting

2022-09-14 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

The main question for me here is if "target.auto-deduce-source-map" should be a 
boolean or an enum. This path, if I read it correctly, will only auto deduce 
source maps if the debug info contains relative paths and a full path is 
specified. So maybe it should be:

  (lldb) settings set target.auto-deduce-source-map disabled
  (lldb) settings set target.auto-deduce-source-map relative-debug-info

If we plan to use the target.auto-deduce-source-map to later handle cases where 
we have two different full paths, the user might not want to enable this 
setting.

Or we can clarify that this setting deduces source mapping only for relative 
debug info paths by renaming it and then the "bool" value makes more sense?




Comment at: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h:28
+  llvm::Optional removed_prefix_opt = llvm::None,
+  lldb::TargetSP target = nullptr);
 





Comment at: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h:70
+  llvm::Optional m_removed_prefix_opt;
+  lldb::TargetSP m_target = nullptr;
+  bool m_auto_deduce_source_map = false;

Store this as a weak pointer to a target to avoid a target that owns an object 
that will keep the target object from ever being able to destruct itself. 
Anytime you need to use the target then you use a local variable that is a 
shared pointer:
```
TargetSP target_sp = m_target_wp.lock();
if (!target_sp)
  return;
```




Comment at: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h:71
+  lldb::TargetSP m_target = nullptr;
+  bool m_auto_deduce_source_map = false;
 

Remove this. No need to store this as a member variable, just ask the 
breakpoints target for it when you need it since you only use this once.



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:31
+  m_removed_prefix_opt(removed_prefix_opt), m_target(target) {
+  m_auto_deduce_source_map = target && target->GetAutoDeduceSourceMap();
+}

Remove this and use target when needed on demand.



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:197-198
+SymbolContextList &sc_list) {
+  if (!m_auto_deduce_source_map || !m_target)
+return;
+






Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:217
+
+  const bool case_sensitive = m_location_spec.GetFileSpec().IsCaseSensitive();
+  for (uint32_t i = 0; i < sc_list.GetSize(); ++i) {

Can we just return if m_location_spec.IsRelative() returns true here to short 
circuit this entire function? Many users type "b main.cpp:12" and we probably 
don't need to do any auto source map stuff if the request starts as a relative 
path like "main.cpp" or "foo/bar/baz.cpp" right?



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:217
+
+  const bool case_sensitive = m_location_spec.GetFileSpec().IsCaseSensitive();
+  for (uint32_t i = 0; i < sc_list.GetSize(); ++i) {

clayborg wrote:
> Can we just return if m_location_spec.IsRelative() returns true here to short 
> circuit this entire function? Many users type "b main.cpp:12" and we probably 
> don't need to do any auto source map stuff if the request starts as a 
> relative path like "main.cpp" or "foo/bar/baz.cpp" right?
Move the "request_file" below to this line and use it to avoid copying it each 
time through the loop.



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:222
+
+FileSpec sc_file = sc.line_entry.file;
+FileSpec request_file = m_location_spec.GetFileSpec();

Should we quickly continue here if "sc_file" is not relative?



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:225
+
+const bool full = !request_file.GetDirectory().IsEmpty();
+if (FileSpec::Equal(sc_file, request_file, full))

Move this out of the for loop. No need to calculate it each time.



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:239
+if (m_removed_prefix_opt.hasValue())
+  new_mapping_to.append(m_removed_prefix_opt.getValue());
+

please use the llvm::sys::path::append stuff to append paths to each other so 
it can worry about adding any needed directory delimiters



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:246
+  if (new_mapping_to.empty())
+new_mapping_to.append(".");
+} else {

If it is empty, then assign



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:252
+new_mapping_from = ".";
+new_mapping_to.append(new_mapping_to_opt.getValue());
+  }

use llvm::sys::path::a

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve updated this revision to Diff 460176.
fdeazeve added a comment.

Also applied Jim's comment to the LocationList class, as this involves a single
lock, instead of one lock per location.
If this is wrong, please let me know and I'll revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointList.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointLocationList.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointList.cpp
  lldb/source/Breakpoint/BreakpointLocationList.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  
lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
  
lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
  lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp

Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/main.cpp
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char const *argv[]) {
+  printf("Set a breakpoint here.\n");
+  return 0;
+}
Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
@@ -0,0 +1,58 @@
+"""
+Test breakpoint hit count is reset when target runs.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class HitcountResetUponRun(TestBase):
+BREAKPOINT_TEXT = 'Set a breakpoint here'
+
+def check_stopped_at_breakpoint_and_hit_once(self, thread, breakpoint):
+frame0 = thread.GetFrameAtIndex(0)
+location1 = breakpoint.FindLocationByAddress(frame0.GetPC())
+self.assertTrue(location1)
+self.assertEqual(location1.GetHitCount(), 1)
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+def test_hitcount_reset_upon_run(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+breakpoint = target.BreakpointCreateBySourceRegex(
+self.BREAKPOINT_TEXT, lldb.SBFileSpec('main.cpp'))
+self.assertTrue(
+breakpoint.IsValid() and breakpoint.GetNumLocations() == 1,
+VALID_BREAKPOINT)
+
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+from lldbsuite.test.lldbutil import get_stopped_thread
+
+# Verify 1st breakpoint location is hit.
+thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint")
+self.check_stopped_at_breakpoint_and_hit_once(thread, breakpoint)
+
+# Relaunch
+process.Kill()
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Verify the hit counts are still one.
+thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint")
+self.check_stopped_at_breakpoint_and_hit_once(thread, breakpoint)
Index: lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -

[Lldb-commits] [PATCH] D132316: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2

2022-09-14 Thread John Ericson via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a1c81e32739: [CMake] Avoid `LLVM_BINARY_DIR` when other 
more specific variable are better… (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132316

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/test/CMakeLists.txt

Index: polly/test/CMakeLists.txt
===
--- polly/test/CMakeLists.txt
+++ polly/test/CMakeLists.txt
@@ -46,7 +46,7 @@
 
 set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
+set(LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}")
 if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
   set(POLLY_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 else()
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -12,7 +12,7 @@
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 if (CMAKE_CONFIGURATION_TYPES)
   set(POLLY_EXPORTS_FILE_NAME "PollyExports-$>.cmake")
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -15,7 +15,7 @@
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
 export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake)
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -3,7 +3,7 @@
 include(FindPrefixFromConfig)
 
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 # First for users who use an installed LLVM, create the LLVMExports.cmake file.
 set(LLVM_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1093,7 +1093,7 @@
   message(FATAL_ERROR "LLVM_INSTALL_PACKAGE_DIR must be defined and writable. GEN_CONFIG should only be passe when building LLVM proper.")
   endif()
   # LLVM_INSTALL_PACKAGE_DIR might be absolute, so don't reuse below.
-  set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
   file(WRITE
   "${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
   "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -940,9 +940,9 @@
   )
 
 # They are not referenced. See set_output_directory().
-set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin )
-set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
-set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
+set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
+set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
+set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
 
 if(LLVM_INCLUDE_TESTS)
   include(GetErrcMessages)
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -276,7 +276,7 @@
   # could be and pick the first that exists.
   foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
 "${LLVM_BUILD_LIBRARY_DIR}"
-"${LLVM_BINARY

[Lldb-commits] [PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-09-14 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov updated this revision to Diff 460220.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/complex-int.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/complex-conversion.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
=

[Lldb-commits] [lldb] f3d0bda - Revert "Revert "Be more careful to maintain quoting information when parsing commands.""

2022-09-14 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2022-09-14T14:49:51-07:00
New Revision: f3d0bda5344e8429121cb50aba5502c1b399e5cd

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

LOG: Revert "Revert "Be more careful to maintain quoting information when 
parsing commands.""

This reverts commit ac05bc0524c66c74278b26742896a4c634c034cf.

I had incorrectly removed one set of checks in the option handling in
Options::ParseAlias because I couldn't see what it is for.  It was a
bit obscure, but it handled the case where you pass "-something=other --"
as the input_line, which caused the built-in "run" alias not to return
the right value for IsDashDashCommand, causing TestHelp.py to fail.

Added: 
lldb/test/API/commands/command/backticks/Makefile
lldb/test/API/commands/command/backticks/TestBackticksInAlias.py
lldb/test/API/commands/command/backticks/main.c

Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/Interpreter/CommandAlias.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Utility/Args.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 0f137a7b3c496..255f50099ebb9 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -239,6 +239,14 @@ class CommandInterpreter : public Broadcaster,
 eCommandTypesAllThem = 0x  //< all commands
   };
 
+  // The CommandAlias and CommandInterpreter both have a hand in 
+  // substituting for alias commands.  They work by writing special tokens
+  // in the template form of the Alias command, and then detecting them when 
the
+  // command is executed.  These are the special tokens:
+  static const char *g_no_argument;
+  static const char *g_need_argument;
+  static const char *g_argument;
+
   CommandInterpreter(Debugger &debugger, bool synchronous_execution);
 
   ~CommandInterpreter() override = default;

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 101921ffc768b..5c058769ff3f9 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2472,6 +2472,13 @@ def assertSuccess(self, obj, msg=None):
 self.fail(self._formatMessage(msg,
 "'{}' is not success".format(error)))
 
+"""Assert that a command return object is successful"""
+def assertCommandReturn(self, obj, msg=None):
+if not obj.Succeeded():
+error = obj.GetError()
+self.fail(self._formatMessage(msg,
+"'{}' is not success".format(error)))
+
 """Assert two states are equal"""
 def assertState(self, first, second, msg=None):
 if first != second:

diff  --git a/lldb/source/Interpreter/CommandAlias.cpp 
b/lldb/source/Interpreter/CommandAlias.cpp
index d55b3fdd44faf..e36edcac15a59 100644
--- a/lldb/source/Interpreter/CommandAlias.cpp
+++ b/lldb/source/Interpreter/CommandAlias.cpp
@@ -60,11 +60,12 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP 
&cmd_obj_sp,
 
   if (!options_string.empty()) {
 if (cmd_obj_sp->WantsRawCommandString())
-  option_arg_vector->emplace_back("", -1, options_string);
+  option_arg_vector->emplace_back(CommandInterpreter::g_argument, 
+  -1, options_string);
 else {
   for (auto &entry : args.entries()) {
 if (!entry.ref().empty())
-  option_arg_vector->emplace_back(std::string(""), -1,
+  
option_arg_vector->emplace_back(std::string(CommandInterpreter::g_argument), -1,
   std::string(entry.ref()));
   }
 }
@@ -153,11 +154,12 @@ void CommandAlias::GetAliasExpansion(StreamString 
&help_string) const {
 
   for (const auto &opt_entry : *options) {
 std::tie(opt, std::ignore, value) = opt_entry;
-if (opt == "") {
+if (opt == CommandInterpreter::g_argument) {
   help_string.Printf(" %s", value.c_str());
 } else {
   help_string.Printf(" %s", opt.c_str());
-  if ((value != "") && (value != " 
CommandAlias::Desugar() {
 return {nullptr, nullptr};
 
   if (underlying->IsAlias()) {
+// FIXME: This doesn't work if the original alias fills a slot in the
+// underlying alias, since this just appends the two lists.
 auto desugared = ((CommandAlias *)underlying.get())->Desugar();
 auto options = GetOptionArguments();
 options->insert(options->begin(), desugared.second->begin(),

diff  --git a/lldb/source/Interpret

[Lldb-commits] [PATCH] D133906: [lldb] Generate lldb-forward with .def file

2022-09-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: mib, aprantl, labath.
Herald added a project: All.
JDevlieghere requested review of this revision.

Generate lldb-forward with .def file. The benefit is that we don't have to keep 
the list of classes, and typedefs in sync.


https://reviews.llvm.org/D133906

Files:
  lldb/include/lldb/lldb-forward.def
  lldb/include/lldb/lldb-forward.h

Index: lldb/include/lldb/lldb-forward.h
===
--- lldb/include/lldb/lldb-forward.h
+++ lldb/include/lldb/lldb-forward.h
@@ -16,276 +16,14 @@
 // lldb forward declarations
 namespace lldb_private {
 
-class ABI;
-class ASTResultSynthesizer;
-class ASTStructExtractor;
-class Address;
-class AddressRange;
-class AddressResolver;
-class ArchSpec;
-class Architecture;
-class Args;
-class ArmUnwindInfo;
-class Baton;
-class Block;
-class Breakpoint;
-class BreakpointID;
-class BreakpointIDList;
-class BreakpointList;
-class BreakpointLocation;
-class BreakpointLocationCollection;
-class BreakpointLocationList;
-class BreakpointName;
-class BreakpointOptionGroup;
-class BreakpointOptions;
-class BreakpointPrecondition;
-class BreakpointResolver;
-class BreakpointSite;
-class BreakpointSiteList;
-class BroadcastEventSpec;
-class Broadcaster;
-class BroadcasterManager;
-class CXXSyntheticChildren;
-struct CacheSignature;
-class CallFrameInfo;
-class CommandInterpreter;
-class CommandInterpreterRunOptions;
-class CommandObject;
-class CommandObjectMultiword;
-class CommandReturnObject;
-class Communication;
-class CompactUnwindInfo;
-class CompileUnit;
-class CompilerDecl;
-class CompilerDeclContext;
-class CompilerType;
-class Connection;
-class ConnectionFileDescriptor;
-class ConstString;
-class ConstStringTable;
-class DWARFCallFrameInfo;
-class DWARFDataExtractor;
-class DWARFExpression;
-class DWARFExpressionList;
-class DataBuffer;
-class WritableDataBuffer;
-class DataBufferHeap;
-class DataEncoder;
-class DataExtractor;
-class DataFileCache;
-class Debugger;
-class Declaration;
-class DiagnosticManager;
-class Disassembler;
-class DumpValueObjectOptions;
-class DynamicCheckerFunctions;
-class DynamicLoader;
-class Editline;
-class EmulateInstruction;
-class Environment;
-class EvaluateExpressionOptions;
-class Event;
-class EventData;
-class EventDataStructuredData;
-class ExecutionContext;
-class ExecutionContextRef;
-class ExecutionContextScope;
-class Expression;
-class ExpressionTypeSystemHelper;
-class ExpressionVariable;
-class ExpressionVariableList;
-class File;
-class FileSpec;
-class FileSpecList;
-class Flags;
-class FormatManager;
-class FormattersMatchCandidate;
-class FuncUnwinders;
-class Function;
-class FunctionCaller;
-class FunctionInfo;
-class IOHandler;
-class IOObject;
-class IRExecutionUnit;
-class InlineFunctionInfo;
-class Instruction;
-class InstructionList;
-class InstrumentationRuntime;
-class JITLoader;
-class JITLoaderList;
-class Language;
-class LanguageCategory;
-class LanguageRuntime;
-class LineTable;
-class Listener;
-class Log;
-class Mangled;
-class Materializer;
-class MemoryHistory;
-class MemoryRegionInfo;
-class MemoryRegionInfos;
-class Module;
-class ModuleList;
-class ModuleSpec;
-class ModuleSpecList;
-class ObjectContainer;
-class ObjectFile;
-class ObjectFileJITDelegate;
-class OperatingSystem;
-class OptionGroup;
-class OptionGroupOptions;
-class OptionGroupPlatform;
-class OptionValue;
-class OptionValueArch;
-class OptionValueArgs;
-class OptionValueArray;
-class OptionValueBoolean;
-class OptionValueChar;
-class OptionValueDictionary;
-class OptionValueEnumeration;
-class OptionValueFileSpec;
-class OptionValueFileSpecList;
-class OptionValueFormat;
-class OptionValueFormatEntity;
-class OptionValueLanguage;
-class OptionValuePathMappings;
-class OptionValueProperties;
-class OptionValueRegex;
-class OptionValueSInt64;
-class OptionValueString;
-class OptionValueUInt64;
-class OptionValueUUID;
-class Options;
-class PathMappingList;
-class PersistentExpressionState;
-class Platform;
-class Process;
-class ProcessAttachInfo;
-class ProcessInfo;
-class ProcessInstanceInfo;
-class ProcessInstanceInfoMatch;
-class ProcessLaunchInfo;
-class ProcessModID;
-class Property;
-class Queue;
-class QueueImpl;
-class QueueItem;
-class REPL;
-class RecognizedStackFrame;
-class RegisterCheckpoint;
-class RegisterContext;
-class RegisterValue;
-class RegularExpression;
-class RichManglingContext;
-class Scalar;
-class ScriptInterpreter;
-class ScriptInterpreterLocker;
-class ScriptedProcessInterface;
-class ScriptedThreadInterface;
-class ScriptedSyntheticChildren;
-class SearchFilter;
-class Section;
-class SectionList;
-class SectionLoadHistory;
-class SectionLoadList;
-class Settings;
-class SourceManager;
-class SourceManagerImpl;
-class StackFrame;
-class StackFrameList;
-class StackFrameRecognizer;
-class StackFrameRecognizerManager;
-class StackID;
-class Status;
-class StopInfo;
-class Stoppoint;
-class S

[Lldb-commits] [PATCH] D133906: [lldb] Generate lldb-forward with .def file

2022-09-14 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Definitely better than the previous contents!


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

https://reviews.llvm.org/D133906

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


[Lldb-commits] [PATCH] D133042: Add auto deduce source map setting

2022-09-14 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan added a comment.

@clayborg , it is my intention to make `target.auto-deduce-source-map` boolean 
flag ultimately working for both relative paths and two full paths (two full 
paths are really important for off build host debugging, e.g. dump or 
production debugging). In this patch, I focuses on getting relative path 
working because that's the default behavior; a follow-up patch can get two full 
paths working. 
In my opinion boolean flag setting is dead simple to use (to enable both) and 
an enumeration setting would add extra barrier for adoption.

I can add description to `target.auto-deduce-source-map` to explain it only 
works for relative paths.




Comment at: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h:70
+  llvm::Optional m_removed_prefix_opt;
+  lldb::TargetSP m_target = nullptr;
+  bool m_auto_deduce_source_map = false;

clayborg wrote:
> Store this as a weak pointer to a target to avoid a target that owns an 
> object that will keep the target object from ever being able to destruct 
> itself. Anytime you need to use the target then you use a local variable that 
> is a shared pointer:
> ```
> TargetSP target_sp = m_target_wp.lock();
> if (!target_sp)
>   return;
> ```
> 
Your later comment reminds me that we can get target from 
`GetBreakpoint()->GetTarget()` so we do not need to store target point at all. 



Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:217
+
+  const bool case_sensitive = m_location_spec.GetFileSpec().IsCaseSensitive();
+  for (uint32_t i = 0; i < sc_list.GetSize(); ++i) {

clayborg wrote:
> clayborg wrote:
> > Can we just return if m_location_spec.IsRelative() returns true here to 
> > short circuit this entire function? Many users type "b main.cpp:12" and we 
> > probably don't need to do any auto source map stuff if the request starts 
> > as a relative path like "main.cpp" or "foo/bar/baz.cpp" right?
> Move the "request_file" below to this line and use it to avoid copying it 
> each time through the loop.
I do not think we can because if an existing reverse source mapping is applied 
`m_location_spec` will become a relative path even though original request is 
full path (Remember the prefix is stripped and stored in `removed_prefix_opt`? )

I guess I can check:
1. If `removed_prefix_opt` is not available, then return if 
m_location_spec.IsRelative() is true.
2. If `removed_prefix_opt` is available, do nothing.




Comment at: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp:222
+
+FileSpec sc_file = sc.line_entry.file;
+FileSpec request_file = m_location_spec.GetFileSpec();

clayborg wrote:
> Should we quickly continue here if "sc_file" is not relative?
I do not think so. Here is an example:
```
dwarf sc_file:
/build/repo/x/y/z/foo.cpp

breakpoint request:
/user/root/new_repo_location/x/y/z/foo.cpp

User has an existing source mapping entry so a reverse mapping is applied:
original: .
replacement: /user/root/new_repo_location

After reverse mapping:
Breakpoint::m_location_spec: x/y/z/foo.cpp

With the new auto-deduce-source-map a new source mapping entry is added:
original: /build/repo
replacement: /user/root/new_repo_location

You can see the sc_list is full path in this example. 

```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133042

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


[Lldb-commits] [PATCH] D133906: [lldb] Generate lldb-forward with .def file

2022-09-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This patch makes me a little sad because it breaks the "Jump to Definition" 
chain Xcode (and I bet it does in other IDE's that support this.)  You used to 
be able to do "Jump to Definition" on ProcessSP, then jump to definition on the 
class name in the shared pointer definition to jump to the class.  Not the 
first jump takes you to:

LLDB_FORWARD_CLASS(Process)

in the lldb-forward.def file, and you can't go any further.  These .def 
insertions almost always make things harder to find in the actual code, so they 
aren't free.


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

https://reviews.llvm.org/D133906

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


[Lldb-commits] [PATCH] D133908: Add auto deduce source map setting

2022-09-14 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan created this revision.
Herald added a project: All.
yinghuitan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

  This patch adds a new "target.auto-deduce-source-map" setting.
  
  If enabled, this setting may auto deduce a source map entry based on requested
  breakpoint path and the original path stored in debug info for resolved
  breakpoint.
  
  As an example, if debug info contains "./a/b/c/main.cpp", user sets a source
  breakpoint at "/root/repo/x/y/z/a/b/c/main.cpp". The breakpoint will resolve
  correctly now with Greg's patch https://reviews.llvm.org/D130401. However, the
  resolved breakpoint will use "./a/b/c/main.cpp" to locate source file during
  stop event which would fail most of the time.
  
  With the new "target.auto-deduce-source-map" setting enabled, a auto deduced
  source map entry "." => "/root/repo/x/y/z" will be added. This new mapping 
will
  help lldb to map resolved breakpoint path "./a/b/c/main.cpp" back to
  "/root/repo/x/y/z/a/b/c/main.cpp" and locate it on disk.
  
  If an existing source map entry is used the patch also concatenates the auto
  deduced entry with any stripped reverse mapping prefix (see example below).
  
  As a second example, debug info contains "./a/b/c/main.cpp" and user sets
  breakpoint at "/root/repo/x/y/z/a/b/c/main.cpp". Let's say there is an 
existing
  source map entry "." => "/root/repo"; this mapping would strip the prefix out 
of
  "/root/repo/x/y/z/a/b/c/main.cpp" and use "x/y/z/a/b/c/main.cpp" to resolve
  breakpoint. "target.auto-deduce-source-map" setting would auto deduce a new
  potential mapping of "." => "x/y/z", then it detects that there is a stripped
  prefix from reverse mapping and concatenates it as the new mapping:
   "." => "/root/repo/x/y/z" which would correct map "./a/b/c/main.cpp" path to
  new path in disk.
  
  This patches depends on https://reviews.llvm.org/D130401 to use new added
  SBTarget::GetSourceMap() API for testing.
  
  Differential Revision: https://reviews.llvm.org/D133042


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133908

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Target/PathMappingList.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Target/PathMappingList.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/unittests/Target/PathMappingListTest.cpp

Index: lldb/unittests/Target/PathMappingListTest.cpp
===
--- lldb/unittests/Target/PathMappingListTest.cpp
+++ lldb/unittests/Target/PathMappingListTest.cpp
@@ -40,7 +40,7 @@
 map.RemapPath(ConstString(match.original.GetPath()), actual_remapped));
 EXPECT_EQ(FileSpec(actual_remapped.GetStringRef()), match.remapped);
 FileSpec unmapped_spec;
-EXPECT_TRUE(map.ReverseRemapPath(match.remapped, unmapped_spec));
+EXPECT_TRUE(map.ReverseRemapPath(match.remapped, unmapped_spec).hasValue());
 std::string unmapped_path = unmapped_spec.GetPath();
 EXPECT_EQ(unmapped_path, orig_normalized);
   }
Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -8,6 +8,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import json
 import os
 import side_effect
 
@@ -428,3 +429,69 @@
 
 bp_3 = target.FindBreakpointByID(bp_id_3)
 self.assertFalse(bp_3.IsValid(), "Didn't delete disabled breakpoint 3")
+
+
+def get_source_map_json(self):
+stream = lldb.SBStream()
+self.dbg.GetSetting("target.source-map").GetAsJSON(stream)
+return json.loads(stream.GetData())
+
+def verify_source_map_entry_pair(self, entry, original, replacement):
+self.assertEquals(entry[0], original,
+"source map entry 'original' does not match")
+self.assertEquals(entry[1], replacement,
+"source map entry 'replacement' does not match")
+
+@skipIf(oslist=["windows"])
+@no_debug_info_test
+def test_breakpoints_auto_deduce_source_map(self):
+"""
+Test that with target.auto-deduce-source-map settings.
+
+The "relative.yaml" contains a line table that is:
+
+Line table for a/b/c/main.cpp in `a.out
+0x00013f94: a/b/c/main.cpp:1
+0x00013fb0: a/b/c/main.cpp:2:3
+0x00013fb8: a/b/c/main.cpp:2:3
+"""
+src_dir = self.getSourceDir()
+yaml_path = os.pa

[Lldb-commits] [PATCH] D133042: Add auto deduce source map setting

2022-09-14 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan updated this revision to Diff 460270.
yinghuitan added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133042

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Target/PathMappingList.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Target/PathMappingList.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/unittests/Target/PathMappingListTest.cpp

Index: lldb/unittests/Target/PathMappingListTest.cpp
===
--- lldb/unittests/Target/PathMappingListTest.cpp
+++ lldb/unittests/Target/PathMappingListTest.cpp
@@ -40,7 +40,7 @@
 map.RemapPath(ConstString(match.original.GetPath()), actual_remapped));
 EXPECT_EQ(FileSpec(actual_remapped.GetStringRef()), match.remapped);
 FileSpec unmapped_spec;
-EXPECT_TRUE(map.ReverseRemapPath(match.remapped, unmapped_spec));
+EXPECT_TRUE(map.ReverseRemapPath(match.remapped, unmapped_spec).hasValue());
 std::string unmapped_path = unmapped_spec.GetPath();
 EXPECT_EQ(unmapped_path, orig_normalized);
   }
Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -8,6 +8,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import json
 import os
 import side_effect
 
@@ -428,3 +429,69 @@
 
 bp_3 = target.FindBreakpointByID(bp_id_3)
 self.assertFalse(bp_3.IsValid(), "Didn't delete disabled breakpoint 3")
+
+
+def get_source_map_json(self):
+stream = lldb.SBStream()
+self.dbg.GetSetting("target.source-map").GetAsJSON(stream)
+return json.loads(stream.GetData())
+
+def verify_source_map_entry_pair(self, entry, original, replacement):
+self.assertEquals(entry[0], original,
+"source map entry 'original' does not match")
+self.assertEquals(entry[1], replacement,
+"source map entry 'replacement' does not match")
+
+@skipIf(oslist=["windows"])
+@no_debug_info_test
+def test_breakpoints_auto_deduce_source_map(self):
+"""
+Test that with target.auto-deduce-source-map settings.
+
+The "relative.yaml" contains a line table that is:
+
+Line table for a/b/c/main.cpp in `a.out
+0x00013f94: a/b/c/main.cpp:1
+0x00013fb0: a/b/c/main.cpp:2:3
+0x00013fb8: a/b/c/main.cpp:2:3
+"""
+src_dir = self.getSourceDir()
+yaml_path = os.path.join(src_dir, "relative.yaml")
+yaml_base, ext = os.path.splitext(yaml_path)
+obj_path = self.getBuildArtifact("a.out")
+self.yaml2obj(yaml_path, obj_path)
+
+# Create a target with the object file we just created from YAML
+target = self.dbg.CreateTarget(obj_path)
+# We now have debug information with line table paths that start are
+# "./a/b/c/main.cpp".
+
+source_map_json = self.get_source_map_json()
+self.assertEquals(len(source_map_json), 0, "source map should be empty initially")
+self.runCmd("settings set target.auto-deduce-source-map true")
+
+# Verify auto deduced source map when file path in debug info
+# is a suffix of request breakpoint file path
+path = "/x/y/a/b/c/main.cpp"
+bp = target.BreakpointCreateByLocation(path, 2)
+self.assertTrue(bp.GetNumLocations() > 0,
+'Couldn\'t resolve breakpoint using full path "%s" in executate "%s" with '
+'debug info that has relative path with matching suffix' % (path, self.getBuildArtifact("a.out")))
+
+source_map_json = self.get_source_map_json()
+self.assertEquals(len(source_map_json), 1, "source map should not be empty")
+self.verify_source_map_entry_pair(source_map_json[0], ".", "/x/y")
+
+# Reset source map.
+self.runCmd("settings clear target.source-map")
+
+# Verify source map will not auto deduced when file path of request breakpoint
+# equals the file path in debug info.
+path = "a/b/c/main.cpp"
+bp = target.BreakpointCreateByLocation(path, 2)
+self.assertTrue(bp.GetNumLocations() > 0,
+'Couldn\'t resolve breakpoint using full path "%s" in executate "%s" with '
+'debug info that has relative path with matching suffix' % (path, self.getBuildArtifact("a.out

[Lldb-commits] [PATCH] D133906: [lldb] Generate lldb-forward with .def file

2022-09-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D133906#3791153 , @jingham wrote:

> This patch makes me a little sad because it breaks the "Jump to Definition" 
> chain in Xcode (and I bet it does in other IDE's that support this.)  You 
> used to be able to do "Jump to Definition" on ProcessSP, then jump to 
> definition on the class name in the shared pointer definition to jump to the 
> class.  Now the first jump takes you to:
>
> LLDB_FORWARD_CLASS(Process)
>
> in the lldb-forward.def file, and you can't go any further because the IDE 
> can't tell what to do with the contents of the .def file (it has no way to 
> know how it was imported to create real definitions).  These .def insertions 
> almost always make things harder to find in the actual code, so they aren't 
> free.

@jingham to be hosted, as a fellow Xcode user, this indirection annoyed me more 
than I found it convenient. May be we should have Xcode go directly to the 
template argument class when jumping to definition on smart pointers.


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

https://reviews.llvm.org/D133906

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


[Lldb-commits] [PATCH] D133906: [lldb] Generate lldb-forward with .def file

2022-09-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.

In D133906#3791153 , @jingham wrote:

> This patch makes me a little sad because it breaks the "Jump to Definition" 
> chain in Xcode (and I bet it does in other IDE's that support this.)  You 
> used to be able to do "Jump to Definition" on ProcessSP, then jump to 
> definition on the class name in the shared pointer definition to jump to the 
> class.  Now the first jump takes you to:
>
> LLDB_FORWARD_CLASS(Process)
>
> in the lldb-forward.def file, and you can't go any further because the IDE 
> can't tell what to do with the contents of the .def file (it has no way to 
> know how it was imported to create real definitions).  These .def insertions 
> almost always make things harder to find in the actual code, so they aren't 
> free.

@jingham to be hosted, as a fellow Xcode user, this indirection annoyed me more 
than I found it convenient. May be we should have Xcode go directly to the 
template argument class when jumping to definition on smart pointers.

@jdevlieghere LGTM! Thanks!


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

https://reviews.llvm.org/D133906

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


[Lldb-commits] [PATCH] D133908: Add auto deduce source map setting

2022-09-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

We also inject a source-map behind the scenes when a dSYM has path mapping keys 
as described in:

https://lldb.llvm.org/use/symbols.html

It would be good to make sure that the auto-detect source maps and that feature 
get along nicely both when the dSYM source map points to the right directory, 
and when it to is stale and points to some path that's not available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133908

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


[Lldb-commits] [PATCH] D133910: [NFCI] Refactor FormatterContainerPair into TieredFormatterContainer.

2022-09-14 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe created this revision.
jgorbe added reviewers: labath, jingham.
jgorbe added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
jgorbe requested review of this revision.

`FormatterContainerPair` is (as its name indicates) a very thin wrapper
over two formatter containers, one for exact matches and another one for
regex matches. The logic to decide which subcontainer to access is
replicated everywhere `FormatterContainerPair`s are used.

So, for example, when we look for a formatter there's some adhoc code
that does a lookup in the exact match formatter container, and if it
fails it does a lookup in the regex match formatter container. The same
logic is then copied and pasted for summaries, filters, and synthetic
child providers.

This change introduces a new `TieredFormatterContainer` that has two
main characteristics:

- It generalizes `FormatterContainerPair` from 2 to any number of 
subcontainers, that are looked up in priority order.
- It centralizes all the logic to choose which subcontainer to use for lookups, 
add/delete, and indexing.

This allows us to have a single copy of the same logic, templatized for
each kind of formatter. It also simplifies the upcoming addition of a
new tier of callback-based matches. See
https://discourse.llvm.org/t/rfc-python-callback-for-data-formatters-type-matching/64204
for more details about this.

The rest of the change is mostly replacing copy-pasted code with calls
to methods of the relevant `TieredFormatterContainer`, and adding some
methods to the `TypeCategoryImpl` class so we can remove some of this
copy-pasted code from `SBTypeCategory`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133910

Files:
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/source/API/SBTypeCategory.cpp
  lldb/source/DataFormatters/TypeCategory.cpp

Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -87,10 +87,7 @@
lldb::TypeFormatImplSP &entry) {
   if (!IsEnabled() || !IsApplicable(lang))
 return false;
-  if (GetTypeFormatsContainer()->Get(candidates, entry))
-return true;
-  bool regex = GetRegexTypeFormatsContainer()->Get(candidates, entry);
-  return regex;
+  return m_format_cont.Get(candidates, entry);
 }
 
 bool TypeCategoryImpl::Get(lldb::LanguageType lang,
@@ -98,10 +95,7 @@
lldb::TypeSummaryImplSP &entry) {
   if (!IsEnabled() || !IsApplicable(lang))
 return false;
-  if (GetTypeSummariesContainer()->Get(candidates, entry))
-return true;
-  bool regex = GetRegexTypeSummariesContainer()->Get(candidates, entry);
-  return regex;
+  return m_summary_cont.Get(candidates, entry);
 }
 
 bool TypeCategoryImpl::Get(lldb::LanguageType lang,
@@ -109,30 +103,29 @@
lldb::SyntheticChildrenSP &entry) {
   if (!IsEnabled() || !IsApplicable(lang))
 return false;
-  TypeFilterImpl::SharedPointer filter_sp;
+
   // first find both Filter and Synth, and then check which is most recent
+  bool pick_synth = false;
 
-  if (!GetTypeFiltersContainer()->Get(candidates, filter_sp))
-GetRegexTypeFiltersContainer()->Get(candidates, filter_sp);
+  TypeFilterImpl::SharedPointer filter_sp;
+  m_filter_cont.Get(candidates, filter_sp);
 
-  bool pick_synth = false;
-  ScriptedSyntheticChildren::SharedPointer synth;
-  if (!GetTypeSyntheticsContainer()->Get(candidates, synth))
-GetRegexTypeSyntheticsContainer()->Get(candidates, synth);
-  if (!filter_sp.get() && !synth.get())
+  ScriptedSyntheticChildren::SharedPointer synth_sp;
+  m_synth_cont.Get(candidates, synth_sp);
+
+  if (!filter_sp.get() && !synth_sp.get())
 return false;
-  else if (!filter_sp.get() && synth.get())
+  else if (!filter_sp.get() && synth_sp.get())
 pick_synth = true;
-
-  else if (filter_sp.get() && !synth.get())
+  else if (filter_sp.get() && !synth_sp.get())
 pick_synth = false;
-
-  else /*if (filter_sp.get() && synth.get())*/
+  else /*if (filter_sp.get() && synth_sp.get())*/
   {
-pick_synth = filter_sp->GetRevision() <= synth->GetRevision();
+pick_synth = filter_sp->GetRevision() <= synth_sp->GetRevision();
   }
+
   if (pick_synth) {
-entry = synth;
+entry = synth_sp;
 return true;
   } else {
 entry = filter_sp;
@@ -318,138 +311,62 @@
 
 TypeCategoryImpl::FormatContainer::MapValueType
 TypeCategoryImpl::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
-  FormatContainer::MapValueType retval;
-
-  if (type_sp) {
-if (type_sp->IsRegex())
-  GetRegexTypeFormatsContainer()->GetExact(ConstString(type_sp->GetName()),
-   retval);
-else
-  GetTypeFormatsContainer()->GetExact(ConstString(type_sp->GetName()),
-   

[Lldb-commits] [PATCH] D133858: [lldb] Reset breakpoint hit count before new runs

2022-09-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D133858#3790013 , @jingham wrote:

> Resetting the hit counts on rerun is a more useful behavior, so this is all 
> fine.  But the Target is the one that does all the breakpoint management, so 
> I think the resetting should go through the Target, not the Process.  And we 
> generally delegate "do on all breakpoints" operations to the BreakpointList, 
> so it would be more consistent with the current structure to go 
> Process::WillLaunch -> Target::ResetHitCounts -> 
> BreakpointList::ResetHitCounts.

@fdeazeve Pretty cool! But I agree with Jim, breakpoints are handled by the 
target not the process. As a side-note, in the current implementation, I don't 
think it's necessary to add the `DoWillAttachToProcessWithID` method and call 
override it in each process plugin. I think you could have


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133858

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


[Lldb-commits] [PATCH] D133906: [lldb] Generate lldb-forward with .def file

2022-09-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D133906#3791153 , @jingham wrote:

> This patch makes me a little sad because it breaks the "Jump to Definition" 
> chain in Xcode (and I bet it does in other IDE's that support this.)  You 
> used to be able to do "Jump to Definition" on ProcessSP, then jump to 
> definition on the class name in the shared pointer definition to jump to the 
> class.  Now the first jump takes you to:
>
> LLDB_FORWARD_CLASS(Process)
>
> in the lldb-forward.def file, and you can't go any further because the IDE 
> can't tell what to do with the contents of the .def file (it has no way to 
> know how it was imported to create real definitions).  These .def insertions 
> almost always make things harder to find in the actual code, so they aren't 
> free.

The alternative would be to have tablegen generate the header, but I think 
that's overkill, and I'm not even sure Xcode would pick the generated header.


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

https://reviews.llvm.org/D133906

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