[Lldb-commits] [PATCH] D146337: Partially fix stepping over watchpoints on "watch triggers before" systems

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146337

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


[Lldb-commits] [PATCH] D146335: [lldb] Introduce CMake variable LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS

2023-03-17 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.

Thanks, this is great. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146335

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


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

2023-03-17 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145624

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


[Lldb-commits] [PATCH] D146337: Partially fix stepping over watchpoints on "watch triggers before" systems

2023-03-17 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: jasonmolenda, JDevlieghere.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

There were (at least) two problems that were causing TestStepOverWatchpoints.py 
to fail on arm64 Darwin systems.  The first was that the "step over the watch 
instruction" plan that we pushed so we could report the watch stop when we knew 
the "old and new" values was a utility plan that wouldn't cause a user stop 
when it was done, and so instead of reporting the watchpoint we just continued 
on with the step.

The second one may be specific to Darwin systems, but when you single-step the 
processor over an instruction that raises the watchpoint, when we stop the stop 
reason is Trace and not Watchpoint.  That not lldb's interpretation, that what 
the exception we get from the kernel says.

I don't have a good way to work around the second one yet, but I this patch 
fixes the first problem, and reworks the test so that we have a case that 
doesn't end up single-stepping over the instruction that triggers the 
watchpoint - which now succeeds on Darwin - and one that tests single-stepping 
over that instruction which still fails.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146337

Files:
  lldb/source/Target/StopInfo.cpp
  
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c

