[Lldb-commits] [lldb] e19f722 - [lldb][Docs] Use proper LLDB/GDB project branding in tutorial (#90712)

2024-05-02 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-02T08:45:48+01:00
New Revision: e19f7221412f4b49f2aa2a3d8a07ffd3debab0d8

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

LOG: [lldb][Docs] Use proper LLDB/GDB project branding in tutorial (#90712)

Except when referring to the program binaries.

Added: 


Modified: 
lldb/docs/use/tutorial.rst

Removed: 




diff  --git a/lldb/docs/use/tutorial.rst b/lldb/docs/use/tutorial.rst
index c7f89976156ca4..22354c6720e14a 100644
--- a/lldb/docs/use/tutorial.rst
+++ b/lldb/docs/use/tutorial.rst
@@ -1,14 +1,14 @@
 Tutorial
 
 
-This document describes how to use lldb if you are already familiar with
-gdb's command set. We will start with some details on lldb command structure 
and
+This document describes how to use LLDB if you are already familiar with
+GDB's command set. We will start with some details on LLDB command structure 
and
 syntax.
 
 Command Structure
 -
 
-Unlike gdb's quite free-form commands, lldb's are more structured. All commands
+Unlike GDB's quite free-form commands, LLDB's are more structured. All commands
 are of the form:
 
 ::
@@ -24,11 +24,11 @@ all commands. The command syntax for basic commands is very 
simple.
 * Escape backslashes and double quotes within arguments should be escaped
   with a backslash ``\``.
 
-This makes lldb's commands more regular, but it also means you may have to 
quote
-some arguments in lldb that you would not in gdb.
+This makes LLDB's commands more regular, but it also means you may have to 
quote
+some arguments in LLDB that you would not in GDB.
 
-There is one other special quote character in lldb - the backtick `.
-If you put backticks around an argument or option value, lldb will run the text
+There is one other special quote character in LLDB - the backtick `.
+If you put backticks around an argument or option value, LLDB will run the text
 of the value through the expression parser, and the result of the expression
 will be passed to the command.  So for instance, if ``len`` is a local
 ``int`` variable with the value ``5``, then the command:
@@ -40,7 +40,7 @@ will be passed to the command.  So for instance, if ``len`` 
is a local
 Will receive the value ``5`` for the count option, rather than the string 
``len``.
 
 Options can be placed anywhere on the command line, but if the arguments begin
-with a ``-`` then you have to tell lldb that you are done with options for the
+with a ``-`` then you have to tell LLDB that you are done with options for the
 current command by adding an option termination: ``--``.
 
 So for instance, if you want to launch a process and give the ``process 
launch``
@@ -53,7 +53,7 @@ to launch to be launched with the arguments ``-program_arg 
value``, you would ty
 
 We also tried to reduce the number of special purpose argument parsers, which
 sometimes forces the user to be explicit about their intentions. The first
-instance you willl see of this is the breakpoint command. In gdb, to set a
+instance you willl see of this is the breakpoint command. In GDB, to set a
 breakpoint, you might enter:
 
 ::
@@ -71,17 +71,17 @@ from ``foo`` from ``foo.c::foo`` (which means the function 
``foo`` in the file `
 got more and more complex. Especially in C++ there are times where there is
 really no way to specify the function you want to break on.
 
-The lldb commands are more verbose but also more precise and allow for
+The LLDB commands are more verbose but also more precise and allow for
 intelligent auto completion.
 
-To set the same file and line breakpoint in lldb you can enter either of:
+To set the same file and line breakpoint in LLDB you can enter either of:
 
 ::
 
(lldb) breakpoint set --file foo.c --line 12
(lldb) breakpoint set -f foo.c -l 12
 
-To set a breakpoint on a function named ``foo`` in lldb you can enter either 
of:
+To set a breakpoint on a function named ``foo`` in LLDB you can enter either 
of:
 
 ::
 
@@ -96,7 +96,7 @@ conditions or commands without having to specify them 
multiple times:
 
(lldb) breakpoint set --name foo --name bar
 
-Setting breakpoints by name is even more specialized in lldb as you can specify
+Setting breakpoints by name is even more specialized in LLDB as you can specify
 that you want to set a breakpoint at a function by method name. To set a
 breakpoint on all C++ methods named ``foo`` you can enter either of:
 
@@ -125,7 +125,7 @@ The ``--shlib`` option can also be repeated to specify 
several shared libraries.
 
 Suggestions on more interesting primitives of this sort are also very welcome.
 
-Just like gdb, the lldb command interpreter does a shortest unique string match
+Just like GDB, the LLDB command interpreter does a shortest unique string match
 on command names, so 

[Lldb-commits] [lldb] [lldb][Docs] Use proper LLDB/GDB project branding in tutorial (PR #90712)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/90712
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 176d6fb - [lldb][Docs] Remove .txt copy of tutorial (#90585)

2024-05-02 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-02T08:45:57+01:00
New Revision: 176d6fbed3988032dbdabe7abfc5f54e1f0e2bbb

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

LOG: [lldb][Docs] Remove .txt copy of tutorial (#90585)

This was last modified in 4fd3347d6e4b0c873c789528e1c9a1b55990d1b6 in
2021 and was made obsolete by the RST version that
edb874b2310dc6eeaa27330ca1b1c013da7bdd65 added in 2019.

There are some differences but at this point, I'd bet the RST is the
correct one.

Added: 


Modified: 


Removed: 
lldb/docs/lldb-for-gdb-users.txt



diff  --git a/lldb/docs/lldb-for-gdb-users.txt 
b/lldb/docs/lldb-for-gdb-users.txt
deleted file mode 100644
index e5eae376bb4807..00
--- a/lldb/docs/lldb-for-gdb-users.txt
+++ /dev/null
@@ -1,488 +0,0 @@
-Here's a short precis of how to run lldb if you are familiar with the
-gdb command set:
-
-
-1) LLDB Command Structure:
-
-First some details on lldb command structure to help orient you...
-
-Unlike gdb's command set, which is rather free-form, we tried to make
-the lldb command syntax fairly structured.  The commands are all of the
-form
-
-  [-options [option-value]] [argument [argument...]]
-
-The command line parsing is done before command execution, so it is
-uniform across all the commands.  The command syntax is very simple,
-basically arguments, options and option values are all white-space
-separated.  If you need to put a backslash or double-quote character
-in an argument you back-slash it in the argument.  That makes the
-command syntax more regular, but it also means you may have to
-quote some arguments in lldb that you wouldn't in gdb.
-
-Options can be placed anywhere on the command line, but if the arguments
-begin with a "-" then you have to tell lldb that you're done with options
-using the "--" option.  So for instance, the "process launch" command takes
-the "-s" option to mean "stop the process at the first instruction".  It's 
-arguments are the arguments you are passing to the program.  So if you wanted
-to pass an argument that contained a "-" you would have to do:
-
-(lldb) process launch -- -program_arg value
-
-We also tried to reduce the number of special purpose argument
-parsers, which sometimes forces the user to be a little more explicit
-about stating their intentions.  The first instance you'll note of
-this is the breakpoint command.  In gdb, to set a breakpoint, you
-would just say:
-
-(gdb) break foo.c:12
-
-or
-
-(gdb) break foo
-
-if foo is a function.  As time went on, the parser that tells foo.c:12
-from foo from foo.c::foo (which means the function foo in the file
-foo.c) got more and more complex and bizarre, and especially in C++
-there are times where there's really no way to specify the function
-you want to break on.  The lldb commands are more verbose but also precise.  
-So you say:
-
-(lldb) breakpoint set -f foo.c -l 12
-
-to set a file & line breakpoint.  To set a breakpoint on a function
-by name, you do:
-
-(lldb) breakpoint set -n foo
-
-This can allow us to be more expressive, so you can say:
-
-(lldb) breakpoint set -M foo
-
-to break on all C++ methods named foo, or:
-
-(lldb) breakpoint set -S alignLeftEdges:
-
-to set a breakpoint on all ObjC selectors called alignLeftEdges:.  It
-also makes it easy to compose specifications, like:
-
-(lldb) breakpoint set -s foo.dylib -n foo
-
-for all functions called foo in the shared library foo.dylib.  Suggestions
-on more interesting primitives of this sort are also very welcome.
-
-So for instance:
-
-(lldb) breakpoint set -n "-[SKTGraphicView alignLeftEdges:]"
-
-Just like gdb, the lldb command interpreter does a shortest unique
-string match on command names, so the previous command can also be
-typed:
-
-(lldb) b s -n "-[SKTGraphicView alignLeftEdges:]"
-
-lldb also supports command completion for source file names, symbol
-names, file names, etc. Completion is initiated by a hitting a .
-Individual options in a command can have 
diff erent completers, so for
-instance the -f option in "breakpoint" completes to source files, the
--s option to currently loaded shared libraries, etc...  We can even do 
-things like if you specify -s, and are completing on -f, we will only
-list source files in the shared library specified by -s...
-
-The individual commands are pretty extensively documented, using
-the "help" command.  And there is an "apropos" command that will
-search the help for a particular word and dump a summary help string
-for each matching command.
-
-Finally, there is a mechanism to construct aliases for commonly used
-commands.  So for instance if you get annoyed typing
-
-(lldb) b s -f foo.c -l 12
-
-you can do:
-
-(lldb) command alias bfl breakpoint set -f %1 -l %2
-(lldb) bfl foo.c 12
-
-We have added a few alia

[Lldb-commits] [lldb] [lldb][Docs] Remove .txt copy of tutorial (PR #90585)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/90585
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 528b512 - [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (#84024)

2024-05-02 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-02T08:47:40+01:00
New Revision: 528b512b13e2ade4657b25dbb809bafd28c8b170

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

LOG: [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (#84024)

This relates to #56084.

vectorcall only works on x86
https://clang.llvm.org/docs/AttributeReference.html#vectorcall so
elsewhere it fails to compile. Which is expected on AArch64 for example
so is treated as a pass.

Added: 


Modified: 
lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py

Removed: 




diff  --git 
a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py 
b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
index 9483dfcd040186..0304482e899b82 100644
--- a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
+++ b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
@@ -62,7 +62,10 @@ def test_stdcall(self):
 return
 self.expect_expr("func(1, 2, 3, 4)", result_type="int", 
result_value="10")
 
+# Fails on x86, passes elsewhere because clang doesn't support vectorcall 
on
+# any other architectures.
 @expectedFailureAll(
+triple=re.compile("^(x86|i386)"),
 oslist=["freebsd"], 
bugnumber="github.com/llvm/llvm-project/issues/56084"
 )
 def test_vectorcall(self):



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


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (PR #84024)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/84024
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a015f01 - [lldb][test][FreeBSD] Remove corefile test xfails (#84022)

2024-05-02 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-02T08:48:40+01:00
New Revision: a015f015db21e02cbce4ff9d15d0b293e45d0831

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

LOG: [lldb][test][FreeBSD] Remove corefile test xfails (#84022)

Fixes #48759

As stated on the issue this was fixed by a change in FreeBSD 13, and
I've confirmed that it passes on 14 as well.

Added: 


Modified: 
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 7ec5e0d7c8309b..8ec0cbdd0fdd1f 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -292,9 +292,7 @@ def test_aarch64_pac(self):
 self.dbg.DeleteTarget(target)
 
 @skipIfLLVMTargetMissing("AArch64")
-@expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49415"
-)
+# This test fails on FreeBSD 12 and earlier, see llvm.org/pr49415 for 
details.
 def test_aarch64_regs(self):
 # check 64 bit ARM core files
 target = self.dbg.CreateTarget(None)
@@ -377,9 +375,7 @@ def test_aarch64_regs(self):
 self.expect("register read --all")
 
 @skipIfLLVMTargetMissing("AArch64")
-@expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49415"
-)
+# This test fails on FreeBSD 12 and earlier, see llvm.org/pr49415 for 
details.
 def test_aarch64_sve_regs_fpsimd(self):
 # check 64 bit ARM core files
 target = self.dbg.CreateTarget(None)



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


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Remove corefile test xfails (PR #84022)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/84022
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Be conversative about setting highmem address masks (PR #90533)

2024-05-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Seems logical to me, keep the 99% use case simple and folks who know they need 
a high mem mask have to put in the extra effort to really consider it.

https://github.com/llvm/llvm-project/pull/90533
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Be conversative about setting highmem address masks (PR #90533)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett approved this pull request.


https://github.com/llvm/llvm-project/pull/90533
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

The tests for the next PR depend on the format decided by 
https://github.com/llvm/llvm-project/pull/90059, which needs more work. So I 
will land this once that's sorted out.

https://github.com/llvm/llvm-project/pull/90063
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -1631,13 +1631,19 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
 return true;
   }
 
-  DWARFDIE dwarf_die = GetDIE(die_it->getSecond());
+  DWARFDIE dwarf_die = FindDefinitionDIE(GetDIE(die_it->getSecond()));
   if (dwarf_die) {
 // Once we start resolving this type, remove it from the forward
 // declaration map in case anyone child members or other types require this
 // type to get resolved. The type will get resolved when all of the calls
 // to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition are done.
-GetForwardDeclCompilerTypeToDIE().erase(die_it);
+// Need to get a new iterator because FindDefinitionDIE might add new

labath wrote:

Would it be possible to erase the iterator before calling FindDefinitionDIE?

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -533,9 +540,16 @@ class SymbolFileDWARF : public SymbolFileCommon {
   NameToOffsetMap m_function_scope_qualified_name_map;
   std::unique_ptr m_ranges;
   UniqueDWARFASTTypeMap m_unique_ast_type_map;
+  // A map from DIE to lldb_private::Type. For record type, the key might be
+  // either declaration DIE or definition DIE.
   DIEToTypePtr m_die_to_type;
   DIEToVariableSP m_die_to_variable_sp;
+  // A map from CompilerType to the struct/class/union/enum DIE (might be a
+  // declaration or a definition) that is used to construct it.
   CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
+  // A map from a struct/class/union/enum DIE (might be a declaration or a
+  // definition) to its definition DIE.
+  DIEToDIE m_die_to_def_die;

labath wrote:

(I also can't help but wonder why do we need that 
`m_forward_decl_compiler_type_to_die` in the first place, given that the 
`ClangASTMetadata` associated with the type already contains a user ID, which 
should allow us to retrieve original DIE. I know this isn't related to your 
patch, I'm just writing it in case you or someone has any thoughts on this.)

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -1654,6 +1660,99 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
   return false;
 }
 
+DWARFDIE SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
+  auto def_die_it = GetDeclarationDIEToDefinitionDIE().find(die.GetDIE());
+  if (def_die_it != GetDeclarationDIEToDefinitionDIE().end())
+return GetDIE(def_die_it->getSecond());
+
+  ParsedDWARFTypeAttributes attrs(die);
+  const dw_tag_t tag = die.Tag();
+  TypeSP type_sp;
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  if (log) {
+GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
+"forward declaration DIE, trying to find definition DIE",
+static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag),
+attrs.name.GetCString());
+  }
+  // We haven't parse definition die for this type, starting to search for it.
+  // After we found the definition die, the GetDeclarationDIEToDefinitionDIE()
+  // map will have the new mapping from this declaration die to definition die.
+  if (attrs.class_language == eLanguageTypeObjC ||

labath wrote:

I'm not sure how big of a problem this is (as `CompleteType` above already 
contains some clang-specific code), but moving some clang-specific code out of 
`DWARFASTParserClang` and into `SymbolFileDWARF` is less than ideal, as the 
latter is also used with non-clang/non-C languages. Would it be possible to 
keep this code `DWARFASTParserClang` somehow?

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -533,9 +540,16 @@ class SymbolFileDWARF : public SymbolFileCommon {
   NameToOffsetMap m_function_scope_qualified_name_map;
   std::unique_ptr m_ranges;
   UniqueDWARFASTTypeMap m_unique_ast_type_map;
+  // A map from DIE to lldb_private::Type. For record type, the key might be
+  // either declaration DIE or definition DIE.
   DIEToTypePtr m_die_to_type;
   DIEToVariableSP m_die_to_variable_sp;
+  // A map from CompilerType to the struct/class/union/enum DIE (might be a
+  // declaration or a definition) that is used to construct it.
   CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
+  // A map from a struct/class/union/enum DIE (might be a declaration or a
+  // definition) to its definition DIE.
+  DIEToDIE m_die_to_def_die;

labath wrote:

Would it be possible to avoid creating the extra map, for example by modifying 
the `m_forward_decl_compiler_type_to_die` to point to the definition DIE -- 
after that DIE has been located?

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -506,9 +506,29 @@ 
DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread,
   Target &target = thread.GetProcess()->GetTarget();
   const ModuleList &images = target.GetImages();
 
-  images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols);
-  if (!target_symbols.GetSize())
-return thread_plan_sp;
+  llvm::StringRef target_name = sym_name.GetStringRef();
+  // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or
+  // __AArch64AbsLongThunk_) added to the function name. If we detect a
+  // trampoline with the prefix, we need to remove the prefix to find the
+  // function symbol.
+  if (target_name.consume_front("__AArch64ADRPThunk_")) {

labath wrote:

How about `if (target_name.consume_front("__AArch64ADRPThunk_") || 
target_name.consume_front("__AArch64AbsLongThunk_"))`

https://github.com/llvm/llvm-project/pull/90783
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d00ed83 - [lldb] Fix build on FreeBSD

2024-05-02 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-05-02T10:12:36+01:00
New Revision: d00ed836e77759414afd40c02eeca5651657438f

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

LOG: [lldb] Fix build on FreeBSD

Missing llvm:: namespace for StringRef.

Added: 


Modified: 
lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp 
b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
index edb1d59cf42f88..919f26ba70123d 100644
--- a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
@@ -157,7 +157,7 @@ std::optional 
SymbolLocatorDefault::LocateExecutableSymbolFile(
   mib[1] = USER_LOCALBASE;
   if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
 FileSpec file_spec("/lib/debug");
-file_spec.PrependPathComponent(StringRef(buf));
+file_spec.PrependPathComponent(llvm::StringRef(buf));
 FileSystem::Instance().Resolve(file_spec);
 debug_file_search_paths.AppendIfUnique(file_spec);
   }



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


[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)

2024-05-02 Thread David Spickett via lldb-commits


@@ -141,6 +145,24 @@ std::optional 
SymbolLocatorDefault::LocateExecutableSymbolFile(
   FileSystem::Instance().Resolve(file_spec);
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
+#if defined(__FreeBSD__)
+// Add $LOCALBASE/lib/debug directory, where LOCALBASE is
+// usually /usr/local, but may be adjusted by the end user.
+{
+  int mib[2];
+  char buf[PATH_MAX];
+  size_t len = PATH_MAX;
+
+  mib[0] = CTL_USER;
+  mib[1] = USER_LOCALBASE;
+  if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
+FileSpec file_spec("/lib/debug");
+file_spec.PrependPathComponent(StringRef(buf));

DavidSpickett wrote:

Fixed: 
https://github.com/llvm/llvm-project/commit/d00ed836e77759414afd40c02eeca5651657438f

https://github.com/llvm/llvm-project/pull/81355
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes in newer versions (PR #84032)

2024-05-02 Thread David Spickett via lldb-commits


@@ -362,7 +363,15 @@ TEST(RegisterContextFreeBSDTest, arm64) {
   EXPECT_GPR_ARM64(lr, lr);
   EXPECT_GPR_ARM64(sp, sp);
   EXPECT_GPR_ARM64(pc, elr);
+#if __FreeBSD_version >= 1400084

DavidSpickett wrote:

Good point. Though these tests are likely only run on the machine that built 
them, but if lldb is loading a FreeBSD corefile it would need to know there was 
a difference. That at least needs checking, even if it may appear to "just 
work".

Making cross version core files work is more than I have time for here, so if 
any FreeBSD person wants to do a proper version of this fix, feel free.

(I did look for a runtime way to get `__FreeBSD_version` but none of the 
version strings I found contained the final part of the macro's value)

https://github.com/llvm/llvm-project/pull/84032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes in newer versions (PR #84032)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/84032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes in newer versions (PR #84032)

2024-05-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Fixing the general issue needs more attention, so I am abandoning this fix.

https://github.com/llvm/llvm-project/pull/84032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)

2024-05-02 Thread Gleb Popov via lldb-commits


@@ -141,6 +145,24 @@ std::optional 
SymbolLocatorDefault::LocateExecutableSymbolFile(
   FileSystem::Instance().Resolve(file_spec);
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
+#if defined(__FreeBSD__)
+// Add $LOCALBASE/lib/debug directory, where LOCALBASE is
+// usually /usr/local, but may be adjusted by the end user.
+{
+  int mib[2];
+  char buf[PATH_MAX];
+  size_t len = PATH_MAX;
+
+  mib[0] = CTL_USER;
+  mib[1] = USER_LOCALBASE;
+  if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
+FileSpec file_spec("/lib/debug");
+file_spec.PrependPathComponent(StringRef(buf));

arrowd wrote:

Sorry for the breakage. Is this because a `FileSpec` holds references, not the 
final string?

https://github.com/llvm/llvm-project/pull/81355
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)

2024-05-02 Thread Gleb Popov via lldb-commits

https://github.com/arrowd edited https://github.com/llvm/llvm-project/pull/81355
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [AArch64][TargetParser] autogen ArchExtKind enum - renaming (PR #90320)

2024-05-02 Thread Tomas Matheson via lldb-commits

https://github.com/tmatheson-arm edited 
https://github.com/llvm/llvm-project/pull/90320
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)

2024-05-02 Thread David Spickett via lldb-commits


@@ -141,6 +145,24 @@ std::optional 
SymbolLocatorDefault::LocateExecutableSymbolFile(
   FileSystem::Instance().Resolve(file_spec);
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
+#if defined(__FreeBSD__)
+// Add $LOCALBASE/lib/debug directory, where LOCALBASE is
+// usually /usr/local, but may be adjusted by the end user.
+{
+  int mib[2];
+  char buf[PATH_MAX];
+  size_t len = PATH_MAX;
+
+  mib[0] = CTL_USER;
+  mib[1] = USER_LOCALBASE;
+  if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
+FileSpec file_spec("/lib/debug");
+file_spec.PrependPathComponent(StringRef(buf));

DavidSpickett wrote:

In my case it just failed to compile without the `llvm::` namespace.

https://github.com/llvm/llvm-project/pull/81355
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix Scalar::GetData for non-multiple-of-8-bits values (PR #90846)

2024-05-02 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/90846

It was aligning the byte size down. Now it aligns up. This manifested itself as 
SBTypeStaticField::GetConstantValue returning a zero-sized value for `bool` 
fields (because clang represents bool as a 1-bit value).

I've changed the code for float Scalars as well, although I'm not aware of 
floating point values that are not multiples of 8 bits.

>From 7336344b98881a5158d9d4d72af5c51ebd1e74e2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 2 May 2024 10:49:13 +
Subject: [PATCH] [lldb] Fix Scalar::GetData for non-multiple-of-8-bits values

It was aligning the byte size down. Now it aligns up. This manifested
itself as SBTypeStaticField::GetConstantValue returning a zero-sized
value for `bool` fields (because clang represents bool as a 1-bit value).

I've changed the code for float Scalars as well, although I'm not aware
of floating point values that are not multiples of 8 bits.
---
 lldb/source/Utility/Scalar.cpp|  4 +--
 lldb/test/API/python_api/type/TestTypeList.py | 11 +++
 lldb/test/API/python_api/type/main.cpp|  1 +
 lldb/unittests/Utility/ScalarTest.cpp | 30 +++
 4 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index e94fd459623665..c70c5e10799187 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -134,9 +134,9 @@ size_t Scalar::GetByteSize() const {
   case e_void:
 break;
   case e_int:
-return (m_integer.getBitWidth() / 8);
+return (m_integer.getBitWidth() + 7) / 8;
   case e_float:
-return m_float.bitcastToAPInt().getBitWidth() / 8;
+return (m_float.bitcastToAPInt().getBitWidth() + 7) / 8;
   }
   return 0;
 }
diff --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index 81c44f7a39d61a..4dbfb06f8fc58c 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -52,6 +52,17 @@ def _find_static_field_in_Task_pointer(self, task_pointer):
 self.DebugSBValue(value)
 self.assertEqual(value.GetValueAsSigned(), 47)
 
+static_constexpr_bool_field = task_type.GetStaticFieldWithName(
+"static_constexpr_bool_field"
+)
+self.assertTrue(static_constexpr_bool_field)
+self.assertEqual(static_constexpr_bool_field.GetName(), 
"static_constexpr_bool_field")
+self.assertEqual(static_constexpr_bool_field.GetType().GetName(), 
"const bool")
+
+value = static_constexpr_bool_field.GetConstantValue(self.target())
+self.DebugSBValue(value)
+self.assertEqual(value.GetValueAsUnsigned(), 1)
+
 static_mutable_field = 
task_type.GetStaticFieldWithName("static_mutable_field")
 self.assertTrue(static_mutable_field)
 self.assertEqual(static_mutable_field.GetName(), 
"static_mutable_field")
diff --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index c86644d918279a..7384a3d8da16fb 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -28,6 +28,7 @@ class Task {
 union U {
 } u;
 static constexpr long static_constexpr_field = 47;
+static constexpr bool static_constexpr_bool_field = true;
 static int static_mutable_field;
 Task(int i, Task *n):
 id(i),
diff --git a/lldb/unittests/Utility/ScalarTest.cpp 
b/lldb/unittests/Utility/ScalarTest.cpp
index 8d957d16593ee7..500cb8bb2286e0 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -13,8 +13,11 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/ADT/APSInt.h"
 #include "llvm/Testing/Support/Error.h"
 
+#include 
 #include 
 
 using namespace lldb_private;
@@ -163,6 +166,33 @@ TEST(ScalarTest, GetBytes) {
   ASSERT_EQ(0, memcmp(f, Storage, sizeof(f)));
 }
 
+TEST(ScalarTest, GetData) {
+  auto get_data = [](llvm::APSInt v) {
+DataExtractor data;
+Scalar(v).GetData(data);
+return data.GetData().vec();
+  };
+
+  auto vec = [](std::initializer_list l) {
+std::vector v(l.begin(), l.end());
+if (endian::InlHostByteOrder() == lldb::eByteOrderLittle)
+  std::reverse(v.begin(), v.end());
+return v;
+  };
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/1, /*Unsigned=*/true)),
+  vec({0x01}));
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/8, /*Unsigned=*/true)),
+  vec({0xff}));
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/9, /*Unsigned=*/true)),
+  vec({0x01, 0xff}));
+}
+
 TEST(ScalarTest, SetValueFromData) {
   uint8_t a[] = {1, 2, 3, 4};
   Scalar s;

___
lldb-commits ma

[Lldb-commits] [lldb] [lldb] Fix Scalar::GetData for non-multiple-of-8-bits values (PR #90846)

2024-05-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

It was aligning the byte size down. Now it aligns up. This manifested itself as 
SBTypeStaticField::GetConstantValue returning a zero-sized value for `bool` 
fields (because clang represents bool as a 1-bit value).

I've changed the code for float Scalars as well, although I'm not aware of 
floating point values that are not multiples of 8 bits.

---
Full diff: https://github.com/llvm/llvm-project/pull/90846.diff


4 Files Affected:

- (modified) lldb/source/Utility/Scalar.cpp (+2-2) 
- (modified) lldb/test/API/python_api/type/TestTypeList.py (+11) 
- (modified) lldb/test/API/python_api/type/main.cpp (+1) 
- (modified) lldb/unittests/Utility/ScalarTest.cpp (+30) 


``diff
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index e94fd459623665..c70c5e10799187 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -134,9 +134,9 @@ size_t Scalar::GetByteSize() const {
   case e_void:
 break;
   case e_int:
-return (m_integer.getBitWidth() / 8);
+return (m_integer.getBitWidth() + 7) / 8;
   case e_float:
-return m_float.bitcastToAPInt().getBitWidth() / 8;
+return (m_float.bitcastToAPInt().getBitWidth() + 7) / 8;
   }
   return 0;
 }
diff --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index 81c44f7a39d61a..4dbfb06f8fc58c 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -52,6 +52,17 @@ def _find_static_field_in_Task_pointer(self, task_pointer):
 self.DebugSBValue(value)
 self.assertEqual(value.GetValueAsSigned(), 47)
 
+static_constexpr_bool_field = task_type.GetStaticFieldWithName(
+"static_constexpr_bool_field"
+)
+self.assertTrue(static_constexpr_bool_field)
+self.assertEqual(static_constexpr_bool_field.GetName(), 
"static_constexpr_bool_field")
+self.assertEqual(static_constexpr_bool_field.GetType().GetName(), 
"const bool")
+
+value = static_constexpr_bool_field.GetConstantValue(self.target())
+self.DebugSBValue(value)
+self.assertEqual(value.GetValueAsUnsigned(), 1)
+
 static_mutable_field = 
task_type.GetStaticFieldWithName("static_mutable_field")
 self.assertTrue(static_mutable_field)
 self.assertEqual(static_mutable_field.GetName(), 
"static_mutable_field")
diff --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index c86644d918279a..7384a3d8da16fb 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -28,6 +28,7 @@ class Task {
 union U {
 } u;
 static constexpr long static_constexpr_field = 47;
+static constexpr bool static_constexpr_bool_field = true;
 static int static_mutable_field;
 Task(int i, Task *n):
 id(i),
diff --git a/lldb/unittests/Utility/ScalarTest.cpp 
b/lldb/unittests/Utility/ScalarTest.cpp
index 8d957d16593ee7..500cb8bb2286e0 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -13,8 +13,11 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/ADT/APSInt.h"
 #include "llvm/Testing/Support/Error.h"
 
+#include 
 #include 
 
 using namespace lldb_private;
@@ -163,6 +166,33 @@ TEST(ScalarTest, GetBytes) {
   ASSERT_EQ(0, memcmp(f, Storage, sizeof(f)));
 }
 
+TEST(ScalarTest, GetData) {
+  auto get_data = [](llvm::APSInt v) {
+DataExtractor data;
+Scalar(v).GetData(data);
+return data.GetData().vec();
+  };
+
+  auto vec = [](std::initializer_list l) {
+std::vector v(l.begin(), l.end());
+if (endian::InlHostByteOrder() == lldb::eByteOrderLittle)
+  std::reverse(v.begin(), v.end());
+return v;
+  };
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/1, /*Unsigned=*/true)),
+  vec({0x01}));
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/8, /*Unsigned=*/true)),
+  vec({0xff}));
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/9, /*Unsigned=*/true)),
+  vec({0x01, 0xff}));
+}
+
 TEST(ScalarTest, SetValueFromData) {
   uint8_t a[] = {1, 2, 3, 4};
   Scalar s;

``




https://github.com/llvm/llvm-project/pull/90846
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix Scalar::GetData for non-multiple-of-8-bits values (PR #90846)

2024-05-02 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/90846

>From 258654adb8ae34626e58c35f04e1b63fa9100f4a Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 2 May 2024 10:49:13 +
Subject: [PATCH] [lldb] Fix Scalar::GetData for non-multiple-of-8-bits values

It was aligning the byte size down. Now it aligns up. This manifested
itself as SBTypeStaticField::GetConstantValue returning a zero-sized
value for `bool` fields (because clang represents bool as a 1-bit value).

I've changed the code for float Scalars as well, although I'm not aware
of floating point values that are not multiples of 8 bits.
---
 lldb/source/Utility/Scalar.cpp|  4 +--
 lldb/test/API/python_api/type/TestTypeList.py | 13 
 lldb/test/API/python_api/type/main.cpp|  1 +
 lldb/unittests/Utility/ScalarTest.cpp | 30 +++
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index e94fd459623665..c70c5e10799187 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -134,9 +134,9 @@ size_t Scalar::GetByteSize() const {
   case e_void:
 break;
   case e_int:
-return (m_integer.getBitWidth() / 8);
+return (m_integer.getBitWidth() + 7) / 8;
   case e_float:
-return m_float.bitcastToAPInt().getBitWidth() / 8;
+return (m_float.bitcastToAPInt().getBitWidth() + 7) / 8;
   }
   return 0;
 }
diff --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index 81c44f7a39d61a..17e27b624511cf 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -52,6 +52,19 @@ def _find_static_field_in_Task_pointer(self, task_pointer):
 self.DebugSBValue(value)
 self.assertEqual(value.GetValueAsSigned(), 47)
 
+static_constexpr_bool_field = task_type.GetStaticFieldWithName(
+"static_constexpr_bool_field"
+)
+self.assertTrue(static_constexpr_bool_field)
+self.assertEqual(
+static_constexpr_bool_field.GetName(), 
"static_constexpr_bool_field"
+)
+self.assertEqual(static_constexpr_bool_field.GetType().GetName(), 
"const bool")
+
+value = static_constexpr_bool_field.GetConstantValue(self.target())
+self.DebugSBValue(value)
+self.assertEqual(value.GetValueAsUnsigned(), 1)
+
 static_mutable_field = 
task_type.GetStaticFieldWithName("static_mutable_field")
 self.assertTrue(static_mutable_field)
 self.assertEqual(static_mutable_field.GetName(), 
"static_mutable_field")
diff --git a/lldb/test/API/python_api/type/main.cpp 
b/lldb/test/API/python_api/type/main.cpp
index c86644d918279a..7384a3d8da16fb 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -28,6 +28,7 @@ class Task {
 union U {
 } u;
 static constexpr long static_constexpr_field = 47;
+static constexpr bool static_constexpr_bool_field = true;
 static int static_mutable_field;
 Task(int i, Task *n):
 id(i),
diff --git a/lldb/unittests/Utility/ScalarTest.cpp 
b/lldb/unittests/Utility/ScalarTest.cpp
index 8d957d16593ee7..500cb8bb2286e0 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -13,8 +13,11 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/ADT/APSInt.h"
 #include "llvm/Testing/Support/Error.h"
 
+#include 
 #include 
 
 using namespace lldb_private;
@@ -163,6 +166,33 @@ TEST(ScalarTest, GetBytes) {
   ASSERT_EQ(0, memcmp(f, Storage, sizeof(f)));
 }
 
+TEST(ScalarTest, GetData) {
+  auto get_data = [](llvm::APSInt v) {
+DataExtractor data;
+Scalar(v).GetData(data);
+return data.GetData().vec();
+  };
+
+  auto vec = [](std::initializer_list l) {
+std::vector v(l.begin(), l.end());
+if (endian::InlHostByteOrder() == lldb::eByteOrderLittle)
+  std::reverse(v.begin(), v.end());
+return v;
+  };
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/1, /*Unsigned=*/true)),
+  vec({0x01}));
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/8, /*Unsigned=*/true)),
+  vec({0xff}));
+
+  EXPECT_THAT(
+  get_data(llvm::APSInt::getMaxValue(/*numBits=*/9, /*Unsigned=*/true)),
+  vec({0x01, 0xff}));
+}
+
 TEST(ScalarTest, SetValueFromData) {
   uint8_t a[] = {1, 2, 3, 4};
   Scalar s;

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


[Lldb-commits] [clang] [lldb] [llvm] [AArch64][TargetParser] autogen ArchExtKind enum - renaming (PR #90320)

2024-05-02 Thread Jonathan Thackray via lldb-commits

https://github.com/jthackray approved this pull request.

LGTM (presumably these were mechanically renamed, given the diff size).

https://github.com/llvm/llvm-project/pull/90320
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [AArch64][TargetParser] autogen ArchExtKind enum - renaming (PR #90320)

2024-05-02 Thread David Green via lldb-commits

davemgreen wrote:

IMO This patch looks far too large to sensibly review and needs to be split up. 
A lot of the changes don't really looks like mechanical renamings, and it is 
hard to see how they would not break existing uses of llvm arch64 target 
features?

https://github.com/llvm/llvm-project/pull/90320
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix Scalar::GetData for non-multiple-of-8-bits values (PR #90846)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/90846
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)

2024-05-02 Thread David Spickett via lldb-commits


@@ -506,9 +506,29 @@ 
DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread,
   Target &target = thread.GetProcess()->GetTarget();
   const ModuleList &images = target.GetImages();
 
-  images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols);
-  if (!target_symbols.GetSize())
-return thread_plan_sp;
+  llvm::StringRef target_name = sym_name.GetStringRef();
+  // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or
+  // __AArch64AbsLongThunk_) added to the function name. If we detect a
+  // trampoline with the prefix, we need to remove the prefix to find the
+  // function symbol.
+  if (target_name.consume_front("__AArch64ADRPThunk_")) {

DavidSpickett wrote:

You could also assign back to `symname` if `target_name` is not empty, then 
only have one call to `FindSymbolsWithNameAndType` at the end.

```
if ((target_name.consume_front("__AArch64ADRPThunk_") || 
target_name.consume_front("__AArch64AbsLongThunk_"))) && !target_name.empty())
   sym_name = ConstString(target_name);
images.FindSymbolsWithNameAndType(sym_name...
```

https://github.com/llvm/llvm-project/pull/90783
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [AArch64][TargetParser] autogen ArchExtKind enum - renaming (PR #90320)

2024-05-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff d9fc5babb96ca9c75f36f9cf3d3f2a55ddc0ab4d 
5db47b54f49943072a2b787fc64b92f1e9c4f21c -- clang/lib/Basic/Targets/AArch64.cpp 
clang/lib/Basic/Targets/AArch64.h clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
clang/test/CodeGen/aarch64-mixed-target-attributes.c 
clang/test/CodeGen/aarch64-targetattr.c clang/test/CodeGen/arm_acle.c 
clang/test/CodeGen/attr-target-clones-aarch64.c 
clang/test/CodeGen/attr-target-version.c clang/test/Driver/aarch64-fp16.c 
clang/test/Driver/aarch64-perfmon.c clang/test/Driver/aarch64-rand.c 
clang/test/Preprocessor/aarch64-target-features.c 
llvm/include/llvm/TargetParser/AArch64TargetParser.h 
llvm/include/llvm/TargetParser/ARMTargetParser.h 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp 
llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp 
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp 
llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp 
llvm/lib/TargetParser/AArch64TargetParser.cpp 
llvm/unittests/TargetParser/TargetParserTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp 
b/llvm/unittests/TargetParser/TargetParserTest.cpp
index b08ede84d2..9cc8845e8c 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1306,7 +1306,7 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_FP16FML, AArch64::AEK_PAUTH,
  AArch64::AEK_SVE2BITPERM, AArch64::AEK_FLAGM,
  AArch64::AEK_PMUV3,   AArch64::AEK_PREDRES,
- AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
+ AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
  AArch64::AEK_FCMA}),
 "9.2-A"),
 ARMCPUTestParams(
@@ -1323,20 +1323,24 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_FP16FML, AArch64::AEK_PAUTH,
  AArch64::AEK_SVE2BITPERM, AArch64::AEK_FLAGM,
  AArch64::AEK_PMUV3,   AArch64::AEK_PREDRES,
- AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
+ AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
  AArch64::AEK_FCMA}),
 "9.2-A"),
 ARMCPUTestParams(
 "neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
 AArch64::ExtensionBitset(
-{AArch64::AEK_RAS,  AArch64::AEK_SVE,  AArch64::AEK_SSBS,
- AArch64::AEK_RCPC, AArch64::AEK_CRC,  
AArch64::AEK_FPARMV8,
- AArch64::AEK_NEON, AArch64::AEK_RAS,  AArch64::AEK_LSE,
- AArch64::AEK_RDM,  AArch64::AEK_RCPC, 
AArch64::AEK_DOTPROD,
- AArch64::AEK_AES,  AArch64::AEK_SHA2, AArch64::AEK_SHA3,
- AArch64::AEK_SM4,  AArch64::AEK_FULLFP16, AArch64::AEK_BF16,
- AArch64::AEK_PROFILE,  AArch64::AEK_RNG,  
AArch64::AEK_FP16FML,
- AArch64::AEK_I8MM, AArch64::AEK_JSCVT,AArch64::AEK_FCMA,
+{AArch64::AEK_RAS,  AArch64::AEK_SVE,
+ AArch64::AEK_SSBS, AArch64::AEK_RCPC,
+ AArch64::AEK_CRC,  AArch64::AEK_FPARMV8,
+ AArch64::AEK_NEON, AArch64::AEK_RAS,
+ AArch64::AEK_LSE,  AArch64::AEK_RDM,
+ AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
+ AArch64::AEK_AES,  AArch64::AEK_SHA2,
+ AArch64::AEK_SHA3, AArch64::AEK_SM4,
+ AArch64::AEK_FULLFP16, AArch64::AEK_BF16,
+ AArch64::AEK_PROFILE,  AArch64::AEK_RNG,
+ AArch64::AEK_FP16FML,  AArch64::AEK_I8MM,
+ AArch64::AEK_JSCVT,AArch64::AEK_FCMA,
  AArch64::AEK_PAUTH}),
 "8.4-A"),
 ARMCPUTestParams(
@@ -1371,7 +1375,7 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_PAUTH,   AArch64::AEK_FLAGM,
  AArch64::AEK_PMUV3,   AArch64::AEK_RNG,
  AArch64::AEK_SVE2BITPERM, AArch64::AEK_FP16FML,
- AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
+ AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
  AArch64::AEK_FCMA}),
 "9.2-A"),
 ARMCPUTestParams(
@@ -1390,7 +1394,7 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_PAUTH,   AArch64::AEK_FLAGM,
  AArch64::AEK_PMUV3,   AArch64::AEK_RNG,
  AArch64::AEK_SVE2BITPERM, AArch64::AEK_FP16FML,
- AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
+ AArch64::AEK_PROFILE, AArch64::AEK_JSCVT,
  AArch64::AEK_FCMA}),
 "9.2-A"),
 ARMCPUTestParams(

[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)

2024-05-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

My first instinct with this sort of `if arch is bla` code is to put it into a 
plugin, usually the ABI. However this being ELF specific, and the ELF plugin 
not having access to a target to get the ABI from, that's not possible. The 
DYLD plugin could but then we still have 2 copies of the symbol prefixes. So 
same result really.

The ELF plugin function is already 300 lines of architecture details so this is 
not unique to trampolines at all.

If someone wanted to add trampolines for MachO, they would need to add them to 
the MachO plugin and the list in DYLD so the DYLD list is going to end up a 
superset of them anyway. So there will always be one larger list, with subsets 
of it in the different object type plugins.

The fact that DYLD might look for suffixes for ELF in a MachO file should not 
be a problem (at least for correctness) because a symbol with an ELF thunk 
suffix name would not be marked as a thunk symbol by the MachO object plugin in 
the first place.

So no need to change the structure of this PR, but do correct me if any of my 
assumptions are incorrect there.

https://github.com/llvm/llvm-project/pull/90783
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [AArch64][TargetParser] autogen ArchExtKind enum - renaming (PR #90320)

2024-05-02 Thread via lldb-commits

ostannard wrote:

@davemgreen This is already split into 18 commits, I don't think there's any 
reason to split it into 18 PRs, since comments on one of them likely apply to 
the others.

@tmatheson-arm I don't know if there's any more specific precedent for changing 
target feature names, but I think this will be a breaking change for existing 
bitcode files, which we do try to maintain backward compatibility with: 
https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility. Maybe we 
could add IR auto-upgrade code to handle old bitcode?

https://github.com/llvm/llvm-project/pull/90320
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [AArch64][TargetParser] autogen ArchExtKind enum - renaming (PR #90320)

2024-05-02 Thread David Green via lldb-commits

davemgreen wrote:

> This is already split into 18 commits, I don't think there's any reason to 
> split it into 18 PRs, since comments on one of them likely apply to the 
> others.

I disagree. This is going to be awkward for a lot of users of llvm and contains 
at least some details I don't agree with. I think it will can cause a lot of 
subtle bugs and can end up wasting a lot of peoples time. It should at least be 
awkward for us too.

https://github.com/llvm/llvm-project/pull/90320
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread via lldb-commits

https://github.com/royitaqi edited 
https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread via lldb-commits

royitaqi wrote:

Hi @JDevlieghere , @jimingham , @bulbazord ,

Gentle ping for a re-review.

Thanks,
Roy

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Zequan Wu via lldb-commits


@@ -1654,6 +1660,99 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
   return false;
 }
 
+DWARFDIE SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
+  auto def_die_it = GetDeclarationDIEToDefinitionDIE().find(die.GetDIE());
+  if (def_die_it != GetDeclarationDIEToDefinitionDIE().end())
+return GetDIE(def_die_it->getSecond());
+
+  ParsedDWARFTypeAttributes attrs(die);
+  const dw_tag_t tag = die.Tag();
+  TypeSP type_sp;
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  if (log) {
+GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
+"forward declaration DIE, trying to find definition DIE",
+static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag),
+attrs.name.GetCString());
+  }
+  // We haven't parse definition die for this type, starting to search for it.
+  // After we found the definition die, the GetDeclarationDIEToDefinitionDIE()
+  // map will have the new mapping from this declaration die to definition die.
+  if (attrs.class_language == eLanguageTypeObjC ||

ZequanWu wrote:

Which part of this function is clang-specific code? 

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-02 Thread via lldb-commits

https://github.com/royitaqi edited 
https://github.com/llvm/llvm-project/pull/90703
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (PR #84026)

2024-05-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

ping!

https://github.com/llvm/llvm-project/pull/84026
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -1654,6 +1660,99 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
   return false;
 }
 
+DWARFDIE SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
+  auto def_die_it = GetDeclarationDIEToDefinitionDIE().find(die.GetDIE());
+  if (def_die_it != GetDeclarationDIEToDefinitionDIE().end())
+return GetDIE(def_die_it->getSecond());
+
+  ParsedDWARFTypeAttributes attrs(die);
+  const dw_tag_t tag = die.Tag();
+  TypeSP type_sp;
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  if (log) {
+GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
+"forward declaration DIE, trying to find definition DIE",
+static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag),
+attrs.name.GetCString());
+  }
+  // We haven't parse definition die for this type, starting to search for it.
+  // After we found the definition die, the GetDeclarationDIEToDefinitionDIE()
+  // map will have the new mapping from this declaration die to definition die.
+  if (attrs.class_language == eLanguageTypeObjC ||

labath wrote:

Definitely anything that is gated on `language == eLanguageType*C*` checks, but 
a case could also be made that the whole declaration-to-definition mapping 
should be within the purview of the DWARFASTParser instance responsible for the 
specific language. Having the logic split between an ASTParser (a 
language-specific class) and SymbolFileDWARF (language-agnostic) forces all 
languages to work in the same way. I don't know how much of a problem would 
that be in practice, but it would definitely make the code nicer (single 
responsibility principle, and all) if the logic lived in a central place.

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (PR #84026)

2024-05-02 Thread Ed Maste via lldb-commits

https://github.com/emaste approved this pull request.


https://github.com/llvm/llvm-project/pull/84026
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)

2024-05-02 Thread Pavel Labath via lldb-commits

labath wrote:

> So no need to change the structure of this PR, but do correct me if any of my 
> assumptions are incorrect there.

The `DynamicLoaderPOSIXDYLD` is only used on ELF systems anyway (we might as 
well rename it do `DynamicLoaderELF`), so this actually lines up fairly well.

https://github.com/llvm/llvm-project/pull/90783
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] fbaba78 - [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (#84026)

2024-05-02 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-02T16:55:42+01:00
New Revision: fbaba780f6b131e7674259861fce915b1a94f78e

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

LOG: [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (#84026)

Fixes #48758

These are now passing on AArch64 FreeBSD 14.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
index c39cb4cd59aa07..f0a5429e6c1cec 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
@@ -6,9 +6,6 @@
 
 
 class TestGDBRemoteLoad(GDBRemoteTestBase):
-@expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414"
-)
 def test_module_load_address(self):
 """Test that setting the load address of a module uses virtual 
addresses"""
 target = self.createTarget("a.yaml")
@@ -20,9 +17,6 @@ def test_module_load_address(self):
 self.assertTrue(address.IsValid())
 self.assertEqual(".data", address.GetSection().GetName())
 
-@expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414"
-)
 def test_ram_load(self):
 """Test loading an object file to a target's ram"""
 target = self.createTarget("a.yaml")
@@ -31,9 +25,6 @@ def test_ram_load(self):
 self.assertPacketLogContains(["M1000,4:c3c3c3c3", "M1004,2:3232"])
 
 @skipIfXmlSupportMissing
-@expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414"
-)
 def test_flash_load(self):
 """Test loading an object file to a target's flash memory"""
 



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


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (PR #84026)

2024-05-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/84026
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Pavel Labath via lldb-commits


@@ -1654,6 +1660,99 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
   return false;
 }
 
+DWARFDIE SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
+  auto def_die_it = GetDeclarationDIEToDefinitionDIE().find(die.GetDIE());
+  if (def_die_it != GetDeclarationDIEToDefinitionDIE().end())
+return GetDIE(def_die_it->getSecond());
+
+  ParsedDWARFTypeAttributes attrs(die);
+  const dw_tag_t tag = die.Tag();
+  TypeSP type_sp;
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  if (log) {
+GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
+"forward declaration DIE, trying to find definition DIE",
+static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag),
+attrs.name.GetCString());
+  }
+  // We haven't parse definition die for this type, starting to search for it.
+  // After we found the definition die, the GetDeclarationDIEToDefinitionDIE()
+  // map will have the new mapping from this declaration die to definition die.
+  if (attrs.class_language == eLanguageTypeObjC ||

labath wrote:

I realize this is a bit fuzzy, and there are already some arguably 
clang-specific pieces of code in SymbolFileDWARF, but the main reason I am 
bringing this up is because this code (some of it at least) has previously been 
in DWARFASTParserClang, and now it isn't -- which seems like a regression to me.

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -321,9 +321,26 @@ class LLDB_API SBDebugger {
 
   void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
 
+  /// DEPRECATED: We used to only support one Destroy callback. Now that we
+  /// support Add and Remove, you should only remove Destroy callbacks that
+  /// you Add-ed. Use Add and Remove instead.

JDevlieghere wrote:

- Nit: Remove the "DEPRECATED:", that's covered by `LLDB_DEPRECATED_FIXME` 
below. 
- Suggestion: The "Add-ed" looks weird and you didn't write "Remove" so I would 
suggest  "you should only remove callbacks that you added." (which also drops 
the "Destroy"). I think it reads a lot easier that way. 

(We can keep the "DEPRECATED" on the private side)

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -731,8 +747,11 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::recursive_mutex m_destroy_callback_mutex;

JDevlieghere wrote:

Does this actually **need** to be thread safe? APIs being thread safe is of 
course a good thing, but in its current state, there are plenty of methods in 
the Debugger class that are not guaranteed to be thread safe. Unless there's a 
need for this to be safe, I wouldn't bother with the new mutex... 

Either way this shouldn't be a _recursive_ mutex.

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -743,9 +743,24 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 }
 
 void Debugger::HandleDestroyCallback() {
-  if (m_destroy_callback) {
-m_destroy_callback(GetID(), m_destroy_callback_baton);
-m_destroy_callback = nullptr;
+  std::lock_guard guard(m_destroy_callback_mutex);
+  const lldb::user_id_t user_id = GetID();
+  // This loop handles the case where callbacks are added/removed by existing
+  // callbacks during the loop, as the following:
+  // - Added callbacks will always be invoked.
+  // - Removed callbacks will never be invoked. That is *unless* the loop
+  //   happens to invoke the said callbacks first, before they get removed.
+  //   In this case, the callbacks gets invoked, and the removal return false.
+  //
+  // In the removal case, because the order of the container (`unordered_map`)
+  // is random, it's wise to not depend on the order and instead implement
+  // logic inside the callbacks to decide if their work should be skipped.
+  while (m_destroy_callback_and_baton.size()) {
+auto iter = m_destroy_callback_and_baton.begin();
+const auto &callback = iter->second.first;
+const auto &baton = iter->second.second;

JDevlieghere wrote:

Using `auto` for the iterator is fine, but it's not obvious from context what 
the types are of `.first` and `.second`. The  [LLVM Coding 
Standards](https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable)
 have a paragraph on when to use (and no use) `auto`. A few more instances of 
that below. 

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -731,8 +747,11 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::recursive_mutex m_destroy_callback_mutex;
+  lldb::destroy_callback_token_t m_destroy_callback_next_token = 0;
+  std::unordered_map>
+  m_destroy_callback_and_baton;

JDevlieghere wrote:

Given we expect the number of callbacks to be small, let's use a 
`llvm::SmallDenseMap` for this. 

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -62,12 +62,15 @@ typedef void *thread_arg_t; // Host thread 
argument type
 typedef void *thread_result_t;  // Host thread result type
 typedef void *(*thread_func_t)(void *); // Host thread function type
 typedef int pipe_t; // Host pipe type
+typedef int destroy_callback_token_t;   // Debugger destroy callback token type

JDevlieghere wrote:

Should this be unsigned?

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -1690,11 +1690,28 @@ void SBDebugger::SetDestroyCallback(
 lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
   LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
   if (m_opaque_sp) {
-return m_opaque_sp->SetDestroyCallback(
-destroy_callback, baton);
+m_opaque_sp->SetDestroyCallback(destroy_callback, baton);
   }
 }
 
+lldb::destroy_callback_token_t
+SBDebugger::AddDestroyCallback(lldb::SBDebuggerDestroyCallback 
destroy_callback,
+   void *baton) {
+  LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
+  if (m_opaque_sp) {
+return m_opaque_sp->AddDestroyCallback(destroy_callback, baton);
+  }
+  return LLDB_INVALID_DESTROY_CALLBACK_TOKEN;
+}
+
+bool SBDebugger::RemoveDestroyCallback(lldb::destroy_callback_token_t token) {
+  LLDB_INSTRUMENT_VA(this);

JDevlieghere wrote:

Missing token argument and missing newline.

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Jonas Devlieghere via lldb-commits


@@ -1690,11 +1690,28 @@ void SBDebugger::SetDestroyCallback(
 lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
   LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
   if (m_opaque_sp) {
-return m_opaque_sp->SetDestroyCallback(
-destroy_callback, baton);
+m_opaque_sp->SetDestroyCallback(destroy_callback, baton);
   }
 }
 
+lldb::destroy_callback_token_t
+SBDebugger::AddDestroyCallback(lldb::SBDebuggerDestroyCallback 
destroy_callback,
+   void *baton) {
+  LLDB_INSTRUMENT_VA(this, destroy_callback, baton);

JDevlieghere wrote:

Newline after `LLDB_INSTRUMENT`

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)

2024-05-02 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

lgtm.
It would be nice if new UI features could be added in the typescript code of 
lldb-dap, so that all users benefit from them.

https://github.com/llvm/llvm-project/pull/90799
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2d4acb0 - LLDB Debuginfod tests and a fix or two (#90622)

2024-05-02 Thread via lldb-commits

Author: Kevin Frei
Date: 2024-05-02T11:02:17-07:00
New Revision: 2d4acb086541577ac6ab3a140b9ceb9659ce7094

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

LOG: LLDB Debuginfod tests and a fix or two (#90622)

I'm taking yet another swing at getting these tests going, on the
hypothesis that the problems with buildbots & whatnot are because
they're not configured with CURL support, which I've confirmed would
cause the previous tests to fail. (I have no access to an ARM64 linux
system, but I did repro the failure on MacOS configured without CURL
support)

So, the only difference between this diff and
[previous](https://github.com/llvm/llvm-project/pull/85693)
[diffs](https://github.com/llvm/llvm-project/pull/87676) that have
already been approved is that I've added a condition to the tests to
only run if Debuginfod capabilities should be built into the binary. I
had done this for these tests when they were [Shell
tests](https://github.com/llvm/llvm-project/pull/79181) and not API
tests, but I couldn't find a direct analog in any API test, so I used
the "plugins" model used by the intel-pt tests as well.

-

Co-authored-by: Kevin Frei 

Added: 
lldb/test/API/debuginfod/Normal/Makefile
lldb/test/API/debuginfod/Normal/TestDebuginfod.py
lldb/test/API/debuginfod/Normal/main.c
lldb/test/API/debuginfod/SplitDWARF/Makefile
lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
lldb/test/API/debuginfod/SplitDWARF/main.c

Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/test/API/lit.site.cfg.py.in
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a04..2cbc918ebbaeb1 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here. 
+# standardize on "Windows_NT", so we'll make it consistent here.
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,6 +210,12 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
+
+   ifeq "$(MAKE_DWP)" "YES"
+   MAKE_DWO := YES
+   DWP_NAME = $(EXE).dwp
+   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
+   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -358,6 +364,7 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
+   DWP ?= $(call replace_cc_with,dwp)
override AR = $(ARCHIVER)
 endif
 
@@ -528,6 +535,10 @@ ifneq "$(CXX)" ""
endif
 endif
 
+ifeq "$(GEN_GNU_BUILD_ID)" "YES"
+   LDFLAGS += -Wl,--build-id
+endif
+
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -566,10 +577,17 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
+   cp "$(EXE)" "$(EXE).unstripped"
+endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
 endif
+ifeq "$(MAKE_DWP)" "YES"
+   $(DWP) -o "$(DWP_NAME)" $(DWOS)
 endif
+endif
+
 
 #--
 # Make the dylib
@@ -611,9 +629,15 @@ endif
 else
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+   ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
+   cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).unstripped"
+   endif
$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" 
"$(DYLIB_FILENAME).debug"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" 
"$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
 endif
+ifeq "$(MAKE_DWP)" "YES"
+   $(DWP) -o $(DYLIB_DWP_FILE) $(DYLIB_DWOS)
+endif
 endif
 
 #--

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/

[Lldb-commits] [lldb] LLDB Debuginfod tests and a fix or two (PR #90622)

2024-05-02 Thread Greg Clayton via lldb-commits

https://github.com/clayborg closed 
https://github.com/llvm/llvm-project/pull/90622
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -169,25 +173,28 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
+
+#if defined(DEBUGSERVER_IS_ARM64E)
 DNBLogThreaded("thread_get_state signed regs "
"\n   fp=%16.16llx"
"\n   lr=%16.16llx"
"\n   sp=%16.16llx"
"\n   pc=%16.16llx",
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
reinterpret_cast(m_state.context.gpr.__opaque_fp),
reinterpret_cast(m_state.context.gpr.__opaque_lr),
reinterpret_cast(m_state.context.gpr.__opaque_sp),
-   reinterpret_cast(m_state.context.gpr.__opaque_pc)
+   
reinterpret_cast(m_state.context.gpr.__opaque_pc));
 #else
-   m_state.context.gpr.__fp,
-   m_state.context.gpr.__lr, 
-   m_state.context.gpr.__sp,
-   m_state.context.gpr.__pc
+DNBLogThreaded("thread_get_state signed regs "
+   "\n   fp=%16.16llx"
+   "\n   lr=%16.16llx"
+   "\n   sp=%16.16llx"
+   "\n   pc=%16.16llx",
+   m_state.context.gpr.__fp, m_state.context.gpr.__lr,
+   m_state.context.gpr.__sp, m_state.context.gpr.__pc);

bulbazord wrote:

Suggestion: The format string is the same between these two, why not pull out 
the common factor? 
```
const char *format = "thread_get_state signed regs\n   fp=%16.16llx\n   
lr=%16.16llx\n   sp=%16.16llx\n   pc=%16.16llx";
#if defined(...)
DNBLogThreaded(format, ...);
#else
DNBLogThreaded(format, ...);
#endif
```

You could also pull out the arguments.

https://github.com/llvm/llvm-project/pull/90808
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu updated 
https://github.com/llvm/llvm-project/pull/90663

>From 4e83099b593e66f12dc21be5fbac5279e03e Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Tue, 30 Apr 2024 16:23:11 -0400
Subject: [PATCH 1/3] [lldb][DWARF] Delay struct/class/union definition DIE
 searching when parsing declaration DIEs.

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 270 +++---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 105 ++-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  14 +
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   5 +
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   2 +
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   |  95 +++---
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |  21 +-
 7 files changed, 296 insertions(+), 216 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index bea11e0e3840af..7ad661c9a9d49b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -252,7 +252,8 @@ static void ForcefullyCompleteType(CompilerType type) {
 static void PrepareContextToReceiveMembers(TypeSystemClang &ast,
ClangASTImporter &ast_importer,
clang::DeclContext *decl_ctx,
-   DWARFDIE die,
+   const DWARFDIE &decl_ctx_die,
+   const DWARFDIE &die,
const char *type_name_cstr) {
   auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
   if (!tag_decl_ctx)
@@ -279,6 +280,13 @@ static void PrepareContextToReceiveMembers(TypeSystemClang 
&ast,
 type_name_cstr ? type_name_cstr : "", die.GetOffset());
   }
 
+  // By searching for the definition DIE of the decl_ctx type, we will either:
+  // 1. Found the the definition DIE and start its definition with
+  // TypeSystemClang::StartTagDeclarationDefinition.
+  // 2. Unable to find it, then need to forcefully complete it.
+  die.GetDWARF()->FindDefinitionDIE(decl_ctx_die);
+  if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
+return;
   // We don't have a type definition and/or the import failed. We must
   // forcefully complete the type to avoid crashes.
   ForcefullyCompleteType(type);
@@ -620,10 +628,11 @@ DWARFASTParserClang::ParseTypeModifier(const 
SymbolContext &sc,
   if (tag == DW_TAG_typedef) {
 // DeclContext will be populated when the clang type is materialized in
 // Type::ResolveCompilerType.
-PrepareContextToReceiveMembers(
-m_ast, GetClangASTImporter(),
-GetClangDeclContextContainingDIE(die, nullptr), die,
-attrs.name.GetCString());
+DWARFDIE decl_ctx_die;
+clang::DeclContext *decl_ctx =
+GetClangDeclContextContainingDIE(die, &decl_ctx_die);
+PrepareContextToReceiveMembers(m_ast, GetClangASTImporter(), decl_ctx,
+   decl_ctx_die, die, attrs.name.GetCString());
 
 if (attrs.type.IsValid()) {
   // Try to parse a typedef from the (DWARF embedded in the) Clang
@@ -1100,32 +1109,6 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
 // struct and see if this is actually a C++ method
 Type *class_type = dwarf->ResolveType(decl_ctx_die);
 if (class_type) {
-  if (class_type->GetID() != decl_ctx_die.GetID() ||
-  IsClangModuleFwdDecl(decl_ctx_die)) {
-
-// We uniqued the parent class of this function to another
-// class so we now need to associate all dies under
-// "decl_ctx_die" to DIEs in the DIE for "class_type"...
-DWARFDIE class_type_die = dwarf->GetDIE(class_type->GetID());
-
-if (class_type_die) {
-  std::vector failures;
-
-  CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
- class_type, failures);
-
-  // FIXME do something with these failures that's
-  // smarter than just dropping them on the ground.
-  // Unfortunately classes don't like having stuff added
-  // to them after their definitions are complete...
-
-  Type *type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
-  if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
-return type_ptr->shared_from_this();
-  }
-}
-  }
-
   if (attrs.specification.IsValid()) {
 // We have a specification which we are going to base our
 // function prototype off of, so we need this type to be
@@ -1260,6 +1243,39 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
   }
 }
   }
+  // By here, we should have already completed t

[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -731,8 +747,11 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::recursive_mutex m_destroy_callback_mutex;

bulbazord wrote:

Handling a callback could add or remove other callbacks, it does need to be 
thread safe. And as much as I dislike recursive mutex as well, is there another 
way you could handle those scenarios safely? 

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Zequan Wu via lldb-commits


@@ -533,9 +540,16 @@ class SymbolFileDWARF : public SymbolFileCommon {
   NameToOffsetMap m_function_scope_qualified_name_map;
   std::unique_ptr m_ranges;
   UniqueDWARFASTTypeMap m_unique_ast_type_map;
+  // A map from DIE to lldb_private::Type. For record type, the key might be
+  // either declaration DIE or definition DIE.
   DIEToTypePtr m_die_to_type;
   DIEToVariableSP m_die_to_variable_sp;
+  // A map from CompilerType to the struct/class/union/enum DIE (might be a
+  // declaration or a definition) that is used to construct it.
   CompilerTypeToDIE m_forward_decl_compiler_type_to_die;
+  // A map from a struct/class/union/enum DIE (might be a declaration or a
+  // definition) to its definition DIE.
+  DIEToDIE m_die_to_def_die;

ZequanWu wrote:

Done.

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Zequan Wu via lldb-commits


@@ -1654,6 +1660,99 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
   return false;
 }
 
+DWARFDIE SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
+  auto def_die_it = GetDeclarationDIEToDefinitionDIE().find(die.GetDIE());
+  if (def_die_it != GetDeclarationDIEToDefinitionDIE().end())
+return GetDIE(def_die_it->getSecond());
+
+  ParsedDWARFTypeAttributes attrs(die);
+  const dw_tag_t tag = die.Tag();
+  TypeSP type_sp;
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  if (log) {
+GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
+"forward declaration DIE, trying to find definition DIE",
+static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag),
+attrs.name.GetCString());
+  }
+  // We haven't parse definition die for this type, starting to search for it.
+  // After we found the definition die, the GetDeclarationDIEToDefinitionDIE()
+  // map will have the new mapping from this declaration die to definition die.
+  if (attrs.class_language == eLanguageTypeObjC ||

ZequanWu wrote:

Done.

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-02 Thread Zequan Wu via lldb-commits


@@ -1631,13 +1631,19 @@ bool SymbolFileDWARF::CompleteType(CompilerType 
&compiler_type) {
 return true;
   }
 
-  DWARFDIE dwarf_die = GetDIE(die_it->getSecond());
+  DWARFDIE dwarf_die = FindDefinitionDIE(GetDIE(die_it->getSecond()));
   if (dwarf_die) {
 // Once we start resolving this type, remove it from the forward
 // declaration map in case anyone child members or other types require this
 // type to get resolved. The type will get resolved when all of the calls
 // to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition are done.
-GetForwardDeclCompilerTypeToDIE().erase(die_it);
+// Need to get a new iterator because FindDefinitionDIE might add new

ZequanWu wrote:

Now, we change `m_forward_decl_compiler_type_to_die` to be updated with 
definition DIE. So, we may need to erase twice, because the first erase is 
always necessary if we failed to find definition DIE for it. The second erase 
is because calling FindDefinitionDIE might add new entry to the definition DIE 
because the first one removed it.

https://github.com/llvm/llvm-project/pull/90663
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ee63f28 - [lldb-dap] Minor cleanup.

2024-05-02 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2024-05-02T14:22:03-04:00
New Revision: ee63f287e013ab3424372034d4d5a95512ab5b6b

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

LOG: [lldb-dap] Minor cleanup.

Fix #85974.

Added: 


Modified: 
lldb/tools/lldb-dap/JSONUtils.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index b4a2718bbb096e..788c1bc843db33 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -137,8 +137,7 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
 
 static bool IsClassStructOrUnionType(lldb::SBType t) {
   return (t.GetTypeClass() & (lldb::eTypeClassUnion | lldb::eTypeClassStruct |
-  lldb::eTypeClassUnion | lldb::eTypeClassArray)) 
!=
- 0;
+  lldb::eTypeClassArray)) != 0;
 }
 
 /// Create a short summary for a container that contains the summary of its



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


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -318,6 +318,12 @@ class SBCommandInterpreter {
 
   SBStructuredData GetStatistics();
 
+  /// Returns a list of handled commands, output and error. Each element in
+  /// the list is a dictionary with three keys: "command" (string), "output"
+  /// (list of strings) and optionally "error" (list of strings). Each string
+  /// in "output" and "error" is a line (without EOL characteres).

bulbazord wrote:

typo: `characteres` -> `characters`

https://github.com/llvm/llvm-project/pull/90703
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcaster,
   CommandUsageMap m_command_usages;
 
   StreamString m_transcript_stream;
+
+  /// Contains a list of handled commands, output and error. Each element in
+  /// the list is a dictionary with three keys: "command" (string), "output"
+  /// (list of strings) and optionally "error" (list of strings). Each string
+  /// in "output" and "error" is a line (without EOL characters).
+  StructuredData::ArraySP m_transcript_structured;

bulbazord wrote:

nit: No need to put `structured` in the variable name.

https://github.com/llvm/llvm-project/pull/90703
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -290,6 +290,36 @@ class StructuredData {
 
 void GetDescription(lldb_private::Stream &s) const override;
 
+/// Creates an Array of substrings by splitting a string around the
+/// occurrences of a separator character.
+///
+/// Note:
+/// * This is almost the same API and implementation as `StringRef::split`.
+/// * Not depending on `StringRef::split` because it will involve a
+///   temporary `SmallVectorImpl`.

bulbazord wrote:

It sounds like this is justifying duplication for efficiency reasons. Have you 
actually observed that there is an actual gain in duplicating this 
functionality here? If you're doing this preemptively because it sounds like it 
should be faster, I would say measure or don't do it at all.

https://github.com/llvm/llvm-project/pull/90703
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -366,10 +396,10 @@ class StructuredData {
   class String : public Object {
   public:
 String() : Object(lldb::eStructuredDataTypeString) {}
-explicit String(llvm::StringRef S)
-: Object(lldb::eStructuredDataTypeString), m_value(S) {}
+explicit String(llvm::StringRef s)
+: Object(lldb::eStructuredDataTypeString), m_value(s) {}
 
-void SetValue(llvm::StringRef S) { m_value = std::string(S); }
+void SetValue(llvm::StringRef s) { m_value = std::string(s); }

bulbazord wrote:

The changes to adjust the name of the variable are unnecessary and make it 
harder to navigate commit history. Please revert it.

https://github.com/llvm/llvm-project/pull/90703
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class StreamString;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(name) {}

bulbazord wrote:

`std::move` on the name?

https://github.com/llvm/llvm-project/pull/90063
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class StreamString;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(name) {}
+
+void ToXML(StreamString &strm) const;
+  };
+
+  typedef std::vector Enumerators;
+
+  FieldEnum(std::string id, const Enumerators &enumerators);
+
+  const Enumerators &GetEnumerators() const { return m_enumerators; }
+
+  const std::string &GetID() const { return m_id; }
+
+  void ToXML(StreamString &strm, unsigned size) const;
+
+private:
+  std::string m_id;
+  std::vector m_enumerators;

bulbazord wrote:

nit: Change the type to `Enumerators`?

https://github.com/llvm/llvm-project/pull/90063
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-02 Thread Alex Langford via lldb-commits


@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class StreamString;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(name) {}
+
+void ToXML(StreamString &strm) const;
+  };
+
+  typedef std::vector Enumerators;
+
+  FieldEnum(std::string id, const Enumerators &enumerators);
+
+  const Enumerators &GetEnumerators() const { return m_enumerators; }
+
+  const std::string &GetID() const { return m_id; }
+
+  void ToXML(StreamString &strm, unsigned size) const;

bulbazord wrote:

Why does this take a `StreamString &` directly instead of the more general 
`Stream &`?

https://github.com/llvm/llvm-project/pull/90063
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] LLDB Debuginfod tests and a fix or two (PR #90622)

2024-05-02 Thread Nico Weber via lldb-commits


@@ -44,6 +44,10 @@ lldb_build_intel_pt = '@LLDB_BUILD_INTEL_PT@'
 if lldb_build_intel_pt == '1':
 config.enabled_plugins.append('intel-pt')
 
+llvm_enable_curl = '@LLVM_ENABLE_CURL@'

nico wrote:

Is this correct? Won't this expand to 'NO' which is truthy when expanded with 
it off? Maybe you want this without quotes?

(Looks ike LLDB_BUILD_INTEL_PT gets this wrong too.)

https://github.com/llvm/llvm-project/pull/90622
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] LLDB Debuginfod tests and a fix or two (PR #90622)

2024-05-02 Thread Kevin Frei via lldb-commits


@@ -44,6 +44,10 @@ lldb_build_intel_pt = '@LLDB_BUILD_INTEL_PT@'
 if lldb_build_intel_pt == '1':
 config.enabled_plugins.append('intel-pt')
 
+llvm_enable_curl = '@LLVM_ENABLE_CURL@'

kevinfrei wrote:

I validated that this works correctly (had the same work). The *reason* it 
works is because I added LLVM_ENABLE_CURL to the list in 
`llvm_canonicalize_cmake_booleans` found in lldb/test/CMakeLists.txt.

https://github.com/llvm/llvm-project/pull/90622
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.

I agree with all comments here. I like being able to add and remove destroy 
callbacks. See my inline comments for changing `AddDestroyCallback` and 
`RemoveDestroyCallback`.

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Greg Clayton via lldb-commits

https://github.com/clayborg edited 
https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread Greg Clayton via lldb-commits


@@ -321,9 +321,26 @@ class LLDB_API SBDebugger {
 
   void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
 
+  /// DEPRECATED: We used to only support one Destroy callback. Now that we
+  /// support Add and Remove, you should only remove Destroy callbacks that
+  /// you Add-ed. Use Add and Remove instead.
+  ///
+  /// Clear all previously added callbacks and only add the given one.
+  LLDB_DEPRECATED_FIXME("Use AddDestroyCallback and RemoveDestroyCallback",
+"AddDestroyCallback")
   void SetDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback,
   void *baton);
 
+  /// Add a callback for when the debugger is destroyed. Return a token, which
+  /// can be used to remove said callback. Multiple callbacks can be added by
+  /// calling this function multiple times.
+  lldb::destroy_callback_token_t

clayborg wrote:

Do we really need a "lldb::destroy_callback_token_t" type here? I would prefer 
if this returns "void" and then modify `RemoveDestroyCallback(...)` to take the 
destroy callback to remove and include the baton so we know we are removing the 
right one:
```
bool RemoveDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback, 
void *baton);
```

This would allow someone to install two callback using the same callback, but 
with different baton values for each, and then still remove the right one when 
calling `RemoveDestroyCallback(...)`

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Don't fail when SBProcess::GetMemoryRegionInfo returns error. (PR #87649)

2024-05-02 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

makes sense to me

https://github.com/llvm/llvm-project/pull/87649
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-02 Thread via lldb-commits


@@ -321,9 +321,26 @@ class LLDB_API SBDebugger {
 
   void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
 
+  /// DEPRECATED: We used to only support one Destroy callback. Now that we
+  /// support Add and Remove, you should only remove Destroy callbacks that
+  /// you Add-ed. Use Add and Remove instead.
+  ///
+  /// Clear all previously added callbacks and only add the given one.
+  LLDB_DEPRECATED_FIXME("Use AddDestroyCallback and RemoveDestroyCallback",
+"AddDestroyCallback")
   void SetDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback,
   void *baton);
 
+  /// Add a callback for when the debugger is destroyed. Return a token, which
+  /// can be used to remove said callback. Multiple callbacks can be added by
+  /// calling this function multiple times.
+  lldb::destroy_callback_token_t

jimingham wrote:

I don't see the difference.  You call:

auto token1 = my_debugger.AddDestroyCallback(my_only_callback, baton1);
auto token2 = my_debugger.AddDestroyCallback(my_only_callback, baton2);

Then when you go to delete the first one, you use `token1`, and the second, 
`token2`.  I don't see the problem deleting the right one.  The difference is 
just: do you want to have to keep around the callback/baton pair in order to 
potentially disable it; or do you want to hold onto the token you got back.  I 
think the latter is more convenient.

https://github.com/llvm/llvm-project/pull/89868
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/90904

Add the ability to specify a log level to Host::SystemLog.

>From a7b4d7bd7374d0b41cb82fe8c97315006bf7d212 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 2 May 2024 13:20:16 -0700
Subject: [PATCH] [lldb] Add a log level to Host::SystemLog

Add the ability to specify a log level to Host::SystemLog.
---
 lldb/include/lldb/Host/Host.h  |  9 +++-
 lldb/source/Host/common/Host.cpp   | 30 ++
 lldb/source/Host/macosx/objcxx/Host.mm | 12 +--
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 30549cd7891497..b0cb477d82fa14 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -87,8 +87,15 @@ class Host {
   StartMonitoringChildProcess(const MonitorChildProcessCallback &callback,
   lldb::pid_t pid);
 
+  /// System log level.
+  enum SystemLogLevel {
+eSystemLogInfo,
+eSystemLogWarning,
+eSystemLogError,
+  };
+
   /// Emit the given message to the operating system log.
-  static void SystemLog(llvm::StringRef message);
+  static void SystemLog(SystemLogLevel log_level, llvm::StringRef message);
 
   /// Get the process ID for the calling process.
   ///
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 565138ba17031f..a0aa6a62755f92 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -91,15 +91,37 @@ using namespace lldb_private;
 #if !defined(__APPLE__)
 #if !defined(_WIN32)
 #include 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   static llvm::once_flag g_openlog_once;
   llvm::call_once(g_openlog_once, [] {
 openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
   });
-  syslog(LOG_INFO, "%s", message.data());
+  int level = LOG_DEBUG;
+  switch (log_level) {
+  case eSystemLogInfo:
+level = LOG_INFO;
+break;
+  case eSystemLogWarning:
+level = LOG_WARNING;
+break;
+  case eSystemLogError:
+level = LOG_WARNING;
+break;
+  }
+  syslog(level, "%s", message.data());
 }
 #else
-void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; }
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
+  switch (log_level) {
+  case eSystemLogInfo:
+  case eSystemLogWarning:
+llvm::outs() << message;
+break;
+  case eSystemLogError:
+llvm::errs() << message;
+break;
+  }
+}
 #endif
 #endif
 
@@ -629,5 +651,5 @@ char SystemLogHandler::ID;
 SystemLogHandler::SystemLogHandler() {}
 
 void SystemLogHandler::Emit(llvm::StringRef message) {
-  Host::SystemLog(message);
+  Host::SystemLog(Host::eSystemLogInfo, message);
 }
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 070a49208639a2..1f67141de55d70 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -102,12 +102,20 @@
 static os_log_t g_os_log;
 static std::once_flag g_os_log_once;
 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
 std::call_once(g_os_log_once, []() {
   g_os_log = os_log_create("com.apple.dt.lldb", "lldb");
 });
-os_log(g_os_log, "%{public}s", message.str().c_str());
+switch (log_level) {
+case eSystemLogInfo:
+case eSystemLogWarning:
+  os_log(g_os_log, "%{public}s", message.str().c_str());
+  break;
+case eSystemLogError:
+  os_log_error(g_os_log, "%{public}s", message.str().c_str());
+  break;
+}
   } else {
 llvm::errs() << message;
   }

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


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Add the ability to specify a log level to Host::SystemLog.

---
Full diff: https://github.com/llvm/llvm-project/pull/90904.diff


3 Files Affected:

- (modified) lldb/include/lldb/Host/Host.h (+8-1) 
- (modified) lldb/source/Host/common/Host.cpp (+26-4) 
- (modified) lldb/source/Host/macosx/objcxx/Host.mm (+10-2) 


``diff
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 30549cd7891497..b0cb477d82fa14 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -87,8 +87,15 @@ class Host {
   StartMonitoringChildProcess(const MonitorChildProcessCallback &callback,
   lldb::pid_t pid);
 
+  /// System log level.
+  enum SystemLogLevel {
+eSystemLogInfo,
+eSystemLogWarning,
+eSystemLogError,
+  };
+
   /// Emit the given message to the operating system log.
-  static void SystemLog(llvm::StringRef message);
+  static void SystemLog(SystemLogLevel log_level, llvm::StringRef message);
 
   /// Get the process ID for the calling process.
   ///
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 565138ba17031f..a0aa6a62755f92 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -91,15 +91,37 @@ using namespace lldb_private;
 #if !defined(__APPLE__)
 #if !defined(_WIN32)
 #include 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   static llvm::once_flag g_openlog_once;
   llvm::call_once(g_openlog_once, [] {
 openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
   });
-  syslog(LOG_INFO, "%s", message.data());
+  int level = LOG_DEBUG;
+  switch (log_level) {
+  case eSystemLogInfo:
+level = LOG_INFO;
+break;
+  case eSystemLogWarning:
+level = LOG_WARNING;
+break;
+  case eSystemLogError:
+level = LOG_WARNING;
+break;
+  }
+  syslog(level, "%s", message.data());
 }
 #else
-void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; }
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
+  switch (log_level) {
+  case eSystemLogInfo:
+  case eSystemLogWarning:
+llvm::outs() << message;
+break;
+  case eSystemLogError:
+llvm::errs() << message;
+break;
+  }
+}
 #endif
 #endif
 
@@ -629,5 +651,5 @@ char SystemLogHandler::ID;
 SystemLogHandler::SystemLogHandler() {}
 
 void SystemLogHandler::Emit(llvm::StringRef message) {
-  Host::SystemLog(message);
+  Host::SystemLog(Host::eSystemLogInfo, message);
 }
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 070a49208639a2..1f67141de55d70 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -102,12 +102,20 @@
 static os_log_t g_os_log;
 static std::once_flag g_os_log_once;
 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
 std::call_once(g_os_log_once, []() {
   g_os_log = os_log_create("com.apple.dt.lldb", "lldb");
 });
-os_log(g_os_log, "%{public}s", message.str().c_str());
+switch (log_level) {
+case eSystemLogInfo:
+case eSystemLogWarning:
+  os_log(g_os_log, "%{public}s", message.str().c_str());
+  break;
+case eSystemLogError:
+  os_log_error(g_os_log, "%{public}s", message.str().c_str());
+  break;
+}
   } else {
 llvm::errs() << message;
   }

``




https://github.com/llvm/llvm-project/pull/90904
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Med Ismail Bennani via lldb-commits


@@ -91,15 +91,37 @@ using namespace lldb_private;
 #if !defined(__APPLE__)
 #if !defined(_WIN32)
 #include 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   static llvm::once_flag g_openlog_once;
   llvm::call_once(g_openlog_once, [] {
 openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
   });
-  syslog(LOG_INFO, "%s", message.data());
+  int level = LOG_DEBUG;
+  switch (log_level) {
+  case eSystemLogInfo:
+level = LOG_INFO;
+break;
+  case eSystemLogWarning:
+level = LOG_WARNING;
+break;
+  case eSystemLogError:
+level = LOG_WARNING;

medismailben wrote:

typo ?

https://github.com/llvm/llvm-project/pull/90904
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben deleted 
https://github.com/llvm/llvm-project/pull/90904
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Med Ismail Bennani via lldb-commits


@@ -91,15 +91,37 @@ using namespace lldb_private;
 #if !defined(__APPLE__)
 #if !defined(_WIN32)
 #include 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   static llvm::once_flag g_openlog_once;
   llvm::call_once(g_openlog_once, [] {
 openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
   });
-  syslog(LOG_INFO, "%s", message.data());
+  int level = LOG_DEBUG;
+  switch (log_level) {
+  case eSystemLogInfo:
+level = LOG_INFO;
+break;
+  case eSystemLogWarning:
+level = LOG_WARNING;
+break;
+  case eSystemLogError:
+level = LOG_WARNING;

medismailben wrote:

typo ?

```suggestion
level = LOG_ERR;
```

https://github.com/llvm/llvm-project/pull/90904
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Display breakpoint locations using display name (PR #90297)

2024-05-02 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/90297
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/90904

>From 1109b65209d49046e029b780bf484a810c1bd42e Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 2 May 2024 13:20:16 -0700
Subject: [PATCH] [lldb] Add a log level to Host::SystemLog

Add the ability to specify a log level to Host::SystemLog.
---
 lldb/include/lldb/Host/Host.h  |  9 +++-
 lldb/source/Host/common/Host.cpp   | 30 ++
 lldb/source/Host/macosx/objcxx/Host.mm | 12 +--
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 30549cd7891497..b0cb477d82fa14 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -87,8 +87,15 @@ class Host {
   StartMonitoringChildProcess(const MonitorChildProcessCallback &callback,
   lldb::pid_t pid);
 
+  /// System log level.
+  enum SystemLogLevel {
+eSystemLogInfo,
+eSystemLogWarning,
+eSystemLogError,
+  };
+
   /// Emit the given message to the operating system log.
-  static void SystemLog(llvm::StringRef message);
+  static void SystemLog(SystemLogLevel log_level, llvm::StringRef message);
 
   /// Get the process ID for the calling process.
   ///
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 565138ba17031f..45b2a62b5c72a7 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -91,15 +91,37 @@ using namespace lldb_private;
 #if !defined(__APPLE__)
 #if !defined(_WIN32)
 #include 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   static llvm::once_flag g_openlog_once;
   llvm::call_once(g_openlog_once, [] {
 openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
   });
-  syslog(LOG_INFO, "%s", message.data());
+  int level = LOG_DEBUG;
+  switch (log_level) {
+  case eSystemLogInfo:
+level = LOG_INFO;
+break;
+  case eSystemLogWarning:
+level = LOG_WARNING;
+break;
+  case eSystemLogError:
+level = LOG_ERR;
+break;
+  }
+  syslog(level, "%s", message.data());
 }
 #else
-void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; }
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
+  switch (log_level) {
+  case eSystemLogInfo:
+  case eSystemLogWarning:
+llvm::outs() << message;
+break;
+  case eSystemLogError:
+llvm::errs() << message;
+break;
+  }
+}
 #endif
 #endif
 
@@ -629,5 +651,5 @@ char SystemLogHandler::ID;
 SystemLogHandler::SystemLogHandler() {}
 
 void SystemLogHandler::Emit(llvm::StringRef message) {
-  Host::SystemLog(message);
+  Host::SystemLog(Host::eSystemLogInfo, message);
 }
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 070a49208639a2..1f67141de55d70 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -102,12 +102,20 @@
 static os_log_t g_os_log;
 static std::once_flag g_os_log_once;
 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
 std::call_once(g_os_log_once, []() {
   g_os_log = os_log_create("com.apple.dt.lldb", "lldb");
 });
-os_log(g_os_log, "%{public}s", message.str().c_str());
+switch (log_level) {
+case eSystemLogInfo:
+case eSystemLogWarning:
+  os_log(g_os_log, "%{public}s", message.str().c_str());
+  break;
+case eSystemLogError:
+  os_log_error(g_os_log, "%{public}s", message.str().c_str());
+  break;
+}
   } else {
 llvm::errs() << message;
   }

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


[Lldb-commits] [lldb] LLDB Debuginfod tests and a fix or two (PR #90622)

2024-05-02 Thread via lldb-commits

Prabhuk wrote:

I am starting to see test failures in our toolchain builders after this patch:

https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8749027826743254513/overview

https://github.com/llvm/llvm-project/pull/90622
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)

2024-05-02 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/90808

>From 8145e9faaa52209f9800d473fb75f7cfbd2a1185 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 1 May 2024 18:06:50 -0700
Subject: [PATCH 1/2] [lldb] [debugserver] address preprocessor warning, extra
 arg

In DNBArchImplARM64.cpp I'm doing

And the preprocessor warns that this is not defined behavior.  This
checks if ptrauth_calls is available and if this is being compiled
64-bit (i.e. arm64e), and defines a single DEBUGSERVER_IS_ARM64E
when those are both true.

I did have to duplicate one DNBLogThreaded() call which itself is a
macro, and using an ifdef in the middle of macro arguments also got
me a warning from the preprocessor.

While testing this for all the different targets, I found a DNBError
initialization that accepts a c-string but I'm passing in a
printf-style formatter c-string and an argument.  Create the string
before the call and pass in the constructed string.

rdar://127129242
---
 .../debugserver/source/MacOSX/MachProcess.mm  |  8 ++---
 .../source/MacOSX/arm64/DNBArchImplARM64.cpp  | 31 ---
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 70b4564a027b1b..cbe3c5459e91fc 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -4070,10 +4070,10 @@ static CFStringRef CopyBundleIDForPath(const char 
*app_bundle_path,
   m_flags |= eMachProcessFlagsAttached;
   DNBLog("[LaunchAttach] successfully attached to pid %d", m_pid);
 } else {
-  launch_err.SetErrorString(
-  "Failed to attach to pid %d, BoardServiceLaunchForDebug() unable to "
-  "ptrace(PT_ATTACHEXC)",
-  m_pid);
+  std::string errmsg = "Failed to attach to pid ";
+  errmsg += std::to_string(m_pid);
+  errmsg += ", BoardServiceLaunchForDebug() unable to 
ptrace(PT_ATTACHEXC)";
+  launch_err.SetErrorString(errmsg.c_str());
   SetState(eStateExited);
   DNBLog("[LaunchAttach] END (%d) error: failed to attach to pid %d",
  getpid(), m_pid);
diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 57dd2dce6bf5ad..3b1147c69c666b 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -26,8 +26,12 @@
 #include 
 #include 
 
+#undef DEBUGSERVER_IS_ARM64E
 #if __has_feature(ptrauth_calls)
 #include 
+#if defined(__LP64__)
+#define DEBUGSERVER_IS_ARM64E 1
+#endif
 #endif
 
 // Break only in privileged or user mode
@@ -115,7 +119,7 @@ static uint64_t clear_pac_bits(uint64_t value) {
 uint64_t DNBArchMachARM64::GetPC(uint64_t failValue) {
   // Get program counter
   if (GetGPRState(false) == KERN_SUCCESS)
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
+#if defined(DEBUGSERVER_IS_ARM64E)
 return clear_pac_bits(
 reinterpret_cast(m_state.context.gpr.__opaque_pc));
 #else
@@ -147,7 +151,7 @@ kern_return_t DNBArchMachARM64::SetPC(uint64_t value) {
 uint64_t DNBArchMachARM64::GetSP(uint64_t failValue) {
   // Get stack pointer
   if (GetGPRState(false) == KERN_SUCCESS)
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
+#if defined(DEBUGSERVER_IS_ARM64E)
 return clear_pac_bits(
 reinterpret_cast(m_state.context.gpr.__opaque_sp));
 #else
@@ -169,25 +173,28 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
+
+#if defined(DEBUGSERVER_IS_ARM64E)
 DNBLogThreaded("thread_get_state signed regs "
"\n   fp=%16.16llx"
"\n   lr=%16.16llx"
"\n   sp=%16.16llx"
"\n   pc=%16.16llx",
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
reinterpret_cast(m_state.context.gpr.__opaque_fp),
reinterpret_cast(m_state.context.gpr.__opaque_lr),
reinterpret_cast(m_state.context.gpr.__opaque_sp),
-   reinterpret_cast(m_state.context.gpr.__opaque_pc)
+   
reinterpret_cast(m_state.context.gpr.__opaque_pc));
 #else
-   m_state.context.gpr.__fp,
-   m_state.context.gpr.__lr, 
-   m_state.context.gpr.__sp,
-   m_state.context.gpr.__pc
+DNBLogThreaded("thread_get_state signed regs "
+   "\n   fp=%16.16llx"
+   "\n   lr=%16.16llx"
+   "\n   sp=%16.16llx"
+   "\n   pc=%16.16llx",
+   m_state.context.gpr.__fp, m_state.context.gpr.__lr,
+   m_state.context.gpr.__sp, m_state.c

[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)

2024-05-02 Thread Jason Molenda via lldb-commits


@@ -169,25 +173,28 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
+
+#if defined(DEBUGSERVER_IS_ARM64E)
 DNBLogThreaded("thread_get_state signed regs "
"\n   fp=%16.16llx"
"\n   lr=%16.16llx"
"\n   sp=%16.16llx"
"\n   pc=%16.16llx",
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
reinterpret_cast(m_state.context.gpr.__opaque_fp),
reinterpret_cast(m_state.context.gpr.__opaque_lr),
reinterpret_cast(m_state.context.gpr.__opaque_sp),
-   reinterpret_cast(m_state.context.gpr.__opaque_pc)
+   
reinterpret_cast(m_state.context.gpr.__opaque_pc));
 #else
-   m_state.context.gpr.__fp,
-   m_state.context.gpr.__lr, 
-   m_state.context.gpr.__sp,
-   m_state.context.gpr.__pc
+DNBLogThreaded("thread_get_state signed regs "
+   "\n   fp=%16.16llx"
+   "\n   lr=%16.16llx"
+   "\n   sp=%16.16llx"
+   "\n   pc=%16.16llx",
+   m_state.context.gpr.__fp, m_state.context.gpr.__lr,
+   m_state.context.gpr.__sp, m_state.context.gpr.__pc);

jasonmolenda wrote:

good idea, done.

https://github.com/llvm/llvm-project/pull/90808
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 954d00e - [lldb] MachO delay-init binaries don't load as dependent

2024-05-02 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-05-02T15:20:17-07:00
New Revision: 954d00e87cdd77d0e9e367be52e62340467bd779

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

LOG: [lldb] MachO delay-init binaries don't load as dependent

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 1caf93659956b4..4dd23bb1e4dbec 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5140,8 +5140,17 @@ uint32_t 
ObjectFileMachO::GetDependentModules(FileSpecList &files) {
   case LC_LOADFVMLIB:
   case LC_LOAD_UPWARD_DYLIB: {
 uint32_t name_offset = cmd_offset + m_data.GetU32(&offset);
+bool is_delayed_init = false;
+uint32_t use_command_marker = m_data.GetU32(&offset);
+if (use_command_marker == 0x1a741800 /* DYLIB_USE_MARKER */) {
+  offset += 4; /* uint32_t current_version */
+  offset += 4; /* uint32_t compat_version */
+  uint32_t flags = m_data.GetU32(&offset);
+  if (flags & 0x08 /* DYLIB_USE_DELAYED_INIT */)
+is_delayed_init = true;
+}
 const char *path = m_data.PeekCStr(name_offset);
-if (path) {
+if (path && !is_delayed_init) {
   if (load_cmd.cmd == LC_RPATH)
 rpath_paths.push_back(path);
   else {



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


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/90904
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.


https://github.com/llvm/llvm-project/pull/90808
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2d15855 - [lldb] [debugserver] address preprocessor warning, extra arg (#90808)

2024-05-02 Thread via lldb-commits

Author: Jason Molenda
Date: 2024-05-02T15:52:24-07:00
New Revision: 2d15855adf6afac3f4171a24fd18b65a32eedf78

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

LOG: [lldb] [debugserver] address preprocessor warning, extra arg (#90808)

In DNBArchImplARM64.cpp I'm doing
```
#if __has_feature(ptrauth_calls) && defined(__LP64__)
```
And the preprocessor warns that this is not defined behavior. This
checks if ptrauth_calls is available and if this is being compiled
64-bit (i.e. arm64e), and defines a single DEBUGSERVER_IS_ARM64E when
those are both true.

I did have to duplicate one DNBLogThreaded() call which itself is a
macro, and using an ifdef in the middle of macro arguments also got me a
warning from the preprocessor.

While testing this for all the different targets, I found a DNBError
initialization that accepts a c-string but I'm passing in a printf-style
formatter c-string and an argument. Create the string before the call
and pass in the constructed string.

rdar://127129242

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 70b4564a027b1b..cbe3c5459e91fc 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -4070,10 +4070,10 @@ static CFStringRef CopyBundleIDForPath(const char 
*app_bundle_path,
   m_flags |= eMachProcessFlagsAttached;
   DNBLog("[LaunchAttach] successfully attached to pid %d", m_pid);
 } else {
-  launch_err.SetErrorString(
-  "Failed to attach to pid %d, BoardServiceLaunchForDebug() unable to "
-  "ptrace(PT_ATTACHEXC)",
-  m_pid);
+  std::string errmsg = "Failed to attach to pid ";
+  errmsg += std::to_string(m_pid);
+  errmsg += ", BoardServiceLaunchForDebug() unable to 
ptrace(PT_ATTACHEXC)";
+  launch_err.SetErrorString(errmsg.c_str());
   SetState(eStateExited);
   DNBLog("[LaunchAttach] END (%d) error: failed to attach to pid %d",
  getpid(), m_pid);

diff  --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 57dd2dce6bf5ad..b6f52cb5cf496d 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -26,8 +26,12 @@
 #include 
 #include 
 
+#undef DEBUGSERVER_IS_ARM64E
 #if __has_feature(ptrauth_calls)
 #include 
+#if defined(__LP64__)
+#define DEBUGSERVER_IS_ARM64E 1
+#endif
 #endif
 
 // Break only in privileged or user mode
@@ -115,7 +119,7 @@ static uint64_t clear_pac_bits(uint64_t value) {
 uint64_t DNBArchMachARM64::GetPC(uint64_t failValue) {
   // Get program counter
   if (GetGPRState(false) == KERN_SUCCESS)
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
+#if defined(DEBUGSERVER_IS_ARM64E)
 return clear_pac_bits(
 reinterpret_cast(m_state.context.gpr.__opaque_pc));
 #else
@@ -147,7 +151,7 @@ kern_return_t DNBArchMachARM64::SetPC(uint64_t value) {
 uint64_t DNBArchMachARM64::GetSP(uint64_t failValue) {
   // Get stack pointer
   if (GetGPRState(false) == KERN_SUCCESS)
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
+#if defined(DEBUGSERVER_IS_ARM64E)
 return clear_pac_bits(
 reinterpret_cast(m_state.context.gpr.__opaque_sp));
 #else
@@ -169,25 +173,24 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
  (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
 uint64_t *x = &m_state.context.gpr.__x[0];
-DNBLogThreaded("thread_get_state signed regs "
-   "\n   fp=%16.16llx"
-   "\n   lr=%16.16llx"
-   "\n   sp=%16.16llx"
-   "\n   pc=%16.16llx",
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
+
+const char *log_str = "thread_get_state signed regs "
+  "\n   fp=%16.16llx"
+  "\n   lr=%16.16llx"
+  "\n   sp=%16.16llx"
+  "\n   pc=%16.16llx";
+#if defined(DEBUGSERVER_IS_ARM64E)
+DNBLogThreaded(log_str,
reinterpret_cast(m_state.context.gpr.__opaque_fp),
reinterpret_cast(m_state.context.gpr.__opaque_lr),
reinterpret_cast(m_state.context.gpr.__opaque_sp),
-   reinterpret_cast(m_state.context.gpr.__opaque_pc)
+   
reinterpret_cast(m_state.context.gpr.__opaque_pc));
 #else
-   m_state.context.gpr.__fp,
- 

[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)

2024-05-02 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda closed 
https://github.com/llvm/llvm-project/pull/90808
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] Unify DW_TAG -> string conversions (PR #90657)

2024-05-02 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/90657
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a7e9e3e - [lldb] Add a log level to Host::SystemLog (#90904)

2024-05-02 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-05-02T16:07:11-07:00
New Revision: a7e9e3eb8b44bc3a6f14f0af71e555e2cac6ef41

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

LOG: [lldb] Add a log level to Host::SystemLog (#90904)

Add the ability to specify a log level to Host::SystemLog.

Added: 


Modified: 
lldb/include/lldb/Host/Host.h
lldb/source/Host/common/Host.cpp
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 30549cd7891497..b0cb477d82fa14 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -87,8 +87,15 @@ class Host {
   StartMonitoringChildProcess(const MonitorChildProcessCallback &callback,
   lldb::pid_t pid);
 
+  /// System log level.
+  enum SystemLogLevel {
+eSystemLogInfo,
+eSystemLogWarning,
+eSystemLogError,
+  };
+
   /// Emit the given message to the operating system log.
-  static void SystemLog(llvm::StringRef message);
+  static void SystemLog(SystemLogLevel log_level, llvm::StringRef message);
 
   /// Get the process ID for the calling process.
   ///

diff  --git a/lldb/source/Host/common/Host.cpp 
b/lldb/source/Host/common/Host.cpp
index 565138ba17031f..45b2a62b5c72a7 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -91,15 +91,37 @@ using namespace lldb_private;
 #if !defined(__APPLE__)
 #if !defined(_WIN32)
 #include 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   static llvm::once_flag g_openlog_once;
   llvm::call_once(g_openlog_once, [] {
 openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
   });
-  syslog(LOG_INFO, "%s", message.data());
+  int level = LOG_DEBUG;
+  switch (log_level) {
+  case eSystemLogInfo:
+level = LOG_INFO;
+break;
+  case eSystemLogWarning:
+level = LOG_WARNING;
+break;
+  case eSystemLogError:
+level = LOG_ERR;
+break;
+  }
+  syslog(level, "%s", message.data());
 }
 #else
-void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; }
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
+  switch (log_level) {
+  case eSystemLogInfo:
+  case eSystemLogWarning:
+llvm::outs() << message;
+break;
+  case eSystemLogError:
+llvm::errs() << message;
+break;
+  }
+}
 #endif
 #endif
 
@@ -629,5 +651,5 @@ char SystemLogHandler::ID;
 SystemLogHandler::SystemLogHandler() {}
 
 void SystemLogHandler::Emit(llvm::StringRef message) {
-  Host::SystemLog(message);
+  Host::SystemLog(Host::eSystemLogInfo, message);
 }

diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 070a49208639a2..1f67141de55d70 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -102,12 +102,20 @@
 static os_log_t g_os_log;
 static std::once_flag g_os_log_once;
 
-void Host::SystemLog(llvm::StringRef message) {
+void Host::SystemLog(SystemLogLevel log_level, llvm::StringRef message) {
   if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
 std::call_once(g_os_log_once, []() {
   g_os_log = os_log_create("com.apple.dt.lldb", "lldb");
 });
-os_log(g_os_log, "%{public}s", message.str().c_str());
+switch (log_level) {
+case eSystemLogInfo:
+case eSystemLogWarning:
+  os_log(g_os_log, "%{public}s", message.str().c_str());
+  break;
+case eSystemLogError:
+  os_log_error(g_os_log, "%{public}s", message.str().c_str());
+  break;
+}
   } else {
 llvm::errs() << message;
   }



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


[Lldb-commits] [lldb] [lldb] Add a log level to Host::SystemLog (PR #90904)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/90904
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Always emit diagnostic events to the system log (PR #90913)

2024-05-02 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/90913

Always emit diagnostic events to the system log so that they end up in the 
sysdiagnose on Darwin.

>From 458913020dd443c0ca92caa63cf8477035f8c5cc Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 2 May 2024 15:47:46 -0700
Subject: [PATCH] [lldb] Always emit diagnostic events to the system log

Always emit diagnostic events to the system log so that they end up in
the sysdiagnose on Darwin.
---
 lldb/source/Core/Debugger.cpp | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index cac4642873b772..c5ab99fac75d27 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1512,7 +1512,22 @@ void 
Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type,
 std::string message,
 std::optional debugger_id,
 std::once_flag *once) {
+  auto GetSystemLogLevel = [](DiagnosticEventData::Type type) {
+switch (type) {
+case DiagnosticEventData::Type::Info:
+  return Host::eSystemLogInfo;
+case DiagnosticEventData::Type::Warning:
+  return Host::eSystemLogWarning;
+case DiagnosticEventData::Type::Error:
+  return Host::eSystemLogError;
+}
+llvm_unreachable("All cases handled above!");
+  };
+
   auto ReportDiagnosticLambda = [&]() {
+// Always log diagnostics to the system log.
+Host::SystemLog(GetSystemLogLevel(type), message);
+
 // The diagnostic subsystem is optional but we still want to broadcast
 // events when it's disabled.
 if (Diagnostics::Enabled())

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


[Lldb-commits] [lldb] [lldb] Always emit diagnostic events to the system log (PR #90913)

2024-05-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Always emit diagnostic events to the system log so that they end up in the 
sysdiagnose on Darwin.

---
Full diff: https://github.com/llvm/llvm-project/pull/90913.diff


1 Files Affected:

- (modified) lldb/source/Core/Debugger.cpp (+15) 


``diff
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index cac4642873b772..c5ab99fac75d27 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1512,7 +1512,22 @@ void 
Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type,
 std::string message,
 std::optional debugger_id,
 std::once_flag *once) {
+  auto GetSystemLogLevel = [](DiagnosticEventData::Type type) {
+switch (type) {
+case DiagnosticEventData::Type::Info:
+  return Host::eSystemLogInfo;
+case DiagnosticEventData::Type::Warning:
+  return Host::eSystemLogWarning;
+case DiagnosticEventData::Type::Error:
+  return Host::eSystemLogError;
+}
+llvm_unreachable("All cases handled above!");
+  };
+
   auto ReportDiagnosticLambda = [&]() {
+// Always log diagnostics to the system log.
+Host::SystemLog(GetSystemLogLevel(type), message);
+
 // The diagnostic subsystem is optional but we still want to broadcast
 // events when it's disabled.
 if (Diagnostics::Enabled())

``




https://github.com/llvm/llvm-project/pull/90913
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >