[Lldb-commits] [PATCH] D146154: [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms

2023-03-16 Thread David Chisnall via Phabricator via lldb-commits
theraven added inline comments.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp:131
+ExecutionContext &exe_ctx) {
+  // TODO: This function is supposed to check whether an ObjC selector is
+  // present for an object. Might be implemented similar as in the Apple V2

sgraenitz wrote:
> theraven wrote:
> > I'm not sure how this is meant to work.  I'd expect this to call one of the 
> > runtime's introspection functions.  I believe the Apple version has 
> > variants of these that run without acquiring locks, which can be used in 
> > the debugger.  We can add these quite easily if necessary.
> The Apple V2 runtime has two ways to do it: 
> https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp#L1179
>  I experimented with the one that doesn't require `void 
> *gdb_class_getClass(void*)` from the runtime library, but the JIT kept on 
> crashing. So, for this first version I opted for a minimal implementation 
> that doesn't do any selector checks. Let's look at it in another review.
Can you open bugs against the runtime for the gdb_* symbols that we need?  I 
will add them.

The other method will crash on small objects because they don't have an isa 
pointer, their isa is in the low 1-3 bits of the object pointer, indexing into 
a table in the runtime.



Comment at: lldb/test/Shell/Expr/objc-gnustep-print.m:68
+//
+// MEMBERS_OUTSIDE: (lldb) p t->_int
+// MEMBERS_OUTSIDE: (int) $0 = 0

sgraenitz wrote:
> theraven wrote:
> > It's not clear from this test if it's correctly computing the offsets.  I 
> > suspect that it isn't, since I don't see any reference to the ivar offset 
> > variables.
> What exactly would you expect to see in the output?
If the offsets are all wrong, this will still work if it happens to land within 
zeroed memory, which is quite likely.  It would be good to have a method that 
set all of the ivars to something and then check for those values explicitly.  
Or check for `(char*)t->{ivar} - (char*)t` and make sure that this is the right 
value (this will change between 32/64/128-bit platforms).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146154

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


[Lldb-commits] [PATCH] D146154: [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms

2023-03-16 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked 3 inline comments as done.
sgraenitz added a comment.

In D146154#4197454 , @aprantl wrote:

> One thing I just realized — we need to make sure that we don't accidentally 
> create a GNUstep ObjC runtime in a Swift process that was built without ObjC 
> support on Linux.

Yes, thanks for bringing this up. The goal definitely is to avoid any 
accidental conflicts with existing use cases that don't need or expect a 
GNUstep runtime. I really want to get my focus to the Windows side and PDB 
parsing. It's useful to have Linux working as well, so that we have a testable 
feature set to match. Otherwise, we don't want to invest a lot of effort here 
yet.

> How can we ensure this works for both cases?

Shouldn't the Swift processes report `eLanguageTypeSwift`? Then 
`GNUstepObjCRuntime::CreateInstance()` rejects it reliably.

> I.e., can you detect based on the presence of a symbol or shared object that 
> an GNUstep runtime is present?

Are there existing cases that follow such an approach? Looking at the order of 
events here, it appears that we have to wait for `ModulesDidLoad()` to report 
the shared library before we can inspect its symbols. How would we proceed if 
we want to create the language runtime first? I.e. here 
https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Target/Process.cpp#L5727-L5732

The shared library has a GNUstep-specific EH personality for example, would 
that do?

  > llvm-nm libobjc2/build/libobjc.so | grep gnustep_objc
  000264c0 T __gnustep_objc_personality_v0
  00026500 T __gnustep_objcxx_personality_v0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146154

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


[Lldb-commits] [PATCH] D146045: [LLDB] Show sub type of signals when debugging a core file

2023-03-16 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 505758.
DavidSpickett added a comment.

Update GetSignalDescription function name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146045

Files:
  lldb/include/lldb/Target/StopInfo.h
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
  lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
  lldb/source/Target/StopInfo.cpp
  
lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -203,6 +203,9 @@
   omit defaulted template parameters. The full template parameter list can still be
   viewed with ``expr --raw-output``/``frame var --raw-output``. (`D141828 `_)
 
+* LLDB is now able to show the subtype of signals found in a core file. For example
+  memory tagging specific segfaults such as ``SIGSEGV: sync tag check fault``.
+
 Changes to Sanitizers
 -
 
Index: lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
===
--- lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
+++ lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
@@ -166,3 +166,14 @@
 # the MTE core file which does support it but does not allow writing tags.
 self.expect("memory tag write 0 1",
 substrs=["error: Process does not support memory tagging"], error=True)
+
+@skipIfLLVMTargetMissing("AArch64")
+def test_mte_tag_fault_reason(self):
+""" Test that we correctly report the fault reason. """
+self.runCmd("target create --core core.mte")
+
+# There is no fault address shown here because core files do not include
+# si_addr.
+self.expect("bt", substrs=[
+"* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV: "
+"sync tag check fault"])
Index: lldb/source/Target/StopInfo.cpp
===
--- lldb/source/Target/StopInfo.cpp
+++ lldb/source/Target/StopInfo.cpp
@@ -1039,8 +1039,9 @@
 
 class StopInfoUnixSignal : public StopInfo {
 public:
-  StopInfoUnixSignal(Thread &thread, int signo, const char *description)
-  : StopInfo(thread, signo) {
+  StopInfoUnixSignal(Thread &thread, int signo, const char *description,
+ std::optional code)
+  : StopInfo(thread, signo), m_code(code) {
 SetDescription(description);
   }
 
@@ -1095,19 +1096,26 @@
 if (m_description.empty()) {
   ThreadSP thread_sp(m_thread_wp.lock());
   if (thread_sp) {
+UnixSignalsSP unix_signals = thread_sp->GetProcess()->GetUnixSignals();
 StreamString strm;
-const char *signal_name =
-thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString(
-m_value);
-if (signal_name)
-  strm.Printf("signal %s", signal_name);
+strm << "signal ";
+
+std::string signal_name =
+unix_signals->GetSignalDescription(m_value, m_code);
+if (signal_name.size())
+  strm << signal_name;
 else
-  strm.Printf("signal %" PRIi64, m_value);
+  strm.Printf("%" PRIi64, m_value);
+
 m_description = std::string(strm.GetString());
   }
 }
 return m_description.c_str();
   }
+
+private:
+  // In siginfo_t terms, if m_value is si_signo, m_code is si_code.
+  std::optional m_code;
 };
 
 // StopInfoTrace
@@ -1366,9 +1374,10 @@
 }
 
 StopInfoSP StopInfo::CreateStopReasonWithSignal(Thread &thread, int signo,
-const char *description) {
+const char *description,
+std::optional code) {
   thread.GetProcess()->GetUnixSignals()->IncrementSignalHitCount(signo);
-  return StopInfoSP(new StopInfoUnixSignal(thread, signo, description));
+  return StopInfoSP(new StopInfoUnixSignal(thread, signo, description, code));
 }
 
 StopInfoSP StopInfo::CreateStopReasonToTrace(Thread &thread) {
Index: lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
===
--- lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -128,6 +128,7 @@
   std::vector notes;
   lldb::tid_t tid;
   int signo = 0;
+  int code = 0;
   int prstatus_sig = 0;
   std::string name;
 };
@@ -166,6 +167,7 @@
   lldb::RegisterContextSP m_thread_reg_ctx_sp;
 
   int m_signo;
+  int m_code;
 
   lldb_private::DataExtractor m_gpregs

[Lldb-commits] [PATCH] D146154: [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms

2023-03-16 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 505760.
sgraenitz marked 3 inline comments as done.
sgraenitz added a comment.

Extend the test to check both, zero initialization and assigned ivars


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146154

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.h
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
  lldb/test/Shell/Expr/objc-gnustep-print.m

Index: lldb/test/Shell/Expr/objc-gnustep-print.m
===
--- lldb/test/Shell/Expr/objc-gnustep-print.m
+++ lldb/test/Shell/Expr/objc-gnustep-print.m
@@ -27,23 +27,39 @@
 }
 @end
 
-@interface TestObj : NSObject {}
-- (int)ok;
+@interface TestObj : NSObject {
+  int _int;
+  float _float;
+  char _char;
+  void *_ptr_void;
+  NSObject *_ptr_nsobject;
+  id _id_objc;
+}
+- (void)check_ivars_zeroed;
+- (void)set_ivars;
 @end
 @implementation TestObj
-- (int)ok {
-  return self ? 0 : 1;
+- (void)check_ivars_zeroed {
+  ;
+}
+- (void)set_ivars {
+  _int = 1;
+  _float = 2.0f;
+  _char = '\3';
+  _ptr_void = (void*)4;
+  _ptr_nsobject = (NSObject*)5;
+  _id_objc = (id)6;
 }
 @end
 
-// RUN: %lldb -b -o "b objc-gnustep-print.m:35" -o "run" -o "p self" -o "p *self" -- %t | FileCheck %s --check-prefix=SELF
+// RUN: %lldb -b -o "b objc-gnustep-print.m:43" -o "run" -o "p self" -o "p *self" -- %t | FileCheck %s --check-prefix=SELF
 //
-// SELF: (lldb) b objc-gnustep-print.m:35
+// SELF: (lldb) b objc-gnustep-print.m:43
 // SELF: Breakpoint {{.*}} at objc-gnustep-print.m
 //
 // SELF: (lldb) run
 // SELF: Process {{[0-9]+}} stopped
-// SELF: -[TestObj ok](self=[[SELF_PTR:0x[0-9]+]]{{.*}}) at objc-gnustep-print.m:35
+// SELF: -[TestObj check_ivars_zeroed](self=[[SELF_PTR:0x[0-9]+]]{{.*}}) at objc-gnustep-print.m
 //
 // SELF: (lldb) p self
 // SELF: (TestObj *) $0 = [[SELF_PTR]]
@@ -54,9 +70,38 @@
 // SELF: isa
 // SELF: refcount
 // SELF:   }
+// SELF:   _int = 0
+// SELF:   _float = 0
+// SELF:   _char = '\0'
+// SELF:   _ptr_void = 0x{{0*}}
+// SELF:   _ptr_nsobject = nil
+// SELF:   _id_objc = nil
 // SELF: }
 
+// RUN: %lldb -b -o "b objc-gnustep-print.m:106" -o "run" -o "p t->_int" -o "p t->_float" -o "p t->_char" \
+// RUN:  -o "p t->_ptr_void" -o "p t->_ptr_nsobject" -o "p t->_id_objc" -- %t | FileCheck %s --check-prefix=IVARS_SET
+//
+// IVARS_SET: (lldb) p t->_int
+// IVARS_SET: (int) $0 = 1
+//
+// IVARS_SET: (lldb) p t->_float
+// IVARS_SET: (float) $1 = 2
+//
+// IVARS_SET: (lldb) p t->_char
+// IVARS_SET: (char) $2 = '\x03'
+//
+// IVARS_SET: (lldb) p t->_ptr_void
+// IVARS_SET: (void *) $3 = 0x{{0*}}4
+//
+// IVARS_SET: (lldb) p t->_ptr_nsobject
+// IVARS_SET: (NSObject *) $4 = 0x{{0*}}5
+//
+// IVARS_SET: (lldb) p t->_id_objc
+// IVARS_SET: (id) $5 = 0x{{0*}}6
+
 int main() {
   TestObj *t = [TestObj new];
-  return [t ok];
+  [t check_ivars_zeroed];
+  [t set_ivars];
+  return 0;
 }
Index: lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -38,7 +38,8 @@
   enum class ObjCRuntimeVersions {
 eObjC_VersionUnknown = 0,
 eAppleObjC_V1 = 1,
-eAppleObjC_V2 = 2
+eAppleObjC_V2 = 2,
+eGNUstep_libobjc2 = 3,
   };
 
   typedef lldb::addr_t ObjCISA;
Index: lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -235,6 +235,22 @@
   m_isa_to_descriptor.begin(), m_isa_to_descriptor.end());
 }
 
+void ObjCLanguageRuntime::ReadObjCLibraryIfNeeded(
+const ModuleList &module_list) {
+  if (!HasReadObjCLibrary()) {
+std::lock_guard guard(module_list.GetMutex());
+
+size_t num_modules = module_list.GetSize();
+for (size_t i = 0; i < num_modules; i++) {
+  auto mod = module_list.GetModuleAtIndex(i);
+  if (IsModuleObjCLibrary(mod)) {
+ReadObjCLibrary(mod);
+break;
+  }
+}
+  }
+}
+
 ObjCLanguageRuntime::ObjCISA
 ObjCLanguageRuntime::GetParentClass(ObjCLanguageRuntime::ObjCISA isa) {
   ClassDescriptorSP objc_class_sp(GetClassDescriptorFromISA(isa));
Index: lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.h
==

[Lldb-commits] [PATCH] D146154: [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms

2023-03-16 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added inline comments.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp:131
+ExecutionContext &exe_ctx) {
+  // TODO: This function is supposed to check whether an ObjC selector is
+  // present for an object. Might be implemented similar as in the Apple V2

theraven wrote:
> sgraenitz wrote:
> > theraven wrote:
> > > I'm not sure how this is meant to work.  I'd expect this to call one of 
> > > the runtime's introspection functions.  I believe the Apple version has 
> > > variants of these that run without acquiring locks, which can be used in 
> > > the debugger.  We can add these quite easily if necessary.
> > The Apple V2 runtime has two ways to do it: 
> > https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp#L1179
> >  I experimented with the one that doesn't require `void 
> > *gdb_class_getClass(void*)` from the runtime library, but the JIT kept on 
> > crashing. So, for this first version I opted for a minimal implementation 
> > that doesn't do any selector checks. Let's look at it in another review.
> Can you open bugs against the runtime for the gdb_* symbols that we need?  I 
> will add them.
> 
> The other method will crash on small objects because they don't have an isa 
> pointer, their isa is in the low 1-3 bits of the object pointer, indexing 
> into a table in the runtime.
Sure https://github.com/gnustep/libobjc2/issues/244



Comment at: lldb/test/Shell/Expr/objc-gnustep-print.m:68
+//
+// MEMBERS_OUTSIDE: (lldb) p t->_int
+// MEMBERS_OUTSIDE: (int) $0 = 0

theraven wrote:
> sgraenitz wrote:
> > theraven wrote:
> > > It's not clear from this test if it's correctly computing the offsets.  I 
> > > suspect that it isn't, since I don't see any reference to the ivar offset 
> > > variables.
> > What exactly would you expect to see in the output?
> If the offsets are all wrong, this will still work if it happens to land 
> within zeroed memory, which is quite likely.  It would be good to have a 
> method that set all of the ivars to something and then check for those values 
> explicitly.  Or check for `(char*)t->{ivar} - (char*)t` and make sure that 
> this is the right value (this will change between 32/64/128-bit platforms).
Ok, updated the test. I only checked on 64-bit, but it should support arbitrary 
pointer widths. Can we skip the test for ivar offset distance? I'd like to 
avoid testing the actual memory layout here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146154

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


[Lldb-commits] [PATCH] D146221: [CodeView] Add source languages ObjC and ObjC++

2023-03-16 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
sgraenitz added reviewers: rnk, zturner, compnerd, aleksandr.urakov.
Herald added a subscriber: hiraditya.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added projects: LLDB, LLVM.
Herald added a subscriber: lldb-commits.

This patch adds llvm::codeview::SourceLanguage entries, DWARF translations, and 
PDB source file extensions in LLVM and allow LLDB's PDB parsers to recognize 
them correctly.

The CV_CFL_LANG enum in the Visual Studio 2022 documentation 
https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang
 defines:

  CV_CFL_OBJC = 0x11,
  CV_CFL_OBJCXX   = 0x12,

Since the initial commit in D24317 , ObjC was 
emitted as C language and ObjC++ as Masm.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146221

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  llvm/include/llvm/DebugInfo/CodeView/CodeView.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/EnumTables.cpp
  llvm/lib/DebugInfo/PDB/PDBExtras.cpp
  llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
  llvm/test/DebugInfo/COFF/language.ll
  llvm/test/DebugInfo/COFF/objc.ll
  llvm/test/DebugInfo/COFF/objcpp.ll
  llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp

Index: llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
===
--- llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
+++ llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
@@ -210,6 +210,8 @@
 RETURN_CASE(SourceLanguage, D, "d");
 RETURN_CASE(SourceLanguage, Swift, "swift");
 RETURN_CASE(SourceLanguage, Rust, "rust");
+RETURN_CASE(SourceLanguage, ObjC, "objc");
+RETURN_CASE(SourceLanguage, ObjCpp, "objc++");
   }
   return formatUnknownEnum(Lang);
 }
Index: llvm/test/DebugInfo/COFF/objcpp.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/objcpp.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s | FileCheck %s --check-prefix=ASM
+; RUN: llc -filetype=obj < %s | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ
+
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   18  # Flags and language
+; ASM-NEXT: .short  208 # CPUType
+
+; OBJ-LABEL: Compile3Sym {
+; OBJ-NEXT:Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT:Language: ObjCpp (0x12)
+; OBJ-NEXT:Flags [ (0x0)
+; OBJ-NEXT:]
+; OBJ-NEXT:Machine: X64 (0xD0)
+; OBJ-NEXT:FrontendVersion: {{[0-9\.]*}}
+; OBJ-NEXT:BackendVersion: {{[0-9\.]*}}
+; OBJ-NEXT:VersionName: clang version 17.0.0 (https://github.com/llvm/llvm-project a8e9beca6bee1f248ef4be7892802c4d091b7fcb)
+; OBJ-NEXT:  }
+
+; ModuleID = 'objcpp.mm'
+source_filename = "objcpp.mm"
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+; Function Attrs: uwtable
+define void @"?f@@YAXXZ"() #0 !dbg !5 {
+entry:
+  ret void, !dbg !9
+}
+
+attributes #0 = { uwtable "target-cpu"="x86-64" }
+
+!llvm.module.flags = !{!0, !1, !2}
+!llvm.dbg.cu = !{!3}
+
+!0 = !{i32 8, !"PIC Level", i32 2}
+!1 = !{i32 2, !"CodeView", i32 1}
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = distinct !DICompileUnit(language: DW_LANG_ObjC_plus_plus, file: !4, producer: "clang version 17.0.0 (https://github.com/llvm/llvm-project a8e9beca6bee1f248ef4be7892802c4d091b7fcb)", isOptimized: false, runtimeVersion: 1, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!4 = !DIFile(filename: "objcpp.mm", directory: "src", checksumkind: CSK_MD5, checksum: "e6ab1d5b7f82464c963a8522037dfa72")
+!5 = distinct !DISubprogram(name: "f", linkageName: "?f@@YAXXZ", scope: !4, file: !4, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !8)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = !{}
+!9 = !DILocation(line: 1, scope: !5)
Index: llvm/test/DebugInfo/COFF/objc.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/objc.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s | FileCheck %s --check-prefix=ASM
+; RUN: llc -filetype=obj < %s | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ
+
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType
+
+; OBJ-LABEL: Compile3Sym {
+; OBJ-NEXT:Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT:Language: ObjC (0x11)
+; OBJ-NEXT:Flags [ (0x0)
+; OBJ-NEXT:]
+; OBJ-NEXT:Machine: X64 (0xD0)
+; OBJ-NEXT:FrontendVersion: {{[0-9\.]*}}
+; OBJ-NEXT:BackendVersion: {{[0-9\.]*}}
+; OBJ-NEXT:VersionName: clang version 17.0.0 (https://github

[Lldb-commits] [PATCH] D146154: [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms

2023-03-16 Thread David Chisnall via Phabricator via lldb-commits
theraven added a comment.

The test looks fine to me, I'm quite surprised that it passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146154

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


[Lldb-commits] [PATCH] D146222: [lldb] Add compile time checks for signal codes when on the matching platform

2023-03-16 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: krytarowski, arichardson, emaste.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds a new macro to the UnixSignals subclasses, ADD_SIGCODE.

ADD_SIGCODE(4, ILL_ILLOPC, 1, "illegal opcode");

Adds a sigcode to signal 4. That code is ILL_ILLOPC and we expect
its value to be 1. When compiling on a system that matches the class
e.g. FreeBSD for FreeBSDSignals, the macro will check that that is true.

When you're not on FreeBSD we just use the number 1, and ILL_ILLOPC
won't be defined to anything because we don't include csignal.

Example error:
LinuxSignals.cpp:52:3: error: static_assert failed due to requirement
'ILL_COPROC == 9' "Value mismatch for signal code ILL_COPROC"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146222

Files:
  lldb/include/lldb/Target/UnixSignals.h
  lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
  lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
  lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp

Index: lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
===
--- lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
+++ lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -8,6 +8,21 @@
 
 #include "NetBSDSignals.h"
 
+#ifdef __NetBSD__
+#include 
+
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3
+#endif
+
+#define ADD_SIGCODE(signal, name, value, ...)  \
+  static_assert(name == value, "Value mismatch for signal code " #name);   \
+  AddSignalCode(signal, value, __VA_ARGS__)
+#else
+#define ADD_SIGCODE(signal, name, value, ...)  \
+  AddSignalCode(signal, value, __VA_ARGS__)
+#endif /* ifdef __NetBSD__ */
+
 using namespace lldb_private;
 
 NetBSDSignals::NetBSDSignals() : UnixSignals() { Reset(); }
@@ -17,34 +32,34 @@
 
   // clang-format off
   // SIGILL
-  AddSignalCode(4, 1 /*ILL_ILLOPC*/, "illegal opcode");
-  AddSignalCode(4, 2 /*ILL_ILLOPN*/, "illegal operand");
-  AddSignalCode(4, 3 /*ILL_ILLADR*/, "illegal addressing mode");
-  AddSignalCode(4, 4 /*ILL_ILLTRP*/, "illegal trap");
-  AddSignalCode(4, 5 /*ILL_PRVOPC*/, "privileged opcode");
-  AddSignalCode(4, 6 /*ILL_PRVREG*/, "privileged register");
-  AddSignalCode(4, 7 /*ILL_COPROC*/, "coprocessor error");
-  AddSignalCode(4, 8 /*ILL_BADSTK*/, "internal stack error");
+  ADD_SIGCODE(4, ILL_ILLOPC, 1, "illegal opcode");
+  ADD_SIGCODE(4, ILL_ILLOPN, 2, "illegal operand");
+  ADD_SIGCODE(4, ILL_ILLADR, 3, "illegal addressing mode");
+  ADD_SIGCODE(4, ILL_ILLTRP, 4, "illegal trap");
+  ADD_SIGCODE(4, ILL_PRVOPC, 5, "privileged opcode");
+  ADD_SIGCODE(4, ILL_PRVREG, 6, "privileged register");
+  ADD_SIGCODE(4, ILL_COPROC, 7, "coprocessor error");
+  ADD_SIGCODE(4, ILL_BADSTK, 8, "internal stack error");
 
   // SIGFPE
-  AddSignalCode(8, 1 /*FPE_INTDIV*/, "integer divide by zero");
-  AddSignalCode(8, 2 /*FPE_INTOVF*/, "integer overflow");
-  AddSignalCode(8, 3 /*FPE_FLTDIV*/, "floating point divide by zero");
-  AddSignalCode(8, 4 /*FPE_FLTOVF*/, "floating point overflow");
-  AddSignalCode(8, 5 /*FPE_FLTUND*/, "floating point underflow");
-  AddSignalCode(8, 6 /*FPE_FLTRES*/, "floating point inexact result");
-  AddSignalCode(8, 7 /*FPE_FLTINV*/, "invalid floating point operation");
-  AddSignalCode(8, 8 /*FPE_FLTSUB*/, "subscript out of range");
+  ADD_SIGCODE(8, FPE_INTDIV, 1, "integer divide by zero");
+  ADD_SIGCODE(8, FPE_INTOVF, 2, "integer overflow");
+  ADD_SIGCODE(8, FPE_FLTDIV, 3, "floating point divide by zero");
+  ADD_SIGCODE(8, FPE_FLTOVF, 4, "floating point overflow");
+  ADD_SIGCODE(8, FPE_FLTUND, 5, "floating point underflow");
+  ADD_SIGCODE(8, FPE_FLTRES, 6, "floating point inexact result");
+  ADD_SIGCODE(8, FPE_FLTINV, 7, "invalid floating point operation");
+  ADD_SIGCODE(8, FPE_FLTSUB, 8, "subscript out of range");
 
   // SIGBUS
-  AddSignalCode(10, 1 /*BUS_ADRALN*/, "invalid address alignment");
-  AddSignalCode(10, 2 /*BUS_ADRERR*/, "non-existent physical address");
-  AddSignalCode(10, 3 /*BUS_OBJERR*/, "object specific hardware error");
+  ADD_SIGCODE(10, BUS_ADRALN, 1, "invalid address alignment");
+  ADD_SIGCODE(10, BUS_ADRERR, 2, "non-existent physical address");
+  ADD_SIGCODE(10, BUS_OBJERR, 3, "object specific hardware error");
 
   // SIGSEGV
-  AddSignalCode(11, 1 /*SEGV_MAPERR*/, "address not mapped to object",
+  ADD_SIGCODE(11, SEGV_MAPERR, 1, "address not mapped to object",
 SignalCodePrintOption::Address);
-  AddSignalCode(11, 2 /*SEGV_ACCERR*/, "invalid permissions for mapped object",
+  ADD_SIGCODE(11, SEGV_ACCERR, 2, "invalid permissions for mapped object",
 SignalCodePrintOption::Address);
 
   //SIGNO  NAME  SUPPRESS STOP   NOTIFY DESCRIPTION
Index: lldb/source/Plugins/Process/Utility/LinuxSigna

[Lldb-commits] [PATCH] D146044: [lldb] Implement CrashReason using UnixSignals

2023-03-16 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett marked 2 inline comments as done.
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp:14
 FreeBSDSignals::FreeBSDSignals() : UnixSignals() { Reset(); }
 
 void FreeBSDSignals::Reset() {

DavidSpickett wrote:
> arichardson wrote:
> > I wonder if it would make sense to do something like the following to 
> > ensure we use the same numbers as defined in FreeBSD (compile-time checks 
> > when building on a FreeBSD host). The it would be possible to use 
> > `FREEBSD_ILL_ILLOPC` instead of `1 /*ILL_ILLOPC*/` below
> This is a cool idea, I'll give this a go (maybe as a follow up change).
https://reviews.llvm.org/D146222


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146044

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


[Lldb-commits] [PATCH] D146222: [lldb] Add compile time checks for signal codes when on the matching platform

2023-03-16 Thread Ed Maste via Phabricator via lldb-commits
emaste added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp:14-16
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3
+#endif

I'm curious what this is for; we don't use it below?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146222

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


[Lldb-commits] [PATCH] D146230: [lldb][test] Replace use of p with expression in Shell tests (NFC)

2023-03-16 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: aprantl, JDevlieghere, mib.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

In Shell tests, replace use of the `p` alias with the `expression` command.

To avoid conflating tests of the alias with tests of the expression command,
this patch canonicalizes to the use `expression`.

See also D141539  which made the same change 
to API tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146230

Files:
  lldb/test/Shell/Commands/command-source.test
  lldb/test/Shell/Commands/command-stop-hook-no-target.test
  lldb/test/Shell/Expr/nodefaultlib.cpp
  lldb/test/Shell/Register/x86-64-fp-read.test
  lldb/test/Shell/Register/x86-db-read.test
  lldb/test/Shell/Register/x86-fp-read.test
  lldb/test/Shell/Settings/Inputs/DontStopCommandSource.in
  lldb/test/Shell/Settings/Inputs/StopCommandSource.in
  lldb/test/Shell/Settings/TestStopCommandSourceOnError.test
  lldb/test/Shell/SymbolFile/DWARF/debug-types-expressions.test
  lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/DW_TAG_GNU_call_site-DW_AT_low_pc.s
  lldb/test/Shell/SymbolFile/DWARF/x86/DW_TAG_variable-DW_AT_const_value.s
  lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
  lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test
  lldb/test/Shell/SymbolFile/DWARF/x86/dwarf5-line-strp.s
  lldb/test/Shell/SymbolFile/DWARF/x86/limit-debug-info.s
  lldb/test/Shell/SymbolFile/NativePDB/Inputs/inline_sites_live.lldbinit
  lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables.lldbinit
  lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
  lldb/test/Shell/SymbolFile/NativePDB/inline_sites_live.cpp
  lldb/test/Shell/SymbolFile/NativePDB/local-variables.cpp
  lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script
  lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script
  lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script
  lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script
  lldb/test/Shell/SymbolFile/PDB/expressions.test

Index: lldb/test/Shell/SymbolFile/PDB/expressions.test
===
--- lldb/test/Shell/SymbolFile/PDB/expressions.test
+++ lldb/test/Shell/SymbolFile/PDB/expressions.test
@@ -2,34 +2,34 @@
 RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/ExpressionsTest.cpp
 RUN: not %lldb -b -s %S/Inputs/ExpressionsTest0.script -s %S/Inputs/ExpressionsTest1.script -s %S/Inputs/ExpressionsTest2.script -- %t.exe 2>&1 | FileCheck %s
 
-// Check the variable value through `print`
-CHECK: (lldb) print result
+// Check the variable value through `expression`
+CHECK: (lldb) expression result
 CHECK: (char) $0 = '\x1c'
 
 // Call the function just like in the code
-CHECK: (lldb) print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1))
+CHECK: (lldb) expression N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1))
 CHECK: (char) $1 = '\x1c'
 
 // Try the relaxed namespaces search
-CHECK: (lldb) print N1::sum(N1::buf1, sizeof(N1::buf1))
+CHECK: (lldb) expression N1::sum(N1::buf1, sizeof(N1::buf1))
 CHECK: (char) $2 = '\x1c'
 
 // Try the relaxed variables and functions search
-CHECK: (lldb) print sum(buf1, sizeof(buf1))
+CHECK: (lldb) expression sum(buf1, sizeof(buf1))
 CHECK: (char) $3 = '\x1c'
 
 // Make a crash during expression calculation
-CHECK: (lldb) print sum(buf1, 10)
+CHECK: (lldb) expression sum(buf1, 10)
 CHECK: The process has been returned to the state before expression evaluation.
 
 // Make one more crash
-CHECK: (lldb) print sum(buf0, 1)
+CHECK: (lldb) expression sum(buf0, 1)
 CHECK: The process has been returned to the state before expression evaluation.
 
 // Check if the process state was restored succesfully
-CHECK: (lldb) print sum(buf0, result - 28)
+CHECK: (lldb) expression sum(buf0, result - 28)
 CHECK: (char) $4 = '\0'
 
 // Call the function with arbitrary parameters
-CHECK: (lldb) print sum(buf1 + 3, 3)
+CHECK: (lldb) expression sum(buf1 + 3, 3)
 CHECK: (char) $5 = '\f'
Index: lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script
===
--- lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script
@@ -2,6 +2,6 @@
 
 run
 
-print c
+expression c
 
-frame variable c
\ No newline at end of file
+frame variable c
Index: lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script
===
--- lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script
@@ -1,2 +1,2 @@
-print sum(buf0, result - 28)
-print sum(buf1 + 3, 3)
+expression sum(buf0, result - 28)
+expression sum(buf1 + 3, 3)
Index: lldb/te

[Lldb-commits] [PATCH] D146230: [lldb][test] Replace use of p with expression in Shell tests (NFC)

2023-03-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM. I probably would've gone with `expo` but as `expression` is the canonical 
name of the command, this makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146230

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


[Lldb-commits] [PATCH] D146230: [lldb][test] Replace use of p with expression in Shell tests (NFC)

2023-03-16 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

> I probably would've gone with `expr`

I had it as `expr` at first and changed it to `expression`, since that's what I 
had done in D141539 . I'm down to change it 
to `expr`, I think it's probably fine too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146230

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


[Lldb-commits] [PATCH] D146262: [lldb] Set the watchpoint spec for expression watchpoints

2023-03-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, mib, delcypher.
Herald added a project: All.
JDevlieghere requested review of this revision.

When setting a variable watchpoint, the watchpoint stores the variable name in 
the watchpoint spec. For expression variables we should store the expression in 
the watchpoint spec. This patch adds that functionality.


https://reviews.llvm.org/D146262

Files:
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  
lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py


Index: 
lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
===
--- 
lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ 
lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -46,7 +46,7 @@
 self.setTearDownCleanup()
 
 exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+target = self.dbg.CreateTarget(exe)
 
 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
 lldbutil.run_break_set_by_file_and_line(
@@ -81,6 +81,12 @@
 self.expect("watchpoint list -v",
 substrs=['hit_count = 0'])
 
+# Check the underlying SBWatchpoint.
+watchpoint = target.GetWatchpointAtIndex(0)
+self.assertEqual(watchpoint.GetWatchSize(), 1)
+self.assertEqual(watchpoint.GetHitCount(), 0)
+self.assertEqual(watchpoint.GetWatchSpec(), "g_char_ptr + 7")
+
 self.runCmd("process continue")
 
 # We should be stopped again due to the watchpoint (write type), but
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -949,9 +949,8 @@
 uint32_t watch_type = m_option_watchpoint.watch_type;
 
 error.Clear();
-Watchpoint *wp =
-target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, &compiler_type, watch_type, 
error);
 if (wp) {
   wp->SetWatchSpec(command.GetArgumentAtIndex(0));
   wp->SetWatchVariable(true);
@@ -1117,10 +1116,10 @@
 CompilerType compiler_type(valobj_sp->GetCompilerType());
 
 Status error;
-Watchpoint *wp =
-target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, &compiler_type, watch_type, 
error);
 if (wp) {
+  wp->SetWatchSpec(std::string(expr));
   Stream &output_stream = result.GetOutputStream();
   output_stream.Printf("Watchpoint created: ");
   wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);


Index: lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
===
--- lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -46,7 +46,7 @@
 self.setTearDownCleanup()
 
 exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+target = self.dbg.CreateTarget(exe)
 
 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
 lldbutil.run_break_set_by_file_and_line(
@@ -81,6 +81,12 @@
 self.expect("watchpoint list -v",
 substrs=['hit_count = 0'])
 
+# Check the underlying SBWatchpoint.
+watchpoint = target.GetWatchpointAtIndex(0)
+self.assertEqual(watchpoint.GetWatchSize(), 1)
+self.assertEqual(watchpoint.GetHitCount(), 0)
+self.assertEqual(watchpoint.GetWatchSpec(), "g_char_ptr + 7")
+
 self.runCmd("process continue")
 
 # We should be stopped again due to the watchpoint (write type), but
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -949,9 +949,8 @@
 uint32_t watch_type = m_option_watchpoint.watch_type;
 
 error.Clear();
-Watchpoint *wp =
-target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
 if (wp) {
   wp->SetWatchSpec(command.GetArgumentAtIndex(0));
   wp->SetWatchVariable(true);
@@ -1117,10 +1116,10 @@
 CompilerType compiler_type(valobj_sp->GetCompilerType())

[Lldb-commits] [PATCH] D146262: [lldb] Set the watchpoint spec for expression watchpoints

2023-03-16 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D146262

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


[Lldb-commits] [PATCH] D146263: [lldb] Move UnixSignals creation into Platform plugins

2023-03-16 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jingham, mib, labath, clayborg.
Herald added a subscriber: emaste.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The high level goal of this change is to remove lldbTarget's dependency
on lldbPluginProcessUtility. The reason for this existing dependency is
so that we can create the appropriate UnixSignals object based on an
ArchSpec. Instead of using the ArchSpec, we can instead take advantage
of the Platform associated with the current Target.

This is accomplished by adding a new method to Platform,
CreateUnixSignals, which will create the correct UnixSignals object for
us. We then can use `Platform::GetUnixSignals` and rely on that to give
us the correct signals as needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146263

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Target/UnixSignals.h
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
  lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
  lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp
  lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/CMakeLists.txt
  lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp
  lldb/source/Plugins/Platform/Linux/LinuxSignals.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/NetBSD/CMakeLists.txt
  lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp
  lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h
  lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
  lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.cpp
  lldb/source/Plugins/Platform/gdb-server/GDBRemoteSignals.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
  lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
  lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
  lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
  lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
  lldb/source/Plugins/Process/Utility/LinuxSignals.h
  lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
  lldb/source/Plugins/Process/Utility/NetBSDSignals.h
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Platform.cpp
  lldb/source/Target/UnixSignals.cpp
  lldb/unittests/Process/gdb-remote/CMakeLists.txt
  lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
  lldb/unittests/Target/RemoteAwarePlatformTest.cpp

Index: lldb/unittests/Target/RemoteAwarePlatformTest.cpp
===
--- lldb/unittests/Target/RemoteAwarePlatformTest.cpp
+++ lldb/unittests/Target/RemoteAwarePlatformTest.cpp
@@ -35,6 +35,8 @@
   MOCK_METHOD2(ResolveRemoteExecutable,
std::pair(const ModuleSpec &,
const FileSpecList *));
+  MOCK_METHOD0(CreateUnixSignals, lldb::UnixSignalsSP());
+
   Status ResolveRemoteExecutable(
   const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
   const FileSpecList *module_search_paths_ptr) /*override*/
@@ -61,6 +63,7 @@
ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
   MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
   MOCK_METHOD0(GetUserIDResolver, UserIDResolver &());
+  MOCK_METHOD0(CreateUnixSignals, lldb::UnixSignalsSP());
 };
 
 namespace {
Index: lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
@@ -9,7 +9,7 @@
 
 #include "GDBRemoteTestUtils.h"
 
-#include "Plugins/Process/Utility/LinuxSignals.h"
+#include "Plugins/Platform/Linux/LinuxSignals.h"
 #include "Plugins/Process/gdb-remote/GDBRemoteClientBase.h"
 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
 #include "lldb/Utility/GDBRemote.h"
Index: lldb/unittests/Process/gdb-remote/CMakeLists.txt
=

[Lldb-commits] [PATCH] D108335: [lldb] Move UnixSignals subclasses to lldbTarget

2023-03-16 Thread Alex Langford via Phabricator via lldb-commits
bulbazord abandoned this revision.
bulbazord added a comment.

This is made defunct by https://reviews.llvm.org/D146263


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108335

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


[Lldb-commits] [lldb] f341d7a - [lldb] Make MemoryCache::Read more resilient

2023-03-16 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-03-16T15:22:46-07:00
New Revision: f341d7a4091a6ec1c1a4a49c4810d4a8b036ad60

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

LOG: [lldb] Make MemoryCache::Read more resilient

MemoryCache::Read is not resilient to partial reads when reading memory
chunks less than or equal in size to L2 cache lines. There have been
attempts in the past to fix this but nothing really solved the root of
the issue.

I first created a test exercising MemoryCache's implementation and
documenting how I believe MemoryCache::Read should behave. I then
rewrote the implementation of MemoryCache::Read as needed to make sure
that the different scenarios behaved correctly.

rdar://105407095

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

Added: 
lldb/unittests/Target/MemoryTest.cpp

Modified: 
lldb/include/lldb/Target/Memory.h
lldb/source/Target/Memory.cpp
lldb/unittests/Target/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/Target/Memory.h 
b/lldb/include/lldb/Target/Memory.h
index 8c564e8f5a8c5..2d1489a2c96ea 100644
--- a/lldb/include/lldb/Target/Memory.h
+++ b/lldb/include/lldb/Target/Memory.h
@@ -61,6 +61,8 @@ class MemoryCache {
 private:
   MemoryCache(const MemoryCache &) = delete;
   const MemoryCache &operator=(const MemoryCache &) = delete;
+
+  lldb::DataBufferSP GetL2CacheLine(lldb::addr_t addr, Status &error);
 };
 
 

diff  --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index fdc01389721ed..45786415d23b1 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -123,18 +123,55 @@ bool MemoryCache::RemoveInvalidRange(lldb::addr_t 
base_addr,
   return false;
 }
 
+lldb::DataBufferSP MemoryCache::GetL2CacheLine(lldb::addr_t line_base_addr,
+   Status &error) {
+  // This function assumes that the address given is aligned correctly.
+  assert((line_base_addr % m_L2_cache_line_byte_size) == 0);
+
+  std::lock_guard guard(m_mutex);
+  auto pos = m_L2_cache.find(line_base_addr);
+  if (pos != m_L2_cache.end())
+return pos->second;
+
+  auto data_buffer_heap_sp =
+  std::make_shared(m_L2_cache_line_byte_size, 0);
+  size_t process_bytes_read = m_process.ReadMemoryFromInferior(
+  line_base_addr, data_buffer_heap_sp->GetBytes(),
+  data_buffer_heap_sp->GetByteSize(), error);
+
+  // If we failed a read, not much we can do.
+  if (process_bytes_read == 0)
+return lldb::DataBufferSP();
+
+  // If we didn't get a complete read, we can still cache what we did get.
+  if (process_bytes_read < m_L2_cache_line_byte_size)
+data_buffer_heap_sp->SetByteSize(process_bytes_read);
+
+  m_L2_cache[line_base_addr] = data_buffer_heap_sp;
+  return data_buffer_heap_sp;
+}
+
 size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len,
  Status &error) {
-  size_t bytes_left = dst_len;
-
-  // Check the L1 cache for a range that contain the entire memory read. If we
-  // find a range in the L1 cache that does, we use it. Else we fall back to
-  // reading memory in m_L2_cache_line_byte_size byte sized chunks. The L1
-  // cache contains chunks of memory that are not required to be
-  // m_L2_cache_line_byte_size bytes in size, so we don't try anything tricky
-  // when reading from them (no partial reads from the L1 cache).
+  if (!dst || dst_len == 0)
+return 0;
 
   std::lock_guard guard(m_mutex);
+  // FIXME: We should do a more thorough check to make sure that we're not
+  // overlapping with any invalid ranges (e.g. Read 0x100 - 0x200 but there's 
an
+  // invalid range 0x180 - 0x280). `FindEntryThatContains` has an 
implementation
+  // that takes a range, but it only checks to see if the argument is contained
+  // by an existing invalid range. It cannot check if the argument contains
+  // invalid ranges and cannot check for overlaps.
+  if (m_invalid_ranges.FindEntryThatContains(addr)) {
+error.SetErrorStringWithFormat("memory read failed for 0x%" PRIx64, addr);
+return 0;
+  }
+
+  // Check the L1 cache for a range that contains the entire memory read.
+  // L1 cache contains chunks of memory that are not required to be the size of
+  // an L2 cache line. We avoid trying to do partial reads from the L1 cache to
+  // simplify the implementation.
   if (!m_L1_cache.empty()) {
 AddrRange read_range(addr, dst_len);
 BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
@@ -149,105 +186,82 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t 
dst_len,
 }
   }
 
-  // If this memory read request is larger than the cache line size, then we
-  // (1) try to read as much of it at once as possible, and (2) don't add the
-  // data to the memory cache.  We don't want to split a 

[Lldb-commits] [PATCH] D145624: [lldb] Make MemoryCache::Read more resilient

2023-03-16 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf341d7a4091a: [lldb] Make MemoryCache::Read more resilient 
(authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145624

Files:
  lldb/include/lldb/Target/Memory.h
  lldb/source/Target/Memory.cpp
  lldb/unittests/Target/CMakeLists.txt
  lldb/unittests/Target/MemoryTest.cpp

Index: lldb/unittests/Target/MemoryTest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/MemoryTest.cpp
@@ -0,0 +1,228 @@
+//===-- MemoryTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Target/Memory.h"
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+using namespace lldb;
+
+namespace {
+class MemoryTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+  }
+  void TearDown() override {
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+
+class DummyProcess : public Process {
+public:
+  DummyProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp), m_bytes_left(0) {}
+
+  // Required overrides
+  bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) override {
+return true;
+  }
+  Status DoDestroy() override { return {}; }
+  void RefreshStateAfterStop() override {}
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+if (m_bytes_left == 0)
+  return 0;
+
+size_t num_bytes_to_write = size;
+if (m_bytes_left < size) {
+  num_bytes_to_write = m_bytes_left;
+  m_bytes_left = 0;
+} else {
+  m_bytes_left -= size;
+}
+
+memset(buf, 'B', num_bytes_to_write);
+return num_bytes_to_write;
+  }
+  bool DoUpdateThreadList(ThreadList &old_thread_list,
+  ThreadList &new_thread_list) override {
+return false;
+  }
+  llvm::StringRef GetPluginName() override { return "Dummy"; }
+
+  // Test-specific additions
+  size_t m_bytes_left;
+  MemoryCache &GetMemoryCache() { return m_memory_cache; }
+  void SetMaxReadSize(size_t size) { m_bytes_left = size; }
+};
+} // namespace
+
+TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
+  PlatformSP platform_sp;
+  TargetSP target_sp;
+  debugger_sp->GetTargetList().CreateTarget(
+  *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
+  return target_sp;
+}
+
+TEST_F(MemoryTest, TesetMemoryCacheRead) {
+  ArchSpec arch("x86_64-apple-macosx-");
+
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  TargetSP target_sp = CreateTarget(debugger_sp, arch);
+  ASSERT_TRUE(target_sp);
+
+  ListenerSP listener_sp(Listener::MakeListener("dummy"));
+  ProcessSP process_sp = std::make_shared(target_sp, listener_sp);
+  ASSERT_TRUE(process_sp);
+
+  DummyProcess *process = static_cast(process_sp.get());
+  MemoryCache &mem_cache = process->GetMemoryCache();
+  const uint64_t l2_cache_size = process->GetMemoryCacheLineSize();
+  Status error;
+  auto data_sp = std::make_shared(l2_cache_size * 2, '\0');
+  size_t bytes_read = 0;
+
+  // Cache empty, memory read fails, size > l2 cache size
+  process->SetMaxReadSize(0);
+  bytes_read = mem_cache.Read(0x1000, data_sp->GetBytes(),
+  data_sp->GetByteSize(), error);
+  ASSERT_TRUE(bytes_read == 0);
+
+  // Cache empty, memory read fails, size <= l2 cache size
+  data_sp->SetByteSize(l2_cache_size);
+  bytes_read = mem_cache.Read(0x1000, data_sp->GetBytes(),
+  data_sp->GetByteSize(), error);
+  ASSERT_TRUE(bytes_read == 0);
+
+  // Cache empty, memory read succeeds, size > l2 cache size
+  process->SetMaxReadSize(l2_cache_size * 4);
+  data_sp->SetByteSize(l2_cache_size * 2);
+  bytes_read = mem_cache.Read(0x1000, data_sp->GetBytes(),
+  data_sp->GetByteSize(), error);
+  ASSERT_TRUE(bytes_read == data_sp->Ge

[Lldb-commits] [PATCH] D146043: [lldb] Refactor CrashReason

2023-03-16 Thread Daniel Thornburgh via Phabricator via lldb-commits
mysterymath added a comment.

Hey, it looks like the reland of this is causing issues with the Fuchsia 
toolchain build: 
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8786444992328058977/overview
Seems that it's only legal to call AppendBounds if you first check for the 
definition of si_lower and si_upper, since these guard the definition of 
AppendBounds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146043

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


[Lldb-commits] [lldb] 88eb4cb - Remove #if guards from AppendBounds to fix compile on old POSIX.

2023-03-16 Thread Daniel Thornburgh via lldb-commits

Author: Daniel Thornburgh
Date: 2023-03-16T16:16:21-07:00
New Revision: 88eb4cbbfe7ded9556131c3bd4228ee9e9d01b4d

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

LOG: Remove #if guards from AppendBounds to fix compile on old POSIX.

Added: 


Modified: 
lldb/source/Plugins/Process/POSIX/CrashReason.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/POSIX/CrashReason.cpp 
b/lldb/source/Plugins/Process/POSIX/CrashReason.cpp
index 058ec6ad2d975..2ae7f8390575d 100644
--- a/lldb/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/lldb/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -54,7 +54,6 @@ static void AppendFaultAddr(std::string &str, lldb::addr_t 
addr) {
   str += ss.str();
 }
 
-#if defined(si_lower) && defined(si_upper)
 static void AppendBounds(std::string &str, lldb::addr_t lower_bound,
  lldb::addr_t upper_bound, lldb::addr_t addr) {
   llvm::raw_string_ostream stream(str);
@@ -71,7 +70,6 @@ static void AppendBounds(std::string &str, lldb::addr_t 
lower_bound,
   stream << ")";
   stream.flush();
 }
-#endif
 
 static CrashReason GetCrashReasonForSIGSEGV(int code) {
   switch (code) {



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


[Lldb-commits] [PATCH] D146265: [lldb] Introduce SymbolFile::ParseAllLanguages

2023-03-16 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
augusto2112 added a reviewer: aprantl.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, jplehr, sstefan1.
Herald added a project: LLDB.

SymbolFile::ParseAllLanguages allows collecting the languages of the
extra compile units a SymbolFileDWARFDebugMap may have, which can't
be accessed otherwise. For every other symbol file type, it should
behave exactly the same as ParseLanguage.

rdar://97610458


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146265

Files:
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -62,6 +62,8 @@
   ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
   lldb_private::XcodeSDK
   ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
+  llvm::SmallSet
+  ParseAllLanguages(lldb_private::CompileUnit &comp_unit) override;
   size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
   bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
   bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -683,6 +683,17 @@
   return {};
 }
 
+llvm::SmallSet
+SymbolFileDWARFDebugMap::ParseAllLanguages(
+lldb_private::CompileUnit &comp_unit) {
+  llvm::SmallSet langs;
+  auto *info = GetCompUnitInfo(comp_unit);
+  for (auto &comp_unit : info->compile_units_sps) {
+langs.insert(comp_unit->GetLanguage());
+  }
+  return langs;
+}
+
 size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) {
   std::lock_guard guard(GetModuleMutex());
   SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
Index: lldb/include/lldb/Symbol/SymbolFile.h
===
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -25,6 +25,7 @@
 #include "lldb/Utility/XcodeSDK.h"
 #include "lldb/lldb-private.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/Errc.h"
 
 #include 
@@ -146,6 +147,17 @@
   virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
   /// Return the Xcode SDK comp_unit was compiled against.
   virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
+
+  /// This function exists because SymbolFileDWARFDebugMap may extra compile
+  /// units which aren't exposed as "real" compile units. In every other
+  /// case this function should behave identically as ParseLanguage.
+  virtual llvm::SmallSet
+  ParseAllLanguages(CompileUnit &comp_unit) {
+llvm::SmallSet langs;
+langs.insert(ParseLanguage(comp_unit));
+return langs;
+  }
+
   virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
   virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
   virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -62,6 +62,8 @@
   ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
   lldb_private::XcodeSDK
   ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
+  llvm::SmallSet
+  ParseAllLanguages(lldb_private::CompileUnit &comp_unit) override;
   size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
   bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
   bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -683,6 +683,17 @@
   return {};
 }
 
+llvm::SmallSet
+SymbolFileDWARFDebugMap::ParseAllLanguages(
+lldb_private::CompileUnit &comp_unit) {
+  llvm::SmallSet langs;
+  auto *info = GetCompUnitInfo(comp_unit);
+  for (auto &comp_unit : info->compile_units_sps) {
+langs.insert(comp_unit->GetLanguage());
+  }
+  return langs;
+}
+
 size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) {
   std::lock_guard 

[Lldb-commits] [PATCH] D146222: [lldb] Add compile time checks for signal codes when on the matching platform

2023-03-16 Thread Alexander Richardson via Phabricator via lldb-commits
arichardson accepted this revision.
arichardson added a comment.
This revision is now accepted and ready to land.

Much neater than my initial suggestion. LGTM




Comment at: lldb/source/Plugins/Process/Utility/LinuxSignals.cpp:14
+
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3

I guess these are needed to support older versions that don't have the defines 
yet?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146222

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


[Lldb-commits] [PATCH] D146222: [lldb] Add compile time checks for signal codes when on the matching platform

2023-03-16 Thread Alexander Richardson via Phabricator via lldb-commits
arichardson added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp:15
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3
+#endif

Also unused like for FreeBSD?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146222

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