Index: lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c
===
--- lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c
+++ lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c
@@ -11,8 +11,8 @@
 }
 
 int main() {
-watch_read();
-g_temp = g_watch_me_read;
+watch_read(); // Set a breakpoint here
+g_temp = g_watch_me_read; // Set breakpoint after call
 watch_write();
 g_watch_me_write = g_temp;
 return 0;
Index: lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
===
--- lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
+++ lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -11,36 +11,11 @@
 class TestStepOverWatchpoint(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
-@expectedFailureAll(
-oslist=["freebsd", "linux"],
-archs=[
-'aarch64',
-'arm'],
-bugnumber="llvm.org/pr26031")
-# Read-write watchpoints not supported on SystemZ
-@expectedFailureAll(archs=['s390x'])
-@expectedFailureAll(
-oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
-archs=['aarch64', 'arm'],
-bugnumber="")
-@add_test_categories(["basic_process"])
-def test(self):
+def get_to_start(self, bkpt_text):
 """Test stepping over watchpoints."""
 self.build()
-target = self.createTestTarget()
-
-lldbutil.run_break_set_by_symbol(self, 'main')
-
-process = target.LaunchSimple(None, None,
-  self.get_process_working_directory())
-self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
-self.assertState(process.GetState(), lldb.eStateStopped,
- PROCESS_STOPPED)
-
-thread = lldbutil.get_stopped_thread(process,
- lldb.eStopReasonBreakpoint)
-self.assertTrue(thread.IsValid(), "Failed to get thread.")
-
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(self, bkpt_text,
+   lldb.SBFileSpec("main.c"))
 frame = thread.GetFrameAtIndex(0)
 self.assertTrue(frame.IsValid(), "Failed to get frame.")
 
@@ -55,14 +30,45 @@
 self.assertSuccess(error, "Error while setting watchpoint")
 self.assertTrue(read_watchpoint, "Failed to set read watchpoint.")
 
+# Disable the breakpoint we hit so we don't muddy the waters with
+# stepping off from the breakpoint:
+bkpt.SetEnabled(False)
+
+return (target, process, thread, read_watchpoint)
+
+@expectedFailureAll(
+oslist=["freebsd", "linux"],
+archs=[
+'aarch64',
+'arm'],
+bugnumber="llvm.org/pr26031")
+# Read-write watchpoints not supported on SystemZ
+@expectedFailureAll(archs=['s390x'])
+@add_test_categories(["basic_process"])
+def test_step_over(self):
+target, process, thread, wp = self.get_to_start("Set a breakpoint here")
+
 thread.StepOver()
 self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonWatchpoint,
 

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

2023-03-17 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.

You could add a test similar to 
lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp




Comment at: lldb/include/lldb/Symbol/SymbolFile.h:154
+  /// case this function should behave identically as ParseLanguage.
+  virtual llvm::SmallSet
+  ParseAllLanguages(CompileUnit _unit) {

I would increase the set size to 4. It's quite common to have C, C++, and ObjC 
in the same module.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146265

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


[Lldb-commits] [PATCH] D146335: [lldb] Introduce CMake variable LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS

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

The goal of this patch is to add the ability for the CMake configure to
fail when some optional test dependencies are not met. LLDB tries to be
flexible when test dependencies are not present but there are cases
where it would be useful to know that these dependencies are missing
before we run the test suite.

The intent here is to apply this setting on CI machines and make sure
that they have useful optional dependencies installed. We recently hit a
case where some CI machines were timing out while running the test suite
because a few tests were hanging. With this option, we'll be able to
know if the machine does not have psutil installed so we can install it
and avoid the timeout scenario altogether.

rdar://103194447


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146335

Files:
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/test/CMakeLists.txt


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -1,5 +1,30 @@
 # Test runner infrastructure for LLDB. This configures the LLDB test trees
 # for use by Lit, and delegates to LLVM's lit test handlers.
+# Lit requires a Python3 interpreter, let's be careful and fail early if it's
+# not present.
+if (NOT DEFINED Python3_EXECUTABLE)
+  message(FATAL_ERROR
+"LLDB test suite requires a Python3 interpreter but none "
+"was found. Please install Python3 or disable tests with "
+"`LLDB_INCLUDE_TESTS=OFF`.")
+endif()
+
+if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
+  message(STATUS "Enforcing strict test requirements for LLDB")
+  set(useful_python_modules
+psutil # Lit uses psutil to do per-test timeouts.
+  )
+  foreach(module ${useful_python_modules})
+lldb_find_python_module(${module})
+if (NOT PY_${module}_FOUND)
+  message(FATAL_ERROR
+"Python module '${module}' not found. Please install it via pip or via 
"
+"your operating system's package manager. Alternatively, disable "
+"strict testing requirements with "
+"`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
+endif()
+  endforeach()
+endif()
 
 if(LLDB_BUILT_STANDALONE)
   # In order to run check-lldb-* we need the correct map_config directives in
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -71,6 +71,8 @@
 option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing 
(Darwin only)." OFF)
 option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing 
lldb." OFF)
 option(LLDB_SKIP_DSYM "Whether to skip generating a dSYM when installing 
lldb." OFF)
+option(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
+  "Fail to configure if certain requirements are not met for testing." OFF)
 
 set(LLDB_GLOBAL_INIT_DIRECTORY "" CACHE STRING
   "Path to the global lldbinit directory. Relative paths are resolved relative 
to the
Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -349,6 +349,25 @@
   endif()
 endfunction()
 
+function(lldb_find_python_module module)
+  set(MODULE_FOUND PY_${module}_FOUND)
+  if (DEFINED ${MODULE_FOUND})
+return()
+  endif()
+
+  execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import ${module}"
+RESULT_VARIABLE status
+ERROR_QUIET)
+
+  if (status)
+set(${MODULE_FOUND} OFF CACHE BOOL "Failed to find python module 
'${module}'")
+message(STATUS "Could NOT find Python module '${module}'")
+  else()
+set(${MODULE_FOUND} ON CACHE BOOL "Found python module '${module}'")
+message(STATUS "Found Python module '${module}'")
+  endif()
+endfunction()
+
 # Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
 # the Objective-C++ code in lldb which we don't want to build with modules.
 # Reasons for this are that modules with Objective-C++ would require that


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -1,5 +1,30 @@
 # Test runner infrastructure for LLDB. This configures the LLDB test trees
 # for use by Lit, and delegates to LLVM's lit test handlers.
+# Lit requires a Python3 interpreter, let's be careful and fail early if it's
+# not present.
+if (NOT DEFINED Python3_EXECUTABLE)
+  message(FATAL_ERROR
+"LLDB test suite requires a Python3 interpreter but none "
+"was found. Please install Python3 or disable tests with "
+"`LLDB_INCLUDE_TESTS=OFF`.")
+endif()
+

[Lldb-commits] [PATCH] D146320: [lldb] Test direct ivar access in objc++ (NFC)

2023-03-17 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.

Otherwise LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146320

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


[Lldb-commits] [PATCH] D146320: [lldb] Test direct ivar access in objc++ (NFC)

2023-03-17 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/test/API/commands/frame/var/direct-ivar/objcpp/main.mm:6
+  void fun() {
+// check this
+  }

I would recommend using `printf("check this")` to make 100% sure that there is 
code on this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146320

___
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-17 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Here is an example of how the Swift Runtime plugin detects both itself and 
whether ObjC interop is enabled. Basically all I'm asking is to not 
accidentally break this mechanism.
https://github.com/apple/llvm-project/blob/7750ffa35111df6d38a5c73ab7e78ccebc9b43c3/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp#L124
If you want to make 100% sure, you could checkout the Swift compiler on Linux 
(or I suppose Windows) from github.com/apple/swift run 
`swift/utils/update-checkout --clone` apply your patch to llvm-project and run 
`swift/utils/build-script --lldb --test -- --skip-build-benchmarks 
--skip-test-cmark --skip-test-swift` and make sure the lldb tests still pass 
after applying you patch. But if you check for the symbol that would be 
sufficient for me.


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-17 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D146154#4198730 , @sgraenitz wrote:

> 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'm not sure where eLanguageType being passed in here comes from. Generally for 
Swift processes with (Apple) Objective-C interoperability enabled, it is the 
expected case to have both a Swift and an Objective-C runtime in the same 
process.

>> 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

I think that would be a great way to guard against false positives!


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] [lldb] b1e9bae - [lldb] Enable TestPublicAPIHeaders.py on Apple Silicon

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

Author: Alex Langford
Date: 2023-03-17T12:43:14-07:00
New Revision: b1e9baea3a2c486dc09b6a098439d1f75548b582

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

LOG: [lldb] Enable TestPublicAPIHeaders.py on Apple Silicon

This cleans up the test a bit and enables it to run on apple silicon
machines.

Added: 


Modified: 
lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py

Removed: 




diff  --git 
a/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py 
b/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
index b74e395b3e671..d57817d228e6c 100644
--- a/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
+++ b/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
@@ -9,6 +9,8 @@
 
 
 @skipIfNoSBHeaders
+@skipIfRemote
+@skipUnlessDarwin
 class SBDirCheckerCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -20,12 +22,8 @@ def setUp(self):
 def test_sb_api_directory(self):
 """Test the SB API directory and make sure there's no unwanted 
stuff."""
 
-# Only proceed if this is an Apple OS, "x86_64", and local platform.
-if not (self.platformIsDarwin() and self.getArchitecture() == 
"x86_64"):
+if not self.isAArch64() and self.getArchitecture() != "x86_64":
 self.skipTest("This test is only for LLDB.framework built 64-bit")
-if self.getArchitecture() == "i386":
-self.skipTest(
-"LLDB is 64-bit and cannot be linked to 32-bit test program.")
 
 exe_name = self.getBuildArtifact("a.out")
 self.buildDriver(self.source, exe_name)
@@ -33,7 +31,6 @@ def test_sb_api_directory(self):
 
 def sanity_check_executable(self, exe_name):
 """Sanity check executable compiled from the auto-generated program."""
-exe_name = self.getBuildArtifact("a.out")
 exe = self.getBuildArtifact(exe_name)
 self.runCmd("file %s" % exe, CURRENT_EXECUTABLE_SET)
 
@@ -46,10 +43,6 @@ def sanity_check_executable(self, exe_name):
 if self.TraceOn():
 print("Set environment to: ", env_cmd)
 self.runCmd(env_cmd)
-self.addTearDownHook(
-lambda: self.dbg.HandleCommand(
-"settings remove target.env-vars %s" %
-self.dylibPath))
 
 lldbutil.run_break_set_by_file_and_line(
 self, self.source, self.line_to_break, num_expected_locations=-1)



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


[Lldb-commits] [PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-17 Thread Richard Smith - zygoloid via Phabricator via lldb-commits
rsmith added a comment.

I have no strong opinions on the merits of this patch in either direction; I 
think the "sorry"s in the Sema diagnostics for regrettable non-conformance make 
Clang marginally friendlier, but they do nothing to actually help people who 
encounter the diagnostic.

FWIW, the relevant guidance on Clang diagnostics is 
https://clang.llvm.org/docs/InternalsManual.html#the-format-string, and that 
would override the LLVM coding guidelines' rules in places where they conflict 
(though in this case there's no conflict).




Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:338
 def err_file_too_large : Error<
-  "sorry, unsupported: file '%0' is too large for Clang to process">;
+  "unsupported: file '%0' is too large for Clang to process">;
 def err_include_too_large : Error<

I think we could drop the "unsupported: " here too. (We're allowed to have 
implementation limits; this isn't a conformance issue.)



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:341
+  "this include generates a translation unit too large for"
   " Clang to process.">, DefaultFatal;
 def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "

Please remove the trailing period while you're fixing the style of this 
diagnostic.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9669
   "by aggregate initialization using default member initializer "
   "is not supported; lifetime of %select{temporary|backing array}0 "
   "will end at the end of the full-expression">, InGroup;

While we're fixing style: in this file we have "is not yet supported", "is not 
supported yet", and "is not supported". We should pick one and use it 
consistently; "is not supported yet" would be my preference.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:11-12
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>; // FIXME expected-error
+using F1 = Float<2.0f / 2>; // FIXME expected-error
 

You should retain a `{{...}}` here with some text from the diagnostic for 
`-verify` to match against. Likewise below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[Lldb-commits] [PATCH] D146320: [lldb] Test direct ivar access in objc++ (NFC)

2023-03-17 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: aprantl.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add an Objective-C++ specific test for direct ivar access. This adds to the 
existing C++ and ObjC tests, and tests against regression for future 
refactoring.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146320

Files:
  lldb/test/API/commands/frame/var/direct-ivar/objcpp/Makefile
  
lldb/test/API/commands/frame/var/direct-ivar/objcpp/TestFrameVarDirectIvarObjCPlusPlus.py
  lldb/test/API/commands/frame/var/direct-ivar/objcpp/main.mm


Index: lldb/test/API/commands/frame/var/direct-ivar/objcpp/main.mm
===
--- /dev/null
+++ lldb/test/API/commands/frame/var/direct-ivar/objcpp/main.mm
@@ -0,0 +1,34 @@
+#include 
+
+struct Structure {
+  int m_field;
+  void fun() {
+// check this
+  }
+};
+
+@interface Classic : NSObject {
+@public
+  int _ivar;
+}
+@end
+
+@implementation Classic
+- (void)fun {
+  // check self
+}
+@end
+
+int main() {
+  Structure s;
+  s.m_field = 41;
+  s.fun();
+
+  Classic *c = [Classic new];
+  c->_ivar = 30;
+  [c fun];
+
+  Classic *self = c;
+  // check explicit self
+  (void)self;
+}
Index: 
lldb/test/API/commands/frame/var/direct-ivar/objcpp/TestFrameVarDirectIvarObjCPlusPlus.py
===
--- /dev/null
+++ 
lldb/test/API/commands/frame/var/direct-ivar/objcpp/TestFrameVarDirectIvarObjCPlusPlus.py
@@ -0,0 +1,24 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+@skipUnlessDarwin
+def test_objc_self(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// check self", 
lldb.SBFileSpec("main.mm"))
+self.expect("frame variable _ivar", startstr="(int) _ivar = 30")
+
+@skipUnlessDarwin
+def test_objc_explicit_self(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// check explicit self", 
lldb.SBFileSpec("main.mm"))
+self.expect("frame variable _ivar", startstr="(int) _ivar = 30")
+
+@skipUnlessDarwin
+def test_cpp_this(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// check this", 
lldb.SBFileSpec("main.mm"))
+self.expect("frame variable m_field", startstr="(int) m_field = 41")
Index: lldb/test/API/commands/frame/var/direct-ivar/objcpp/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/frame/var/direct-ivar/objcpp/Makefile
@@ -0,0 +1,4 @@
+OBJCXX_SOURCES := main.mm
+CFLAGS_EXTRAS := -fblocks -fobjc-arc
+LD_EXTRAS := -lobjc
+include Makefile.rules


Index: lldb/test/API/commands/frame/var/direct-ivar/objcpp/main.mm
===
--- /dev/null
+++ lldb/test/API/commands/frame/var/direct-ivar/objcpp/main.mm
@@ -0,0 +1,34 @@
+#include 
+
+struct Structure {
+  int m_field;
+  void fun() {
+// check this
+  }
+};
+
+@interface Classic : NSObject {
+@public
+  int _ivar;
+}
+@end
+
+@implementation Classic
+- (void)fun {
+  // check self
+}
+@end
+
+int main() {
+  Structure s;
+  s.m_field = 41;
+  s.fun();
+
+  Classic *c = [Classic new];
+  c->_ivar = 30;
+  [c fun];
+
+  Classic *self = c;
+  // check explicit self
+  (void)self;
+}
Index: lldb/test/API/commands/frame/var/direct-ivar/objcpp/TestFrameVarDirectIvarObjCPlusPlus.py
===
--- /dev/null
+++ lldb/test/API/commands/frame/var/direct-ivar/objcpp/TestFrameVarDirectIvarObjCPlusPlus.py
@@ -0,0 +1,24 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+@skipUnlessDarwin
+def test_objc_self(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// check self", lldb.SBFileSpec("main.mm"))
+self.expect("frame variable _ivar", startstr="(int) _ivar = 30")
+
+@skipUnlessDarwin
+def test_objc_explicit_self(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// check explicit self", lldb.SBFileSpec("main.mm"))
+self.expect("frame variable _ivar", startstr="(int) _ivar = 30")
+
+@skipUnlessDarwin
+def test_cpp_this(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// check this", lldb.SBFileSpec("main.mm"))
+self.expect("frame variable m_field", startstr="(int) m_field = 41")
Index: lldb/test/API/commands/frame/var/direct-ivar/objcpp/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/frame/var/direct-ivar/objcpp/Makefile
@@ -0,0 +1,4 @@
+OBJCXX_SOURCES 

[Lldb-commits] [lldb] 8c040d0 - [lldb] Fix d875838e8b45cb0da5070298d0c1a2d1ee78ce7e

2023-03-17 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-03-17T10:45:46-07:00
New Revision: 8c040d0f4941d3557affda3550428b8712b69c92

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

LOG: [lldb] Fix d875838e8b45cb0da5070298d0c1a2d1ee78ce7e

Added: 


Modified: 
lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp 
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
index 279d638782cfb..f27b186345224 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
@@ -6,7 +6,7 @@
 // RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj 
/out:%t.exe /pdb:%t.pdb
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o \
 // RUN:   "settings set interpreter.stop-command-source-on-error false" \
-// RUN:   -o "expression b" -o "expr d" -o "expr static_e_ref" -o "exit" 2>&1 
| FileCheck %s
+// RUN:   -o "expression b" -o "expression d" -o "expression static_e_ref" -o 
"exit" 2>&1 | FileCheck %s
 
 // CHECK: (lldb) expression b
 // CHECK: (B) $0 = {}



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


[Lldb-commits] [PATCH] D145180: [lldb] Introduce new SymbolFileJSON and ObjectFileJSON

2023-03-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.
Herald added a subscriber: jplehr.



Comment at: lldb/source/Plugins/SymbolFile/JSON/SymbolFileJSON.cpp:112
+symtab.AddSymbol(Symbol(
+/*symID*/ 0, Mangled(symbol.name), eSymbolTypeCode,
+/*is_global*/ true, /*is_debug*/ false,

labath wrote:
> clayborg wrote:
> > JDevlieghere wrote:
> > > mib wrote:
> > > > Should we increment the `symID` here ?
> > > The IDs are arbitrary, and if we start at zero, we'll have conflicts with 
> > > the ones already in the symbol table (e.g. the lldb_unnamed_symbols for 
> > > stripped binaries). We could check the size of the symtab and continue 
> > > counting from there. Or we can use 0 like we did here to indicate that 
> > > these values are "special". I went with the latter approach mostly 
> > > because that's what SymbolFileBreakpad does too. 
> > regardless of where the code goes that converts ObjectFileJSON::Symbol to 
> > lldb_private::Symbol, I would vote that we include enough information in 
> > ObjectFileJSON::Symbol so that we don't have to make up symbols IDs, or set 
> > all symbol IDs to zero. LLDB relies on having unique symbol IDs in each 
> > lldb_private::Symbol instance. 
> Speaking of breakpad, have you considered using SymbolFileBreakpad directly? 
> I think it serves pretty much the same purpose, and it also supports other, 
> more advanced functionality (e.g. line tables and unwind info). It sounds 
> like you don't need that now, but if you ever did, you wouldn't need to 
> reinvent that logic...
I feel pretty dumb now: looking at breakpad in more detail, the `PUBLIC` 
records pretty much have everything I was looking for. For some reason I was 
under the impression that it was a binary format and I really wanted something 
human readable. I think I got it confused with minidumps. 

I wasn't planning on adding anything fancy to the JSON format so I agree that 
if that need arises for something more advanced we should use breakpad. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145180

___
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-17 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd875838e8b45: [lldb][test] Replace use of p with expression 
in Shell tests (NFC) (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

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/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script
===
--- lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script
@@ -1 +1 @@

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

2023-03-17 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-03-17T10:29:24-07:00
New Revision: d875838e8b45cb0da5070298d0c1a2d1ee78ce7e

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

LOG: [lldb][test] Replace use of p with expression in Shell tests (NFC)

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.

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

Added: 


Modified: 
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

Removed: 




diff  --git a/lldb/test/Shell/Commands/command-source.test 
b/lldb/test/Shell/Commands/command-source.test
index fa389f2a12889..579e3989f6fd0 100644
--- a/lldb/test/Shell/Commands/command-source.test
+++ b/lldb/test/Shell/Commands/command-source.test
@@ -6,7 +6,7 @@
 # RUN: %lldb -x -b -o 'settings set interpreter.stop-command-source-on-error 
false' -o "command source %s" 2>&1 | FileCheck %s --check-prefix CONTINUE
 
 bogus
-p 10+1
+expression 10+1
 
 # CONTINUE: $0 = 11
 # STOP-NOT: $0 = 11

diff  --git a/lldb/test/Shell/Commands/command-stop-hook-no-target.test 
b/lldb/test/Shell/Commands/command-stop-hook-no-target.test
index ee9ded164d745..cc5e71dff00cd 100644
--- a/lldb/test/Shell/Commands/command-stop-hook-no-target.test
+++ b/lldb/test/Shell/Commands/command-stop-hook-no-target.test
@@ -1,4 +1,4 @@
 # RUN: %clang_host -g %S/Inputs/main.c -o %t
-# RUN: %lldb -b -o 'target stop-hook add --name test --shlib test -o "p 95000 
+ 126"' -o 'file %t' -o 'b main' -o 'r' 2>&1 | FileCheck %s
+# RUN: %lldb -b -o 'target stop-hook add --name test --shlib test -o 
"expression 95000 + 126"' -o 'file %t' -o 'b main' -o 'r' 2>&1 | FileCheck %s
 # CHECK: Stop hook #1 added
 # CHECK-NOT: 95126

diff  --git a/lldb/test/Shell/Expr/nodefaultlib.cpp 
b/lldb/test/Shell/Expr/nodefaultlib.cpp
index fb53da7fcb08b..f97d8aad9a8db 100644
--- a/lldb/test/Shell/Expr/nodefaultlib.cpp
+++ b/lldb/test/Shell/Expr/nodefaultlib.cpp
@@ -7,10 +7,10 @@
 // XFAIL: system-netbsd || system-freebsd || system-darwin
 
 // RUN: %build %s --nodefaultlib -o %t
-// RUN: %lldb %t -o "b main" -o run -o "p call_me(5, 6)" -o exit \
+// RUN: %lldb %t -o "b main" -o run -o "expression call_me(5, 6)" -o exit \
 // RUN:   | FileCheck %s
 
-// CHECK: p call_me(5, 6)
+// CHECK: expression call_me(5, 6)
 // CHECK: (int) $0 = 30
 
 int call_me(int x, long y) { return x * y; }

diff  --git a/lldb/test/Shell/Register/x86-64-fp-read.test 
b/lldb/test/Shell/Register/x86-64-fp-read.test
index 39fdaf170f3f2..e23e333c204a5 100644
--- a/lldb/test/Shell/Register/x86-64-fp-read.test
+++ b/lldb/test/Shell/Register/x86-64-fp-read.test
@@ -9,9 +9,9 @@ process launch
 # CHECK: Process {{.*}} stopped
 
 # fdiv (%rbx) gets encoded into 2 bytes, int3 into 1 byte
-print (void*)($pc-3)
+expression (void*)($pc-3)
 # CHECK: (void *) $0 = [[FDIV:0x[0-9a-f]*]]
-print 
+expression 
 # CHECK: (uint32_t *) $1 = [[ZERO:0x[0-9a-f]*]]
 
 register read --all
@@ -32,9 +32,9 @@ register read --all
 # CHECK-DAG: st{{(mm)?}}7 = {0x00 0x00 0x00 0x00 0x00 

[Lldb-commits] [lldb] 147b609 - [lldb] Unify WatchpointSP variable names (NFC)

2023-03-17 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-03-17T10:09:40-07:00
New Revision: 147b60964064b17163f1788dcd24c366ba3d54b1

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

LOG: [lldb] Unify WatchpointSP variable names (NFC)

LLDB uses `_up`, `_sp` and `_wp` suffixes for unique, shared and weak
pointers respectively. This can become confusing in combination with
watchpoints which are commonly abbreviated to `wp`. Update
CommandObjectWatchpoint to use `watch_sp` for all `WatchpointSP`
variables.

Added: 


Modified: 
lldb/source/Commands/CommandObjectWatchpoint.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp 
b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 9463050f40b36..8b8c196e4505b 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -29,12 +29,12 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static void AddWatchpointDescription(Stream *s, Watchpoint *wp,
+static void AddWatchpointDescription(Stream , Watchpoint ,
  lldb::DescriptionLevel level) {
-  s->IndentMore();
-  wp->GetDescription(s, level);
-  s->IndentLess();
-  s->EOL();
+  s.IndentMore();
+  wp.GetDescription(, level);
+  s.IndentLess();
+  s.EOL();
 }
 
 static bool CheckTargetForWatchpointOperations(Target *target,
@@ -237,8 +237,8 @@ class CommandObjectWatchpointList : public 
CommandObjectParsed {
   // No watchpoint selected; show info about all currently set watchpoints.
   result.AppendMessage("Current watchpoints:");
   for (size_t i = 0; i < num_watchpoints; ++i) {
-Watchpoint *wp = watchpoints.GetByIndex(i).get();
-AddWatchpointDescription(_stream, wp, m_options.m_level);
+WatchpointSP watch_sp = watchpoints.GetByIndex(i);
+AddWatchpointDescription(output_stream, *watch_sp, m_options.m_level);
   }
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
 } else {
@@ -252,9 +252,9 @@ class CommandObjectWatchpointList : public 
CommandObjectParsed {
 
   const size_t size = wp_ids.size();
   for (size_t i = 0; i < size; ++i) {
-Watchpoint *wp = watchpoints.FindByID(wp_ids[i]).get();
-if (wp)
-  AddWatchpointDescription(_stream, wp, m_options.m_level);
+WatchpointSP watch_sp = watchpoints.FindByID(wp_ids[i]);
+if (watch_sp)
+  AddWatchpointDescription(output_stream, *watch_sp, 
m_options.m_level);
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
   }
 }
@@ -758,8 +758,8 @@ class CommandObjectWatchpointModify : public 
CommandObjectParsed {
 }
 
 if (command.GetArgumentCount() == 0) {
-  WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
-  wp_sp->SetCondition(m_options.m_condition.c_str());
+  WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
+  watch_sp->SetCondition(m_options.m_condition.c_str());
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
 } else {
   // Particular watchpoints selected; set condition on them.
@@ -773,9 +773,9 @@ class CommandObjectWatchpointModify : public 
CommandObjectParsed {
   int count = 0;
   const size_t size = wp_ids.size();
   for (size_t i = 0; i < size; ++i) {
-WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
-if (wp_sp) {
-  wp_sp->SetCondition(m_options.m_condition.c_str());
+WatchpointSP watch_sp = watchpoints.FindByID(wp_ids[i]);
+if (watch_sp) {
+  watch_sp->SetCondition(m_options.m_condition.c_str());
   ++count;
 }
   }
@@ -949,19 +949,19 @@ corresponding to the byte size of the data type.");
 uint32_t watch_type = m_option_watchpoint.watch_type;
 
 error.Clear();
-WatchpointSP wp =
+WatchpointSP watch_sp =
 target->CreateWatchpoint(addr, size, _type, watch_type, 
error);
-if (wp) {
-  wp->SetWatchSpec(command.GetArgumentAtIndex(0));
-  wp->SetWatchVariable(true);
+if (watch_sp) {
+  watch_sp->SetWatchSpec(command.GetArgumentAtIndex(0));
+  watch_sp->SetWatchVariable(true);
   if (var_sp && var_sp->GetDeclaration().GetFile()) {
 StreamString ss;
 // True to show fullpath for declaration file.
 var_sp->GetDeclaration().DumpStopContext(, true);
-wp->SetDeclInfo(std::string(ss.GetString()));
+watch_sp->SetDeclInfo(std::string(ss.GetString()));
   }
   output_stream.Printf("Watchpoint created: ");
-  wp->GetDescription(_stream, lldb::eDescriptionLevelFull);
+  watch_sp->GetDescription(_stream, lldb::eDescriptionLevelFull);
   output_stream.EOL();
   result.SetStatus(eReturnStatusSuccessFinishResult);
 } else {
@@ -1116,13 

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

2023-03-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a7642977876: [lldb] Set the watchpoint spec for expression 
watchpoints (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

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, _type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, _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, _type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, _type, watch_type, 
error);
 if (wp) {
+  wp->SetWatchSpec(std::string(expr));
   Stream _stream = result.GetOutputStream();
   output_stream.Printf("Watchpoint created: ");
   wp->GetDescription(_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, _type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, _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, _type, watch_type, error)
-

[Lldb-commits] [lldb] 2a76429 - [lldb] Set the watchpoint spec for expression watchpoints

2023-03-17 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-03-17T09:55:57-07:00
New Revision: 2a76429778768ed29404f0396194636e2bc11b90

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

LOG: [lldb] Set the watchpoint spec for expression watchpoints

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.

rdar://106096860

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectWatchpoint.cpp

lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp 
b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 7aa9614634181..9463050f40b36 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -949,9 +949,8 @@ corresponding to the byte size of the data type.");
 uint32_t watch_type = m_option_watchpoint.watch_type;
 
 error.Clear();
-Watchpoint *wp =
-target->CreateWatchpoint(addr, size, _type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, _type, watch_type, 
error);
 if (wp) {
   wp->SetWatchSpec(command.GetArgumentAtIndex(0));
   wp->SetWatchVariable(true);
@@ -1117,10 +1116,10 @@ class CommandObjectWatchpointSetExpression : public 
CommandObjectRaw {
 CompilerType compiler_type(valobj_sp->GetCompilerType());
 
 Status error;
-Watchpoint *wp =
-target->CreateWatchpoint(addr, size, _type, watch_type, error)
-.get();
+WatchpointSP wp =
+target->CreateWatchpoint(addr, size, _type, watch_type, 
error);
 if (wp) {
+  wp->SetWatchSpec(std::string(expr));
   Stream _stream = result.GetOutputStream();
   output_stream.Printf("Watchpoint created: ");
   wp->GetDescription(_stream, lldb::eDescriptionLevelFull);

diff  --git 
a/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
 
b/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
index aceb8f2bc4385..97e43c35127de 100644
--- 
a/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ 
b/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -46,7 +46,7 @@ def test_watchlocation_using_watchpoint_set(self):
 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 @@ def test_watchlocation_using_watchpoint_set(self):
 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



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


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Frank Ch. Eigler via Phabricator via lldb-commits
fche2 added a comment.

Closing this might have been premature.  I can't find an lldb debuginfod client 
side support.  Is that somehow behind llvm-symbolicator or something like that? 
 Is there documentation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

___
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-17 Thread Stefan Gränitz via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef006eb0bc5e: [CodeView] Add source languages ObjC and 
ObjC++ (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

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,35 @@
+; 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
+
+; OBJ:   Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT:  Language: ObjCpp (0x12)
+
+; 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,35 @@
+; 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
+
+; OBJ:   Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT:  Language: ObjC (0x11)
+
+; ModuleID = 'objc.m'
+source_filename = "objc.m"
+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() unnamed_addr #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, 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: "objc.m", directory: "src", checksumkind: CSK_MD5, checksum: "e6ab1d5b7f82464c963a8522037dfa72")
+!5 = distinct !DISubprogram(name: "f", scope: !4, file: !4, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !8)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = !{}
+!9 = !DILocation(line: 1, scope: !5)
Index: llvm/test/DebugInfo/COFF/language.ll

[Lldb-commits] [lldb] ef006eb - [CodeView] Add source languages ObjC and ObjC++

2023-03-17 Thread Stefan Gränitz via lldb-commits

Author: Stefan Gränitz
Date: 2023-03-17T17:09:31+01:00
New Revision: ef006eb0bc5e8d069deee7e7d93d7cf5d55fd791

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

LOG: [CodeView] Add source languages ObjC and ObjC++

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.

Reviewed By: DavidSpickett

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

Added: 
llvm/test/DebugInfo/COFF/objc.ll
llvm/test/DebugInfo/COFF/objcpp.ll

Modified: 
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/tools/llvm-pdbutil/MinimalSymbolDumper.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 075d4b042d2aa..df558c842f9c1 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -76,6 +76,10 @@ static lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
 return lldb::LanguageType::eLanguageTypeSwift;
   case PDB_Lang::Rust:
 return lldb::LanguageType::eLanguageTypeRust;
+  case PDB_Lang::ObjC:
+return lldb::LanguageType::eLanguageTypeObjC;
+  case PDB_Lang::ObjCpp:
+return lldb::LanguageType::eLanguageTypeObjC_plus_plus;
   default:
 return lldb::LanguageType::eLanguageTypeUnknown;
   }

diff  --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index cb75dd59d3668..613e362071270 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -80,6 +80,10 @@ lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
 return lldb::LanguageType::eLanguageTypeSwift;
   case PDB_Lang::Rust:
 return lldb::LanguageType::eLanguageTypeRust;
+  case PDB_Lang::ObjC:
+return lldb::LanguageType::eLanguageTypeObjC;
+  case PDB_Lang::ObjCpp:
+return lldb::LanguageType::eLanguageTypeObjC_plus_plus;
   default:
 return lldb::LanguageType::eLanguageTypeUnknown;
   }

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h 
b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
index 010a82dd0e232..a9ad99a1d0a84 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
@@ -138,8 +138,8 @@ enum class CPUType : uint16_t {
   D3D11_Shader = 0x100,
 };
 
-/// These values correspond to the CV_CFL_LANG enumeration, and are documented
-/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
+/// These values correspond to the CV_CFL_LANG enumeration in the Microsoft
+/// Debug Interface Access SDK
 enum SourceLanguage : uint8_t {
   C = 0x00,
   Cpp = 0x01,
@@ -158,6 +158,8 @@ enum SourceLanguage : uint8_t {
   JScript = 0x0e,
   MSIL = 0x0f,
   HLSL = 0x10,
+  ObjC = 0x11,
+  ObjCpp = 0x12,
 
   Rust = 0x15,
 

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index fd4ea6e08703e..86cdd11ebd17e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -569,7 +569,6 @@ static SourceLanguage MapDWLangToCVLang(unsigned DWLang) {
   case dwarf::DW_LANG_C89:
   case dwarf::DW_LANG_C99:
   case dwarf::DW_LANG_C11:
-  case dwarf::DW_LANG_ObjC:
 return SourceLanguage::C;
   case dwarf::DW_LANG_C_plus_plus:
   case dwarf::DW_LANG_C_plus_plus_03:
@@ -595,6 +594,10 @@ static SourceLanguage MapDWLangToCVLang(unsigned DWLang) {
 return SourceLanguage::Swift;
   case dwarf::DW_LANG_Rust:
 return SourceLanguage::Rust;
+  case dwarf::DW_LANG_ObjC:
+return SourceLanguage::ObjC;
+  case dwarf::DW_LANG_ObjC_plus_plus:
+return SourceLanguage::ObjCpp;
   default:
 // There's no CodeView representation for this language, and CV doesn't
 // have an "unknown" option for the language field, so we'll use MASM,

diff  --git a/llvm/lib/DebugInfo/CodeView/EnumTables.cpp 

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

2023-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: llvm/test/DebugInfo/COFF/objc.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

sgraenitz wrote:
> DavidSpickett wrote:
> > DavidSpickett wrote:
> > > sgraenitz wrote:
> > > > DavidSpickett wrote:
> > > > > Are these checked, should they be?
> > > > Thanks for taking a look! What we check here is the `17` in language 
> > > > flags. The rest is just to make sure we get the right context. (Same 
> > > > for the others.) Is that your question?
> > > Right but I don't know what that adds once you get beyond the Language 
> > > line. It's a small thing, so that the test doesn't fail if a new key is 
> > > added.
> > Ignore the previous comment, wrong line.
> > 
> > So yes you can check these, but no one actually does. If you look at the 
> > filecheck line it only does OBJ.
> > 
> > Same for the rust change you linked. Unless there is some implicit 
> > behaviour here. One way to find out, put a bogus value in there and it 
> > should fail.
> The first RUN line will exercise the ASM checks:
> ```
> ; RUN: llc < %s | FileCheck %s --check-prefix=ASM
> ```
Doh, sometimes I forget how to read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146221

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


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk abandoned this revision.
kwk added a comment.

There already is a Debuginfod implementation in LLVM by now. Abandoning 
revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

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


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Looks like it  is already there: 
https://github.com/llvm/llvm-project/tree/main/llvm/include/llvm/Debuginfod


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

___
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-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added inline comments.



Comment at: llvm/test/DebugInfo/COFF/objc.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

DavidSpickett wrote:
> DavidSpickett wrote:
> > sgraenitz wrote:
> > > DavidSpickett wrote:
> > > > Are these checked, should they be?
> > > Thanks for taking a look! What we check here is the `17` in language 
> > > flags. The rest is just to make sure we get the right context. (Same for 
> > > the others.) Is that your question?
> > Right but I don't know what that adds once you get beyond the Language 
> > line. It's a small thing, so that the test doesn't fail if a new key is 
> > added.
> Ignore the previous comment, wrong line.
> 
> So yes you can check these, but no one actually does. If you look at the 
> filecheck line it only does OBJ.
> 
> Same for the rust change you linked. Unless there is some implicit behaviour 
> here. One way to find out, put a bogus value in there and it should fail.
The first RUN line will exercise the ASM checks:
```
; RUN: llc < %s | FileCheck %s --check-prefix=ASM
```



Comment at: llvm/test/DebugInfo/COFF/objc.ll:11-17
+; 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:  }

DavidSpickett wrote:
> DavidSpickett wrote:
> > Do we need to check for these lines? Just the first few should be fine.
> So here it's fine to check up to language, mostly, but after that what does 
> it matter? If someone adds a new key the test breaks.
> 
> (and granted, it won't happen often if at all but the general principle holds)
Ok, fair enough. Cut it down.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146221

___
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-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 506100.
sgraenitz marked 7 inline comments as done.
sgraenitz added a comment.

Cut down check-lines


Repository:
  rG LLVM Github Monorepo

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

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,35 @@
+; 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
+
+; OBJ:   Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT:  Language: ObjCpp (0x12)
+
+; 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,35 @@
+; 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
+
+; OBJ:   Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT:  Language: ObjC (0x11)
+
+; ModuleID = 'objc.m'
+source_filename = "objc.m"
+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() unnamed_addr #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, 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: "objc.m", directory: "src", checksumkind: CSK_MD5, checksum: "e6ab1d5b7f82464c963a8522037dfa72")
+!5 = distinct !DISubprogram(name: "f", scope: !4, file: !4, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !8)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = !{}
+!9 = !DILocation(line: 1, scope: !5)
Index: llvm/test/DebugInfo/COFF/language.ll
===
--- 

[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a subscriber: phosek.
kwk added a comment.

@iridinite please see these:

- https://discourse.llvm.org/t/http-library-in-llvm/56317/10
- https://discourse.llvm.org/t/rfc-building-llvm-debuginfod/59011
- https://discourse.llvm.org/t/rfc-building-llvm-debuginfod/58994
- https://discourse.llvm.org/t/debuginfod-credential-helper-rfc/64092

I suggest, you contact @phosek on the status of debuginfod implementation in 
LLVM. I'd love to know where it is at, so please leave a trace ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

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


[Lldb-commits] [PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-17 Thread Aaron Ballman via Phabricator via lldb-commits
aaron.ballman added a comment.

In D146041#4198056 , @AryanGodara 
wrote:

> I will try to split this commit, and update on this asap (Sorry for the late 
> update, I have mid-sem exams going on, I haven't abandoned this issue, still 
> working on it).

No worries about the speed of updates, it's totally fine for weeks to pass 
between updates to a patch. We're usually pretty good at asking "is this 
abandoned" rather than assuming. FWIW, it looks like there's also precommit CI 
failures related to the changes that should be looked into.




Comment at: clang/unittests/Format/FormatTest.cpp:11426
   verifyFormat("[[gsl::suppress(\"clang-tidy-check-name\")]] void f() {}");
-  verifyFormat("void f() [[deprecated(\"so sorry\")]];");
   verifyFormat("aa\n"

These changes don't really do much -- it's a test case, so the wording is not 
important, but what is important is retaining the string argument that is being 
dropped. I'd roll back the changes to this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[Lldb-commits] [PATCH] D146297: [lldb][gnustep][PDB] Parse ObjC base classes and recognize NSObject type

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

In D146297#4202172 , @DavidSpickett 
wrote:

> I don't know anything about Objective C internals, perhaps you can provide 
> some reference that talks about this?

Honestly, I am mostly looking what the DWARF parser does and try to mimic it in 
PDB. I haven't done much research for a formal reference. My impression is that 
the implementation is the reference here. (Please correct me if I am wrong!)

Yeah, let's wait and see if I get feedback from ObjC and PDB maintainers.




Comment at: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp:349
+static bool IsSpecialNameObjC(llvm::StringRef name) {
+  return name == "objc_object" || name == "objc_class";
+}

Maybe this is ok without a dedicated language type check? IIUC the worst thing 
that could happen, in case we really have zero-length types with such names in 
C++ code, is a small performance drop.

BTW the reference for this seems to be: 
https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L709-L710
 



Comment at: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m:44
 
-// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:67" -o "run" -o "p ptr" -o "p 
*ptr" -- %t | FileCheck %s
+// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:72" -o "run" -o "p ptr" -o "p 
*ptr" -- %t | FileCheck %s
 //

DavidSpickett wrote:
> Could you use label in the source so you don't have to update this line 
> number each each time?
> 
> I forget if labels are included in the debug info. In the python tests we 
> have this more heavyweight thing that searches for a particular comment to 
> find the line.
It's a minor effort on my side to update the line number and it's solid. We 
cannot break on `ok`, since the function name doesn't get parsed with a correct 
basename yet. Main would work, but it doesn't seem more readable:
```
-o "b main" -o "n" -o "n"
```

> In the python tests we have this more heavyweight thing that searches for a 
> particular comment to find the line.

If possible I'd like to stay away from the Python tests. I don't think we need 
their advanced features. lit is a lot easier for me (and more widespread in 
LLVM).



Comment at: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m:68
+// CHECK:   _id_objc = nil
 // CHECK: }
 

With this change we get base class and the member offsets right (all are 
zero-initialized).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146297

___
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-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: llvm/test/DebugInfo/COFF/objc.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

DavidSpickett wrote:
> sgraenitz wrote:
> > DavidSpickett wrote:
> > > Are these checked, should they be?
> > Thanks for taking a look! What we check here is the `17` in language flags. 
> > The rest is just to make sure we get the right context. (Same for the 
> > others.) Is that your question?
> Right but I don't know what that adds once you get beyond the Language line. 
> It's a small thing, so that the test doesn't fail if a new key is added.
Ignore the previous comment, wrong line.

So yes you can check these, but no one actually does. If you look at the 
filecheck line it only does OBJ.

Same for the rust change you linked. Unless there is some implicit behaviour 
here. One way to find out, put a bogus value in there and it should fail.



Comment at: llvm/test/DebugInfo/COFF/objc.ll:11-17
+; 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:  }

DavidSpickett wrote:
> Do we need to check for these lines? Just the first few should be fine.
So here it's fine to check up to language, mostly, but after that what does it 
matter? If someone adds a new key the test breaks.

(and granted, it won't happen often if at all but the general principle holds)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146221

___
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-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: llvm/include/llvm/DebugInfo/CodeView/CodeView.h:142
+/// These values correspond to the CV_CFL_LANG enumeration in the Microsoft
+/// Debug Interface Access SDK
 enum SourceLanguage : uint8_t {

sgraenitz wrote:
> DavidSpickett wrote:
> > Could put the same link from the commit message, here. 
> I though about it, but such links will inevitably break again one day and/or 
> lead to outdated information. The old link was very unfortunate. Web search 
> for `CV_CFL_LANG Microsoft Debug Interface Access SDK` seems more stable. 
> What do you think?
Yeah sure, one can google the term instead. Agreed.

It is better than "download this random header file that probably has a strange 
license" :)



Comment at: llvm/test/DebugInfo/COFF/objc.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

sgraenitz wrote:
> DavidSpickett wrote:
> > Are these checked, should they be?
> Thanks for taking a look! What we check here is the `17` in language flags. 
> The rest is just to make sure we get the right context. (Same for the 
> others.) Is that your question?
Right but I don't know what that adds once you get beyond the Language line. 
It's a small thing, so that the test doesn't fail if a new key is added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146221

___
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-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Maybe I should have noted immediately, that this is mostly following the change 
for Rust from https://reviews.llvm.org/D115300




Comment at: llvm/include/llvm/DebugInfo/CodeView/CodeView.h:142
+/// These values correspond to the CV_CFL_LANG enumeration in the Microsoft
+/// Debug Interface Access SDK
 enum SourceLanguage : uint8_t {

DavidSpickett wrote:
> Could put the same link from the commit message, here. 
I though about it, but such links will inevitably break again one day and/or 
lead to outdated information. The old link was very unfortunate. Web search for 
`CV_CFL_LANG Microsoft Debug Interface Access SDK` seems more stable. What do 
you think?



Comment at: llvm/test/DebugInfo/COFF/objc.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

DavidSpickett wrote:
> Are these checked, should they be?
Thanks for taking a look! What we check here is the `17` in language flags. The 
rest is just to make sure we get the right context. (Same for the others.) Is 
that your question?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146221

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


[Lldb-commits] [PATCH] D146297: [lldb][gnustep][PDB] Parse ObjC base classes and recognize NSObject type

2023-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

I don't know anything about Objective C internals, perhaps you can provide some 
reference that talks about this?




Comment at: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m:44
 
-// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:67" -o "run" -o "p ptr" -o "p 
*ptr" -- %t | FileCheck %s
+// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:72" -o "run" -o "p ptr" -o "p 
*ptr" -- %t | FileCheck %s
 //

Could you use label in the source so you don't have to update this line number 
each each time?

I forget if labels are included in the debug info. In the python tests we have 
this more heavyweight thing that searches for a particular comment to find the 
line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146297

___
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-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: llvm/include/llvm/DebugInfo/CodeView/CodeView.h:142
+/// These values correspond to the CV_CFL_LANG enumeration in the Microsoft
+/// Debug Interface Access SDK
 enum SourceLanguage : uint8_t {

Could put the same link from the commit message, here. 



Comment at: llvm/test/DebugInfo/COFF/objc.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   17  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

Are these checked, should they be?



Comment at: llvm/test/DebugInfo/COFF/objc.ll:11-17
+; 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:  }

Do we need to check for these lines? Just the first few should be fine.



Comment at: llvm/test/DebugInfo/COFF/objcpp.ll:4-6
+; ASM:  .short  4412# Record kind: S_COMPILE3
+; ASM-NEXT: .long   18  # Flags and language
+; ASM-NEXT: .short  208 # CPUType

Are these checked, should they be?



Comment at: llvm/test/DebugInfo/COFF/objcpp.ll:11-17
+; 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:  }

Same here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146221

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


[Lldb-commits] [lldb] 49f9af1 - [LLDB] Remove some typed pointer code (NFCI)

2023-03-17 Thread Nikita Popov via lldb-commits

Author: Nikita Popov
Date: 2023-03-17T15:25:58+01:00
New Revision: 49f9af1864d918a0561e455d2ec403f32135c108

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

LOG: [LLDB] Remove some typed pointer code (NFCI)

Various bitcast handling should no longer be necessary with
opaque pointers.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index 0a4af196857ca..0549868274685 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -334,20 +334,8 @@ class ValidPointerChecker : public Instrumenter {
 else
   return false;
 
-// Insert an instruction to cast the loaded value to int8_t*
-
-BitCastInst *bit_cast =
-new BitCastInst(dereferenced_ptr, GetI8PtrTy(), "", inst);
-
 // Insert an instruction to call the helper with the result
-
-llvm::Value *arg_array[1];
-
-arg_array[0] = bit_cast;
-
-llvm::ArrayRef args(arg_array, 1);
-
-CallInst::Create(m_valid_pointer_check_func, args, "", inst);
+CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "", inst);
 
 return true;
   }
@@ -425,16 +413,11 @@ class ObjcObjectChecker : public Instrumenter {
 assert(target_object);
 assert(selector);
 
-// Insert an instruction to cast the receiver id to int8_t*
-
-BitCastInst *bit_cast =
-new BitCastInst(target_object, GetI8PtrTy(), "", inst);
-
 // Insert an instruction to call the helper with the result
 
 llvm::Value *arg_array[2];
 
-arg_array[0] = bit_cast;
+arg_array[0] = target_object;
 arg_array[1] = selector;
 
 ArrayRef args(arg_array, 2);

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index ec0243d92099b..6fe46295770f8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -476,8 +476,7 @@ bool 
IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
 string_array = dyn_cast(cstr->getInitializer());
 
   Constant *alloc_arg = Constant::getNullValue(i8_ptr_ty);
-  Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)
- : Constant::getNullValue(i8_ptr_ty);
+  Constant *bytes_arg = cstr ? cstr : Constant::getNullValue(i8_ptr_ty);
   Constant *numBytes_arg = ConstantInt::get(
   m_intptr_ty, cstr ? (string_array->getNumElements() - 1) * 
string_array->getElementByteSize() : 0, false);
  int encoding_flags = 0;
@@ -821,17 +820,9 @@ bool IRForTarget::RewriteObjCSelector(Instruction 
*selector_load) {
   ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty)};
   }
 
-  Value *argument_array[1];
-
-  Constant *omvn_pointer = ConstantExpr::getBitCast(
-  _objc_meth_var_name_, Type::getInt8PtrTy(m_module->getContext()));
-
-  argument_array[0] = omvn_pointer;
-
-  ArrayRef srN_arguments(argument_array, 1);
-
-  CallInst *srN_call = CallInst::Create(m_sel_registerName, srN_arguments,
-"sel_registerName", selector_load);
+  CallInst *srN_call =
+  CallInst::Create(m_sel_registerName, _objc_meth_var_name_,
+   "sel_registerName", selector_load);
 
   // Replace the load with the call in all users
 
@@ -887,14 +878,12 @@ bool IRForTarget::RewriteObjCClassReference(Instruction 
*class_load) {
   // Unpack the class name from the reference.  In LLVM IR, a reference to an
   // Objective-C class gets represented as
   //
-  // %tmp = load %struct._objc_class*,
-  //%struct._objc_class** @OBJC_CLASS_REFERENCES_, align 4
+  // %tmp = load ptr, ptr @OBJC_CLASS_REFERENCES_, align 4
   //
-  // @"OBJC_CLASS_REFERENCES_ is a bitcast of a character array called
+  // @OBJC_CLASS_REFERENCES_ is a reference to a character array called
   // @OBJC_CLASS_NAME_. @OBJC_CLASS_NAME contains the string.
 
-  // Find the pointer's initializer (a ConstantExpr with opcode BitCast) and
-  // get the string from its target
+  // Find the pointer's initializer and get the string from its target
 
   GlobalVariable *_objc_class_references_ =
   dyn_cast(load->getPointerOperand());
@@ -903,23 +892,10 @@ bool IRForTarget::RewriteObjCClassReference(Instruction 
*class_load) {
   !_objc_class_references_->hasInitializer())
 return false;
 
-  Constant *ocr_initializer = _objc_class_references_->getInitializer();
-
-  ConstantExpr 

[Lldb-commits] [PATCH] D146297: [lldb][gnustep][PDB] Parse ObjC base classes and recognize NSObject type

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
sgraenitz added reviewers: aleksandr.urakov, rnk, teemperor, DavidSpickett, 
aprantl, zturner.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1.
Herald added a project: LLDB.

While C++ base classes are registered with CreateBaseClassSpecifier(), we have 
to use SetObjCSuperClass() for ObjC. The isa member of NSObject is a 
zero-length UDT. Special handling for ObjC id type will be added in one of the 
next patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146297

Files:
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/test/Shell/Expr/objc-gnustep-print-pdb.m


Index: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
===
--- lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
+++ lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
@@ -41,26 +41,30 @@
 }
 @end
 
-// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:67" -o "run" -o "p ptr" -o "p 
*ptr" -- %t | FileCheck %s
+// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:72" -o "run" -o "p ptr" -o "p 
*ptr" -- %t | FileCheck %s
 //
-// CHECK: (lldb) b objc-gnustep-print-pdb.m:67
-// CHECK: Breakpoint {{.*}} at objc-gnustep-print-pdb.m:67
+// CHECK: (lldb) b objc-gnustep-print-pdb.m:72
+// CHECK: Breakpoint {{.*}} at objc-gnustep-print-pdb.m:72
 //
 // CHECK: (lldb) run
 // CHECK: Process {{[0-9]+}} stopped
-// CHECK: frame #0: {{.*}}`main  at objc-gnustep-print-pdb.m:67
+// CHECK: frame #0: {{.*}}`main  at objc-gnustep-print-pdb.m:72
 //
 // CHECK: (lldb) p ptr
 // CHECK: (TestObj *) $0 = 0x{{[0-9]+}}
 //
 // CHECK: (lldb) p *ptr
 // CHECK: (TestObj) $1 = {
-// CHECK:   _int
-// CHECK:   _float
-// CHECK:   _char
-// CHECK:   _ptr_void
-// CHECK:   _ptr_nsobject
-// CHECK:   _id_objc
+// CHECK:   NSObject = {
+// CHECK: isa = 0x{{[0-9]+}}
+// CHECK: refcount
+// CHECK:   }
+// CHECK:   _int = 0
+// CHECK:   _float = 0
+// CHECK:   _char = '\0'
+// CHECK:   _ptr_void = 0x{{0+}}
+// CHECK:   _ptr_nsobject = nil
+// CHECK:   _id_objc = nil
 // CHECK: }
 
 int main() {
Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -345,6 +345,10 @@
   return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
 }
 
+static bool IsSpecialNameObjC(llvm::StringRef name) {
+  return name == "objc_object" || name == "objc_class";
+}
+
 static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc) {
   switch (pdb_cc) {
   case llvm::codeview::CallingConvention::NearC:
@@ -393,16 +397,16 @@
 //union Union { short Row; short Col; }
 // Such symbols will be handled here.
 
-// Some UDT with trival ctor has zero length. Just ignore.
-if (udt->getLength() == 0)
-  return nullptr;
-
 // Ignore unnamed-tag UDTs.
 std::string name =
 std::string(MSVCUndecoratedNameParser::DropScope(udt->getName()));
 if (name.empty())
   return nullptr;
 
+// Some UDT with trival ctor has zero length. Just ignore.
+if (udt->getLength() == 0 && !IsSpecialNameObjC(name))
+  return nullptr;
+
 auto decl_context = GetDeclContextContainingSymbol(type);
 
 // PDB has no attribute to encode the language per symbol. We assume
@@ -1406,6 +1410,12 @@
 TypeSystemClang::CompleteTagDeclarationDefinition(base_comp_type);
 }
 
+if (TypeSystemClang::IsObjCObjectOrInterfaceType(base_comp_type)) {
+  m_ast.SetObjCSuperClass(record_type, base_comp_type);
+  assert(bases_enum.getNext() == nullptr && "Single inheritance only");
+  return;
+}
+
 auto access = TranslateMemberAccess(base->getAccess());
 
 auto is_virtual = base->isVirtualBaseClass();


Index: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
===
--- lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
+++ lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
@@ -41,26 +41,30 @@
 }
 @end
 
-// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:67" -o "run" -o "p ptr" -o "p *ptr" -- %t | FileCheck %s
+// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:72" -o "run" -o "p ptr" -o "p *ptr" -- %t | FileCheck %s
 //
-// CHECK: (lldb) b objc-gnustep-print-pdb.m:67
-// CHECK: Breakpoint {{.*}} at objc-gnustep-print-pdb.m:67
+// CHECK: (lldb) b objc-gnustep-print-pdb.m:72
+// CHECK: Breakpoint {{.*}} at objc-gnustep-print-pdb.m:72
 //
 // CHECK: (lldb) run
 // CHECK: Process {{[0-9]+}} stopped
-// CHECK: frame #0: {{.*}}`main  at objc-gnustep-print-pdb.m:67
+// CHECK: frame #0: {{.*}}`main  at objc-gnustep-print-pdb.m:72
 //
 // CHECK: (lldb) p ptr
 // CHECK: (TestObj *) $0 = 0x{{[0-9]+}}
 //
 // CHECK: (lldb) p *ptr
 // CHECK: (TestObj) $1 = {
-// CHECK:   _int
-// CHECK:   _float
-// 

[Lldb-commits] [PATCH] D146286: [lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9987f0ac81a: [lldb][PDB] Rename GetDeclarationForSymbol() 
- AddSourceInfoToDecl() (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146286

Files:
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp


Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -190,8 +190,7 @@
   return compiler_type.GetTypeName();
 }
 
-static bool GetDeclarationForSymbol(const PDBSymbol ,
-Declaration ) {
+static bool AddSourceInfoToDecl(const PDBSymbol , Declaration ) {
   auto _sym = symbol.getRawSymbol();
   auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
 
@@ -464,7 +463,7 @@
 if (udt->isVolatileType())
   clang_type = clang_type.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), udt->getLength(), nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, clang_type,
@@ -533,7 +532,7 @@
 if (enum_type->isVolatileType())
   ast_enum = ast_enum.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), bytes, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ast_enum,
@@ -579,7 +578,7 @@
 if (type_def->isVolatileType())
   ast_typedef = ast_typedef.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 std::optional size;
 if (type_def->getLength())
   size = type_def->getLength();
@@ -659,7 +658,7 @@
 m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
  arg_list.size(), is_variadic, type_quals, cc);
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), std::nullopt, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,


Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -190,8 +190,7 @@
   return compiler_type.GetTypeName();
 }
 
-static bool GetDeclarationForSymbol(const PDBSymbol ,
-Declaration ) {
+static bool AddSourceInfoToDecl(const PDBSymbol , Declaration ) {
   auto _sym = symbol.getRawSymbol();
   auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
 
@@ -464,7 +463,7 @@
 if (udt->isVolatileType())
   clang_type = clang_type.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), udt->getLength(), nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, clang_type,
@@ -533,7 +532,7 @@
 if (enum_type->isVolatileType())
   ast_enum = ast_enum.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), bytes, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ast_enum,
@@ -579,7 +578,7 @@
 if (type_def->isVolatileType())
   ast_typedef = ast_typedef.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 std::optional size;
 if (type_def->getLength())
   size = type_def->getLength();
@@ -659,7 +658,7 @@
 m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
  arg_list.size(), is_variadic, type_quals, cc);
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), std::nullopt, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c9987f0 - [lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

2023-03-17 Thread Stefan Gränitz via lldb-commits

Author: Stefan Gränitz
Date: 2023-03-17T14:40:17+01:00
New Revision: c9987f0ac81a3d00be7627022372551bed61e6c1

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

LOG: [lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

The old name of this function was confusing for me, when I started working on 
the PDB parser. The new name clearifies that the function adds file, line and 
column (typically referred as source info) and indicates that the information 
is stored in the provided decl parameter.

Reviewed By: DavidSpickett

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index c9236da4842cf..da57338ffb58a 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -190,8 +190,7 @@ static ConstString GetPDBBuiltinTypeName(const 
PDBSymbolTypeBuiltin _type,
   return compiler_type.GetTypeName();
 }
 
-static bool GetDeclarationForSymbol(const PDBSymbol ,
-Declaration ) {
+static bool AddSourceInfoToDecl(const PDBSymbol , Declaration ) {
   auto _sym = symbol.getRawSymbol();
   auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
 
@@ -464,7 +463,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const 
PDBSymbol ) {
 if (udt->isVolatileType())
   clang_type = clang_type.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), udt->getLength(), nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, clang_type,
@@ -533,7 +532,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const 
PDBSymbol ) {
 if (enum_type->isVolatileType())
   ast_enum = ast_enum.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), bytes, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ast_enum,
@@ -579,7 +578,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const 
PDBSymbol ) {
 if (type_def->isVolatileType())
   ast_typedef = ast_typedef.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 std::optional size;
 if (type_def->getLength())
   size = type_def->getLength();
@@ -659,7 +658,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const 
PDBSymbol ) {
 m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
  arg_list.size(), is_variadic, type_quals, cc);
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), std::nullopt, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,



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


[Lldb-commits] [PATCH] D146286: [lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Thanks for the quick response!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146286

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


[Lldb-commits] [PATCH] D146293: [lldb][gnustep][PDB] Recognize ObjC classes and start definition only once the complete type is requested

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

In order to run the test yourself locally, you also need to apply D146058 
, D146154  
and D146221  first (right now they are still 
in review).




Comment at: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp:414
+  lang = eLanguageTypeObjC;
+
 // Check if such an UDT already exists in the current context.

I am not an ObjC expert, but from those who are I know that in practice this 
should holds for all common scenarios. So far it works reliably.

Right now I'd like to avoid patching the PDB contents from the compiler side. 
Would be great to see how far we get without. If there's a better way to do the 
same based on current PDB info, please let me know.



Comment at: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m:1
+// REQUIRES: objc-gnustep && system-windows
+//

This test is supposed to demonstrate what works with this patch. I will remove 
it once we match the features in the Linux/DWARF baseline proposed in: D146154 
test objc-gnustep-print.m


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146293

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


[Lldb-commits] [PATCH] D146293: [lldb][gnustep][PDB] Recognize ObjC classes and start definition only once the complete type is requested

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
sgraenitz added reviewers: aleksandr.urakov, rnk, aprantl, DavidSpickett, 
omjavaid, zturner, asmith.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added a project: LLDB.

This patch allows the PDB parser to recognize UDT symbols as ObjCInterfaceDecls 
and delay the definition process until we resolve the complete compiler type. 
This corresponds to the approach in the DWARF parser: 
https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L1869-L1871

In order to cache forward declarations for both, CXXRecordDecl and 
ObjCInterfaceDecl, the map type is changed to store NamedDecls now (first 
common base). The test shows that we get the names of type and members for a 
simple ObjC class now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146293

Files:
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/test/Shell/Expr/objc-gnustep-print-pdb.m

Index: lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
===
--- /dev/null
+++ lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
@@ -0,0 +1,69 @@
+// REQUIRES: objc-gnustep && system-windows
+//
+// RUN: %build %s --compiler=clang --objc-gnustep --output=%t
+
+#import "objc/runtime.h"
+
+@protocol NSCoding
+@end
+
+#ifdef __has_attribute
+#if __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
+#endif
+@interface NSObject {
+  id isa;
+  int refcount;
+}
+@end
+@implementation NSObject
+- (id)class {
+  return object_getClass(self);
+}
++ (id)new {
+  return class_createInstance(self, 0);
+}
+@end
+@interface TestObj : NSObject {
+  int _int;
+  float _float;
+  char _char;
+  void *_ptr_void;
+  NSObject *_ptr_nsobject;
+  id _id_objc;
+}
+- (int)ok;
+@end
+@implementation TestObj
+- (int)ok {
+  return self ? 0 : 1;
+}
+@end
+
+// RUN: %lldb -b -o "b objc-gnustep-print-pdb.m:67" -o "run" -o "p ptr" -o "p *ptr" -- %t | FileCheck %s
+//
+// CHECK: (lldb) b objc-gnustep-print-pdb.m:67
+// CHECK: Breakpoint {{.*}} at objc-gnustep-print-pdb.m:67
+//
+// CHECK: (lldb) run
+// CHECK: Process {{[0-9]+}} stopped
+// CHECK: frame #0: {{.*}}`main  at objc-gnustep-print-pdb.m:67
+//
+// CHECK: (lldb) p ptr
+// CHECK: (TestObj *) $0 = 0x{{[0-9]+}}
+//
+// CHECK: (lldb) p *ptr
+// CHECK: (TestObj) $1 = {
+// CHECK:   _int
+// CHECK:   _float
+// CHECK:   _char
+// CHECK:   _ptr_void
+// CHECK:   _ptr_nsobject
+// CHECK:   _id_objc
+// CHECK: }
+
+int main() {
+  TestObj *ptr = [TestObj new];
+  return [ptr ok];
+}
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -169,6 +169,8 @@
 
   void DumpClangAST(lldb_private::Stream ) override;
 
+  bool IsaNSObjectOrNSProxy(const llvm::pdb::PDBSymbolTypeUDT ) const;
+
 private:
   struct SecContribInfo {
 uint32_t Offset;
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -46,6 +46,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
@@ -2070,3 +2071,29 @@
 
   return 0;
 }
+
+bool SymbolFilePDB::IsaNSObjectOrNSProxy(
+const PDBSymbolTypeUDT _udt) const {
+  if (pdb_udt.getName() == "NSObject")
+return true;
+  if (pdb_udt.getName() == "NSProxy")
+return true;
+
+  auto bases_up = pdb_udt.findAllChildren();
+  std::unique_ptr pdb_base_up =
+  bases_up->getNext();
+  if (!pdb_base_up)
+return false; // No further bases classes (we assume it's C/C++)
+
+  if (bases_up->getNext())
+return false; // ObjC has single inheritance only (this must be C/C++)
+
+  user_id_t base_uid = pdb_base_up->getRawSymbol().getTypeId();
+  std::unique_ptr pdb_base_raw_up =
+  m_session_up->getSymbolById(base_uid);
+  if (pdb_base_raw_up->getSymTag() != PDB_SymType::UDT)
+return false; // Error: base class is not a user-defined type
+
+  auto *pdb_base_udt = llvm::dyn_cast(pdb_base_raw_up.get());
+  return IsaNSObjectOrNSProxy(*pdb_base_udt);
+}
Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
+++ 

[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Mika Molenkamp via Phabricator via lldb-commits
iridinite added a comment.

Hello all,

I am quite interested in integrating debuginfod with LLDB; my colleagues and I 
are currently exploring moving away from GDB to LLDB for general development 
work, since it appears to outperform GDB in many respects!

It appears there has been no activity on this patch for some time, so I was 
wondering, is this feature still something that is being investigated? Are 
there perhaps any alternatives I could look into, if debuginfod is not planned 
to be part of the LLDB mainline?

Thank you for your time!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

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


[Lldb-commits] [PATCH] D146286: [lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

2023-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added a comment.

Agreed, the original name sounds like a const method.

Although I can see why it might have been this way because before optional 
there was no way to have a null return. So it's return a bool and a ref to the 
result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146286

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


[Lldb-commits] [PATCH] D146286: [lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

2023-03-17 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
sgraenitz added reviewers: aleksandr.urakov, labath, rnk, asmith, zturner.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added a project: LLDB.

The old name of this function was confusing for me, when I started working on 
the PDB parser. The new name clearifies that the function adds file, line and 
column (typically referred as source info) and indicates that the information 
is stored in the provided decl parameter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146286

Files:
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp


Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -190,8 +190,7 @@
   return compiler_type.GetTypeName();
 }
 
-static bool GetDeclarationForSymbol(const PDBSymbol ,
-Declaration ) {
+static bool AddSourceInfoToDecl(const PDBSymbol , Declaration ) {
   auto _sym = symbol.getRawSymbol();
   auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
 
@@ -464,7 +463,7 @@
 if (udt->isVolatileType())
   clang_type = clang_type.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), udt->getLength(), nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, clang_type,
@@ -533,7 +532,7 @@
 if (enum_type->isVolatileType())
   ast_enum = ast_enum.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), bytes, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ast_enum,
@@ -579,7 +578,7 @@
 if (type_def->isVolatileType())
   ast_typedef = ast_typedef.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 std::optional size;
 if (type_def->getLength())
   size = type_def->getLength();
@@ -659,7 +658,7 @@
 m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
  arg_list.size(), is_variadic, type_quals, cc);
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), std::nullopt, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,


Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -190,8 +190,7 @@
   return compiler_type.GetTypeName();
 }
 
-static bool GetDeclarationForSymbol(const PDBSymbol ,
-Declaration ) {
+static bool AddSourceInfoToDecl(const PDBSymbol , Declaration ) {
   auto _sym = symbol.getRawSymbol();
   auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
 
@@ -464,7 +463,7 @@
 if (udt->isVolatileType())
   clang_type = clang_type.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), udt->getLength(), nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, clang_type,
@@ -533,7 +532,7 @@
 if (enum_type->isVolatileType())
   ast_enum = ast_enum.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), bytes, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ast_enum,
@@ -579,7 +578,7 @@
 if (type_def->isVolatileType())
   ast_typedef = ast_typedef.AddVolatileModifier();
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 std::optional size;
 if (type_def->getLength())
   size = type_def->getLength();
@@ -659,7 +658,7 @@
 m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
  arg_list.size(), is_variadic, type_quals, cc);
 
-GetDeclarationForSymbol(type, decl);
+AddSourceInfoToDecl(type, decl);
 return m_ast.GetSymbolFile()->MakeType(
 type.getSymIndexId(), ConstString(name), std::nullopt, nullptr,
 LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D146285: [lldb] For native compiles, check signal numbers are correct when adding codes

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146285

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

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

2023-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 506029.
DavidSpickett marked an inline comment as done.
DavidSpickett added a comment.

Correct Linux macro definition when not on Linux.


Repository:
  rG LLVM Github Monorepo

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

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,17 @@
 
 #include "NetBSDSignals.h"
 
+#ifdef __NetBSD__
+#include 
+
+#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 +28,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/LinuxSignals.cpp
===
--- lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -8,6 +8,27 @@
 
 #include "LinuxSignals.h"
 
+#ifdef __linux__
+#include 
+
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3
+#endif
+#ifndef SEGV_MTEAERR
+#define SEGV_MTEAERR 8
+#endif
+#ifndef SEGV_MTESERR
+#define SEGV_MTESERR 9
+#endif
+
+#define ADD_SIGCODE(signal, name, value, ...)  \
+  static_assert(name == value, "Value mismatch for signal code " #name);   \
+  AddSignalCode(signal, value, __VA_ARGS__)
+#else
+#define 

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

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



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

arichardson wrote:
> I guess these are needed to support older versions that don't have the 
> defines yet?
Yes, BNDERR is from 2015 so maybe it could go, but the memory tagging codes are 
certainly more recent.


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-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 506028.
DavidSpickett added a comment.

Remove SEGV_BNDERR defines from FreeBSD and NetBSD. I cargo culted these from 
CrashReason
but on checking the latest sources, they are not in either.

It has been in Linux since kernel 3.19 which was February 2015. But it's doing 
no harm
there so why take the risk.


Repository:
  rG LLVM Github Monorepo

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

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,17 @@
 
 #include "NetBSDSignals.h"
 
+#ifdef __NetBSD__
+#include 
+
+#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 +28,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/LinuxSignals.cpp
===
--- lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -8,6 +8,27 @@
 
 #include "LinuxSignals.h"
 
+#ifdef __linux__
+#include 
+
+#ifndef SEGV_BNDERR
+#define SEGV_BNDERR 3
+#endif
+#ifndef SEGV_MTEAERR
+#define SEGV_MTEAERR 8
+#endif
+#ifndef SEGV_MTESERR
+#define SEGV_MTESERR 9
+#endif
+
+#define ADD_SIGCODE(signal, name, value, ...)   

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

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

Rebase


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
@@ -212,6 +212,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 , int signo, const char *description)
-  : StopInfo(thread, signo) {
+  StopInfoUnixSignal(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 , 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 ) {
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_gpregset_data;
   std::vector m_notes;
Index: 

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

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

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146044

Files:
  lldb/include/lldb/Target/UnixSignals.h
  lldb/source/Plugins/Process/POSIX/CrashReason.cpp
  lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
  lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
  lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
  lldb/source/Target/UnixSignals.cpp
  lldb/unittests/Signals/UnixSignalsTest.cpp

Index: lldb/unittests/Signals/UnixSignalsTest.cpp
===
--- lldb/unittests/Signals/UnixSignalsTest.cpp
+++ lldb/unittests/Signals/UnixSignalsTest.cpp
@@ -23,6 +23,10 @@
 AddSignal(4, "SIG4", true, false, true, "DESC4");
 AddSignal(8, "SIG8", true, true, true, "DESC8");
 AddSignal(16, "SIG16", true, false, false, "DESC16");
+AddSignalCode(16, 1, "a specific type of SIG16");
+AddSignalCode(16, 2, "SIG16 with a fault address",
+  SignalCodePrintOption::Address);
+AddSignalCode(16, 3, "bounds violation", SignalCodePrintOption::Bounds);
   }
 };
 
@@ -93,6 +97,50 @@
   EXPECT_EQ(name, signals.GetSignalAsCString(signo));
 }
 
+TEST(UnixSignalsTest, GetAsCString) {
+  TestSignals signals;
+
+  ASSERT_EQ(nullptr, signals.GetSignalAsCString(100));
+  std::string name = signals.GetSignalAsCString(16);
+  ASSERT_EQ("SIG16", name);
+}
+
+TEST(UnixSignalsTest, GetAsString) {
+  TestSignals signals;
+
+  ASSERT_EQ("", signals.GetSignalDescription(100, std::nullopt));
+  ASSERT_EQ("SIG16", signals.GetSignalDescription(16, std::nullopt));
+  ASSERT_EQ("", signals.GetSignalDescription(100, 100));
+  ASSERT_EQ("SIG16", signals.GetSignalDescription(16, 100));
+  ASSERT_EQ("SIG16: a specific type of SIG16",
+signals.GetSignalDescription(16, 1));
+
+  // Unknown code, won't use the address.
+  ASSERT_EQ("SIG16", signals.GetSignalDescription(16, 100, 0xCAFEF00D));
+  // Known code, that shouldn't print fault address.
+  ASSERT_EQ("SIG16: a specific type of SIG16",
+signals.GetSignalDescription(16, 1, 0xCAFEF00D));
+  // Known code that should.
+  ASSERT_EQ("SIG16: SIG16 with a fault address (fault address: 0xcafef00d)",
+signals.GetSignalDescription(16, 2, 0xCAFEF00D));
+  // No address given just print the code description.
+  ASSERT_EQ("SIG16: SIG16 with a fault address",
+signals.GetSignalDescription(16, 2));
+
+  const char *expected = "SIG16: bounds violation";
+  // Must pass all needed info to get full output.
+  ASSERT_EQ(expected, signals.GetSignalDescription(16, 3));
+  ASSERT_EQ(expected, signals.GetSignalDescription(16, 3, 0xcafef00d));
+  ASSERT_EQ(expected, signals.GetSignalDescription(16, 3, 0xcafef00d, 0x1234));
+
+  ASSERT_EQ("SIG16: upper bound violation (fault address: 0x5679, lower bound: "
+"0x1234, upper bound: 0x5678)",
+signals.GetSignalDescription(16, 3, 0x5679, 0x1234, 0x5678));
+  ASSERT_EQ("SIG16: lower bound violation (fault address: 0x1233, lower bound: "
+"0x1234, upper bound: 0x5678)",
+signals.GetSignalDescription(16, 3, 0x1233, 0x1234, 0x5678));
+}
+
 TEST(UnixSignalsTest, VersionChange) {
   TestSignals signals;
 
Index: lldb/source/Target/UnixSignals.cpp
===
--- lldb/source/Target/UnixSignals.cpp
+++ lldb/source/Target/UnixSignals.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/ArchSpec.h"
 #include 
+#include 
 
 using namespace lldb_private;
 using namespace llvm;
@@ -112,6 +113,16 @@
   ++m_version;
 }
 
+void UnixSignals::AddSignalCode(int signo, int code, const char *description,
+SignalCodePrintOption print_option) {
+  collection::iterator signal = m_signals.find(signo);
+  assert(signal != m_signals.end() &&
+ "Tried to add code to signal that does not exist.");
+  signal->second.m_codes.insert(
+  std::pair{code, SignalCode{ConstString(description), print_option}});
+  ++m_version;
+}
+
 void UnixSignals::RemoveSignal(int signo) {
   collection::iterator pos = m_signals.find(signo);
   if (pos != m_signals.end())
@@ -127,6 +138,58 @@
 return pos->second.m_name.GetCString();
 }
 
+std::string
+UnixSignals::GetSignalDescription(int32_t signo, std::optional code,
+  std::optional addr,
+  std::optional lower,
+  std::optional upper) const {
+  std::string str;
+
+  collection::const_iterator pos = m_signals.find(signo);
+  if (pos != m_signals.end()) {
+str = pos->second.m_name.GetCString();
+
+if (code) {
+  std::map::const_iterator cpos =
+  pos->second.m_codes.find(*code);
+  if (cpos != pos->second.m_codes.end()) {
+const SignalCode  = cpos->second;