[Lldb-commits] [lldb] [lldb][Docs] Sort documented packets alphabetically (PR #90584)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/90584 ___ 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)
arrowd wrote: Another bump. Can we get this in? 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] Fixed unresolved test lldb-api python_api/debugger/TestDebuggerAPI.py on x86_64 host (PR #90580)
https://github.com/slydiman edited https://github.com/llvm/llvm-project/pull/90580 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Docs] Various style improvements to the tutorial (PR #90594)
DavidSpickett wrote: Yes fair point the docs as a whole prefer the branding. As the document itself was mostly lower case that also influenced me. I tried to put the name changes in their own commit but some are spread around, so I'll be a bit cheeky and land this as is then come back with a PR to properly brand the names, or mark places where we are talking about the binary. https://github.com/llvm/llvm-project/pull/90594 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Docs] Various style improvements to the tutorial (PR #90594)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/90594 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] eb6097a - [lldb][Docs] Various style improvements to the tutorial (#90594)
Author: David Spickett Date: 2024-05-01T10:00:12+01:00 New Revision: eb6097a79e79d03dfc758cc6e79110cbac66d800 URL: https://github.com/llvm/llvm-project/commit/eb6097a79e79d03dfc758cc6e79110cbac66d800 DIFF: https://github.com/llvm/llvm-project/commit/eb6097a79e79d03dfc758cc6e79110cbac66d800.diff LOG: [lldb][Docs] Various style improvements to the tutorial (#90594) * Replace "we" with either "you" (when talking to the reader) or "lldb" (when talking about the project). * Refer to lldb as lldb not LLDB, to match what the user sees on the command line (I am going to come back later and put the proper name in places where it's talking about the projects themselves) * Remove a bunch of contractions for example "won't". Which don't (pun intended) seem like a big deal at first but even I as a native English speaker find the text clearer with them expanded. * Use RST's plain text highlighting for keywords and command names. * Split some very long lines for easier editing in future. Added: Modified: lldb/docs/use/tutorial.rst Removed: diff --git a/lldb/docs/use/tutorial.rst b/lldb/docs/use/tutorial.rst index ff956d750c29f2..c7f89976156ca4 100644 --- a/lldb/docs/use/tutorial.rst +++ b/lldb/docs/use/tutorial.rst @@ -1,89 +1,94 @@ Tutorial -Here's a short precis of how to run lldb if you are familiar with the gdb -command set. We will start with some details on lldb command structure and -syntax to help orient you. +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 command set, which is rather free-form, we tried to make the lldb command syntax fairly structured. The commands are all of the form: +Unlike gdb's quite free-form commands, lldb's are more structured. All commands +are 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 for basic commands is very simple, -arguments, options and option values are all white-space separated, and -either single or double-quotes (in pairs) are used to protect white-spaces -in an argument. 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. +The command line parsing is done before command execution, so it is the same for +all commands. The command syntax for basic commands is very simple. -There is one other special quote character in lldb - the backtick. +* Arguments, options and option values are all white-space separated. +* Either single ``'`` or double-quotes ``"`` (in pairs) are used to protect white-spaces + in an argument. +* 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. + +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: +will be passed to the command. So for instance, if ``len`` is a local +``int`` variable with the value ``5``, then the command: :: (lldb) memory read -c `len` 0x12345 -will receive the value 5 for the count option, rather than the string "len". - +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're 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" command the -"--stop-at-entry" option, yet you want the process you are about to launch to -be launched with the arguments "-program_arg value", you would type: +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`` +command the ``--stop-at-entry`` option, yet you want the process you are about +to launch to be launched with the arguments ``-program_arg value``, you would type: :: (lldb) process launch --stop-at-entry -- -program_arg value We also tried to reduce the number of special purpose argument parsers, which -sometimes forces th
[Lldb-commits] [lldb] [lldb][Docs] Use proper LLDB/GDB project branding in tutorial (PR #90712)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/90712 Except when referring to the program binaries. >From c004c331828080273679d5de8145c916285c607d Mon Sep 17 00:00:00 2001 From: David Spickett Date: Wed, 1 May 2024 10:08:55 +0100 Subject: [PATCH] [lldb][Docs] Use proper LLDB/GDB project branding in tutorial Except when referring to the program binaries. --- lldb/docs/use/tutorial.rst | 116 ++--- 1 file changed, 58 insertions(+), 58 deletions(-) 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 the following two commands will both execute the same c
[Lldb-commits] [lldb] [lldb][Docs] Use proper LLDB/GDB project branding in tutorial (PR #90712)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Except when referring to the program binaries. --- Full diff: https://github.com/llvm/llvm-project/pull/90712.diff 1 Files Affected: - (modified) lldb/docs/use/tutorial.rst (+58-58) ``diff 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 the following two commands will both execute the same command: @@ -134,12 +134,12 @@ command: (lldb) breakpoint set -n "-[SKTGraphicView alignLeftEdges:]" (lldb) br s -n "-[SKTGraphicView alignLeftEdges:]" -lldb also supports command completion for source file names,
[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)
https://github.com/Michael137 approved this pull request. LGTM 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)
https://github.com/emaste approved this pull request. This is reasonable and in line with the existing special case for NetBSD, but it seems like this logic shouldn't really be here but in a target-specific file. When (live or corefile) cross-debugging a FreeBSD target we should look in $LOCALBASE/lib/debug relative to a sysroot. 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] f07a2ed - [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (#81355)
Author: Gleb Popov Date: 2024-05-01T10:18:55-04:00 New Revision: f07a2edc64650f44bc592d74bb4c99ddde3772d3 URL: https://github.com/llvm/llvm-project/commit/f07a2edc64650f44bc592d74bb4c99ddde3772d3 DIFF: https://github.com/llvm/llvm-project/commit/f07a2edc64650f44bc592d74bb4c99ddde3772d3.diff LOG: [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (#81355) FreeBSD ports will now install debuginfo under $LOCALBASE/lib/debug/, where $LOCALBASE is typically /usr/local. On FreeBSD search this path in addition to existing debug info paths. Relevant change on the FreeBSD side: https://reviews.freebsd.org/D43515 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 6f0126b16cdc00..edb1d59cf42f88 100644 --- a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp +++ b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp @@ -36,6 +36,10 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/ThreadPool.h" +#if defined(__FreeBSD__) +#include +#endif + // From MacOSX system header "mach/machine.h" typedef int cpu_type_t; typedef int cpu_subtype_t; @@ -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)); +FileSystem::Instance().Resolve(file_spec); +debug_file_search_paths.AppendIfUnique(file_spec); + } +} +#endif // __FreeBSD__ #endif #endif // _WIN32 } ___ 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)
https://github.com/emaste closed 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)
github-actions[bot] wrote: @arrowd Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! 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][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
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/2] [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] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)
emaste wrote: @zxombie fyi https://github.com/llvm/llvm-project/pull/85058 ___ 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] Fix some concurrent event tests (PR #84155)
https://github.com/emaste approved this pull request. https://github.com/llvm/llvm-project/pull/84155 ___ 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] Fix some concurrent event tests (PR #84155)
emaste wrote: Yes I think it's likely fixed. I'll give it a try on my FreeBSD laptop shortly. https://github.com/llvm/llvm-project/pull/84155 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add FreeBSD kernel coredump matching check. (PR #80785)
emaste wrote: > However, for minimal dump, the build-id section won't loaded because minimal > dump only dump the used memory by kernel. If we fall back to no-UUID-found in that case and don't require that it matches this is still an improvement, yeah? https://github.com/llvm/llvm-project/pull/80785 ___ 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)
https://github.com/emaste approved this pull request. 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][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (PR #84024)
https://github.com/emaste approved this pull request. 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] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
dwblaikie wrote: does this cause multiple (an open ended amount?) of declarations for a type to be created if the type declarations from multiple CUs are encountered separately? Or still only one due to the extra map? 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] Account for spsr being 8 bytes in newer versions (PR #84032)
emaste wrote: CC @zxombie 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)
@@ -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 emaste wrote: This will be correct when the host running the debugger is the same as the target (or at least the same version) but we should handle this based on target version 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][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
ZequanWu wrote: > does this cause multiple (an open ended amount?) of declarations for a type > to be created if the type declarations from multiple CUs are encountered > separately? Or still only one due to the extra map? This only creates one even if type declarations are from different CUs. The definition DIE lookup mechanism is the same as before, via manual index, which is able to search cross CUs. We check if a type is created before using the `UniqueDWARFASTTypeMap` as before: For C++, unique type is identified by full qualified name + byte size. For other languages, it's base name + byte size + declaration location. 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] 4cbe760 - [LLDB][ELF] Fix section unification to not just use names. (#90099)
Author: Alastair Houghton Date: 2024-05-01T09:17:03-07:00 New Revision: 4cbe7607c75486dd17a048a45dd8c72c3dbf7e62 URL: https://github.com/llvm/llvm-project/commit/4cbe7607c75486dd17a048a45dd8c72c3dbf7e62 DIFF: https://github.com/llvm/llvm-project/commit/4cbe7607c75486dd17a048a45dd8c72c3dbf7e62.diff LOG: [LLDB][ELF] Fix section unification to not just use names. (#90099) Section unification cannot just use names, because it's valid for ELF binaries to have multiple sections with the same name. We should check other section properties too. Fixes #88001. rdar://124467787 Added: lldb/test/Shell/ObjectFile/ELF/two-text-sections.yaml Modified: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Removed: diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 0d95a1c12bde35d..16f6d2e884b5771 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1854,6 +1854,39 @@ class VMAddressProvider { }; } +// We have to do this because ELF doesn't have section IDs, and also +// doesn't require section names to be unique. (We use the section index +// for section IDs, but that isn't guaranteed to be the same in separate +// debug images.) +static SectionSP FindMatchingSection(const SectionList §ion_list, + SectionSP section) { + SectionSP sect_sp; + + addr_t vm_addr = section->GetFileAddress(); + ConstString name = section->GetName(); + offset_t byte_size = section->GetByteSize(); + bool thread_specific = section->IsThreadSpecific(); + uint32_t permissions = section->GetPermissions(); + uint32_t alignment = section->GetLog2Align(); + + for (auto sect : section_list) { +if (sect->GetName() == name && +sect->IsThreadSpecific() == thread_specific && +sect->GetPermissions() == permissions && +sect->GetByteSize() == byte_size && sect->GetFileAddress() == vm_addr && +sect->GetLog2Align() == alignment) { + sect_sp = sect; + break; +} else { + sect_sp = FindMatchingSection(sect->GetChildren(), section); + if (sect_sp) +break; +} + } + + return sect_sp; +} + void ObjectFileELF::CreateSections(SectionList &unified_section_list) { if (m_sections_up) return; @@ -2067,10 +2100,12 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, SectionList *module_section_list = module_sp ? module_sp->GetSectionList() : nullptr; - // Local cache to avoid doing a FindSectionByName for each symbol. The "const - // char*" key must came from a ConstString object so they can be compared by - // pointer - std::unordered_map section_name_to_section; + // We might have debug information in a separate object, in which case + // we need to map the sections from that object to the sections in the + // main object during symbol lookup. If we had to compare the sections + // for every single symbol, that would be expensive, so this map is + // used to accelerate the process. + std::unordered_map section_map; unsigned i; for (i = 0; i < num_symbols; ++i) { @@ -2275,14 +2310,14 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, if (symbol_section_sp && module_section_list && module_section_list != section_list) { - ConstString sect_name = symbol_section_sp->GetName(); - auto section_it = section_name_to_section.find(sect_name.GetCString()); - if (section_it == section_name_to_section.end()) -section_it = -section_name_to_section -.emplace(sect_name.GetCString(), - module_section_list->FindSectionByName(sect_name)) -.first; + auto section_it = section_map.find(symbol_section_sp); + if (section_it == section_map.end()) { +section_it = section_map + .emplace(symbol_section_sp, + FindMatchingSection(*module_section_list, + symbol_section_sp)) + .first; + } if (section_it->second) symbol_section_sp = section_it->second; } diff --git a/lldb/test/Shell/ObjectFile/ELF/two-text-sections.yaml b/lldb/test/Shell/ObjectFile/ELF/two-text-sections.yaml new file mode 100644 index 000..8b2fd47df1a1faf --- /dev/null +++ b/lldb/test/Shell/ObjectFile/ELF/two-text-sections.yaml @@ -0,0 +1,48 @@ +# Test handling of object files that have duplicate sections. This is legal, +# according to the System V ABI (Edition 4.1); see 4-20 where it says: +# +# Section names with a dot (.) prefix are reserved for the system, +# although applications may use these sections if their existing +# meanings are satisfactory. ... **An object f
[Lldb-commits] [lldb] [LLDB][ELF] Fix section unification to not just use names. (PR #90099)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/90099 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Install generated API headers into LLDB.framework (PR #90666)
@@ -8,6 +8,12 @@ set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include") set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +if (LLDB_BUILT_STANDALONE) + set(LLDB_OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}) +else() + set(LLDB_OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}/tools/lldb) +endif() bulbazord wrote: Hmm, thinking about this further that does make sense. CMake will create a subdirectory in your build tree for lldb at `$BUILD_DIR/tools/lldb` and will set `CMAKE_CURRENT_BINARY_DIR` to that subdirectory in that context. For standalone builds, LLDB is its own standalone project, so it gets set to `$BUILD_DIR` in that case. I think you can just set `LLDB_OBJ_DIR` to `${CMAKE_CURRENT_BINARY_DIR}` and call it a day. https://github.com/llvm/llvm-project/pull/90666 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/90753 Use a Python script to generate SBLanguages.h instead of piggybacking on LLDB TableGen. This addresses Nico Weber's post-commit feedback. >From 5f66f7b0bf2add28eebdfefd2ae9459f8548a1b4 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 1 May 2024 10:36:51 -0700 Subject: [PATCH] [lldb] Use Python script to generate SBLanguages.h Use a Python script to generate SBLanguages.h instead of piggybacking on LLDB TableGen. This addresses Nico Weber's post-commit feedback. --- lldb/scripts/generate-sbapi-dwarf-enum.py | 65 + lldb/source/API/CMakeLists.txt | 18 -- lldb/utils/TableGen/CMakeLists.txt | 1 - lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp | 67 -- lldb/utils/TableGen/LLDBTableGen.cpp | 8 --- 5 files changed, 79 insertions(+), 80 deletions(-) create mode 100755 lldb/scripts/generate-sbapi-dwarf-enum.py delete mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py new file mode 100755 index 00..c4252223430ed6 --- /dev/null +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) +if not match: +continue +f.write(f" /// {match.group(4)}.\n") +f.write(f" eLanguageName{match.group(3)} = {match.group(2)},\n") + +# Emit the footer +f.write(FOOTER) + + +def main(): +parser = argparse.ArgumentParser() +parser.add_argument("--output", "-o") +parser.add_argument("input") +args = parser.parse_args() + +emit_enum(args.input, args.output) + + +if __name__ == "__main__": +main() diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index ad960403ae70bf..a64c0d4a333425 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( + lldb-sbapi-dwarf-enums + "${Python3_EXECUTABLE}" + ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py + ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + -o ${sb_languages_file} + BYPRODUCTS ${sb_languages_file} + DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} +) add_lldb_library(liblldb SHARED ${option_framework} SBAddress.cpp @@ -106,7 +116,7 @@ add_lldb_library(liblldb SHARED ${option_framework} DEPENDS lldb-sbapi-dwarf-enums - + LINK_LIBS lldbBreakpoint lldbCore diff --git a/lldb/utils/TableGen/CMakeLists.txt b/lldb/utils/TableGen/CMakeLists.txt index 68547fe13e1aeb..47a6400b4287e2 100644 --- a/lldb/utils/TableGen/CMakeLists.txt +++ b/lldb/utils/TableGen/CMakeLists.txt @@ -10,7 +10,6 @@ if (NOT DEFINED LLDB_TABLEGEN_EXE) add_tablegen(lldb-tblgen LLDB LLDBOptionDefEmitter.cpp LLDBPropertyDefEmitter.cpp - LLDBSBAPIDWARFEnum.cpp LLDBTableGen.cpp LLDBTableGenUtils.cpp ) diff --git a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp b/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp deleted file mode 100644 index 084284ed6aa82a..00 --- a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===- LLDBPropertyDefEmitter.cpp --
[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)
JDevlieghere wrote: https://github.com/llvm/llvm-project/pull/90753 https://github.com/llvm/llvm-project/pull/89981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Use a Python script to generate SBLanguages.h instead of piggybacking on LLDB TableGen. This addresses Nico Weber's post-commit feedback. --- Full diff: https://github.com/llvm/llvm-project/pull/90753.diff 5 Files Affected: - (added) lldb/scripts/generate-sbapi-dwarf-enum.py (+65) - (modified) lldb/source/API/CMakeLists.txt (+14-4) - (modified) lldb/utils/TableGen/CMakeLists.txt (-1) - (removed) lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp (-67) - (modified) lldb/utils/TableGen/LLDBTableGen.cpp (-8) ``diff diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py new file mode 100755 index 00..c4252223430ed6 --- /dev/null +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) +if not match: +continue +f.write(f" /// {match.group(4)}.\n") +f.write(f" eLanguageName{match.group(3)} = {match.group(2)},\n") + +# Emit the footer +f.write(FOOTER) + + +def main(): +parser = argparse.ArgumentParser() +parser.add_argument("--output", "-o") +parser.add_argument("input") +args = parser.parse_args() + +emit_enum(args.input, args.output) + + +if __name__ == "__main__": +main() diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index ad960403ae70bf..a64c0d4a333425 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( + lldb-sbapi-dwarf-enums + "${Python3_EXECUTABLE}" + ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py + ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + -o ${sb_languages_file} + BYPRODUCTS ${sb_languages_file} + DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} +) add_lldb_library(liblldb SHARED ${option_framework} SBAddress.cpp @@ -106,7 +116,7 @@ add_lldb_library(liblldb SHARED ${option_framework} DEPENDS lldb-sbapi-dwarf-enums - + LINK_LIBS lldbBreakpoint lldbCore diff --git a/lldb/utils/TableGen/CMakeLists.txt b/lldb/utils/TableGen/CMakeLists.txt index 68547fe13e1aeb..47a6400b4287e2 100644 --- a/lldb/utils/TableGen/CMakeLists.txt +++ b/lldb/utils/TableGen/CMakeLists.txt @@ -10,7 +10,6 @@ if (NOT DEFINED LLDB_TABLEGEN_EXE) add_tablegen(lldb-tblgen LLDB LLDBOptionDefEmitter.cpp LLDBPropertyDefEmitter.cpp - LLDBSBAPIDWARFEnum.cpp LLDBTableGen.cpp LLDBTableGenUtils.cpp ) diff --git a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp b/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp deleted file mode 100644 index 084284ed6aa82a..00 --- a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===- LLDBPropertyDefEmitter.cpp -===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// -// -// Produce the list of source languages header file fragment for the SBAPI. -// -//===-
[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)
dwblaikie wrote: Hmm - but the byte size wouldn't be known from only a declaration, right? so how'd that key work between a declaration and a definition? 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] Use Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) kastiglione wrote: since the regex is anchored to the start (`^`), this should probably be match (in which case you can remove the `^` if you want) https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) +if not match: +continue +f.write(f" /// {match.group(4)}.\n") +f.write(f" eLanguageName{match.group(3)} = {match.group(2)},\n") kastiglione wrote: these would benefit from using named captures, ex: ```suggestion f.write(f" /// {match.group("whatever_group_4_is")}.\n") f.write(f" eLanguageName{match.group("name")} = {match.group("value")},\n") ``` https://github.com/llvm/llvm-project/pull/90753 ___ 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)
ZequanWu wrote: > Hmm - but the byte size wouldn't be known from only a declaration, right? so > how'd that key work between a declaration and a definition? For declaration and definition DIEs, we just look at the name. Byte size and declaration locations are only used as extra info to differentiate two definition DIEs. See the comment in: https://github.com/llvm/llvm-project/pull/90663/files#diff-82e596d532f38e5212da4007f8ffda731ac8c948ab98eaac21f30fc96ca62d30R24-R32 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] Use Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') kastiglione wrote: ```suggestion REGEX = re.compile(r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P.*)",.*\)') ``` https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/90753 >From 5f66f7b0bf2add28eebdfefd2ae9459f8548a1b4 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 1 May 2024 10:36:51 -0700 Subject: [PATCH 1/2] [lldb] Use Python script to generate SBLanguages.h Use a Python script to generate SBLanguages.h instead of piggybacking on LLDB TableGen. This addresses Nico Weber's post-commit feedback. --- lldb/scripts/generate-sbapi-dwarf-enum.py | 65 + lldb/source/API/CMakeLists.txt | 18 -- lldb/utils/TableGen/CMakeLists.txt | 1 - lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp | 67 -- lldb/utils/TableGen/LLDBTableGen.cpp | 8 --- 5 files changed, 79 insertions(+), 80 deletions(-) create mode 100755 lldb/scripts/generate-sbapi-dwarf-enum.py delete mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py new file mode 100755 index 00..c4252223430ed6 --- /dev/null +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) +if not match: +continue +f.write(f" /// {match.group(4)}.\n") +f.write(f" eLanguageName{match.group(3)} = {match.group(2)},\n") + +# Emit the footer +f.write(FOOTER) + + +def main(): +parser = argparse.ArgumentParser() +parser.add_argument("--output", "-o") +parser.add_argument("input") +args = parser.parse_args() + +emit_enum(args.input, args.output) + + +if __name__ == "__main__": +main() diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index ad960403ae70bf..a64c0d4a333425 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( + lldb-sbapi-dwarf-enums + "${Python3_EXECUTABLE}" + ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py + ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + -o ${sb_languages_file} + BYPRODUCTS ${sb_languages_file} + DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} +) add_lldb_library(liblldb SHARED ${option_framework} SBAddress.cpp @@ -106,7 +116,7 @@ add_lldb_library(liblldb SHARED ${option_framework} DEPENDS lldb-sbapi-dwarf-enums - + LINK_LIBS lldbBreakpoint lldbCore diff --git a/lldb/utils/TableGen/CMakeLists.txt b/lldb/utils/TableGen/CMakeLists.txt index 68547fe13e1aeb..47a6400b4287e2 100644 --- a/lldb/utils/TableGen/CMakeLists.txt +++ b/lldb/utils/TableGen/CMakeLists.txt @@ -10,7 +10,6 @@ if (NOT DEFINED LLDB_TABLEGEN_EXE) add_tablegen(lldb-tblgen LLDB LLDBOptionDefEmitter.cpp LLDBPropertyDefEmitter.cpp - LLDBSBAPIDWARFEnum.cpp LLDBTableGen.cpp LLDBTableGenUtils.cpp ) diff --git a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp b/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp deleted file mode 100644 index 084284ed6aa82a..00 --- a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===- LLDBPropertyDefEmitter.cpp -===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile( +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P.*)",.*\)' kastiglione wrote: looks like you have comment and name swapped https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/adrian-prantl approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/adrian-prantl edited https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile( +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P.*)",.*\)' adrian-prantl wrote: Also is it possible to make the third one `P[^"]`? That would be safer. https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/adrian-prantl requested changes to this pull request. https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Install generated API headers into LLDB.framework (PR #90666)
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/90666 >From d1b444aea800ef4f5950400728e00838dfd05fba Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 30 Apr 2024 13:59:39 -0700 Subject: [PATCH] Install generated API headers into LLDB.framework --- lldb/cmake/modules/LLDBConfig.cmake | 2 ++ lldb/cmake/modules/LLDBFramework.cmake | 2 ++ lldb/include/lldb/API/LLDB.h| 1 + lldb/packages/Python/lldbsuite/test/builders/builder.py | 4 lldb/packages/Python/lldbsuite/test/make/Makefile.rules | 5 +++-- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index a758261073ac57..5e897257bce75e 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -8,6 +8,8 @@ set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include") set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(LLDB_OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}) + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite the makefiles " diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index f915839f6b45a5..df2f8ddf54a3d5 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -71,6 +71,7 @@ endif() # At configuration time, collect headers for the framework bundle and copy them # into a staging directory. Later we can copy over the entire folder. file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) +set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h) file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) list(REMOVE_ITEM root_public_headers ${root_private_headers}) @@ -80,6 +81,7 @@ find_program(unifdef_EXECUTABLE unifdef) set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) foreach(header ${public_headers} +${generated_public_headers} ${root_public_headers}) get_filename_component(basename ${header} NAME) diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index c83eb92fcfb30a..b256544326a224 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -40,6 +40,7 @@ #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBLanguages.h" #include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 823a982e674380..21ea3530e24fcb 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -148,6 +148,9 @@ def getLibCxxArgs(self): return libcpp_args return [] +def getLLDBObjRoot(self): +return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)] + def _getDebugInfoArgs(self, debug_info): if debug_info is None: return [] @@ -185,6 +188,7 @@ def getBuildCommand( self.getSDKRootSpec(), self.getModuleCacheSpec(), self.getLibCxxArgs(), +self.getLLDBObjRoot(), self.getCmdLine(dictionary), ] command = list(itertools.chain(*command_parts)) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index bfd249ccd43f2e..bd8eea3d6f5a04 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -238,10 +238,11 @@ ifeq "$(OS)" "Darwin" endif ifeq "$(OS)" "Darwin" - CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include + CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) else - CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include + CFLAGS += $(ARCHFLAG)$(ARCH) endif +CFLAGS += -I$(LLDB_BASE_DIR)include -I$(LLDB_OBJ_ROOT)/include CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR) ___ 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)
medismailben wrote: I think you forgot to include the implementation. 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] Install generated API headers into LLDB.framework (PR #90666)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/90666 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Install generated API headers into LLDB.framework (PR #90666)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/90666 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Install generated API headers into LLDB.framework (PR #90666)
@@ -8,6 +8,8 @@ set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include") set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) JDevlieghere wrote: Remove the newline. https://github.com/llvm/llvm-project/pull/90666 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Install generated API headers into LLDB.framework (PR #90666)
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/90666 >From 88db878450f40e450965629412d1ad5c303249e9 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 30 Apr 2024 13:59:39 -0700 Subject: [PATCH] Install generated API headers into LLDB.framework --- lldb/cmake/modules/LLDBConfig.cmake | 1 + lldb/cmake/modules/LLDBFramework.cmake | 2 ++ lldb/include/lldb/API/LLDB.h| 1 + lldb/packages/Python/lldbsuite/test/builders/builder.py | 4 lldb/packages/Python/lldbsuite/test/make/Makefile.rules | 5 +++-- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index a758261073ac57..3c6223b015bb1f 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -7,6 +7,7 @@ set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include") set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(LLDB_OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) message(FATAL_ERROR diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index f915839f6b45a5..df2f8ddf54a3d5 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -71,6 +71,7 @@ endif() # At configuration time, collect headers for the framework bundle and copy them # into a staging directory. Later we can copy over the entire folder. file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) +set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h) file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) list(REMOVE_ITEM root_public_headers ${root_private_headers}) @@ -80,6 +81,7 @@ find_program(unifdef_EXECUTABLE unifdef) set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) foreach(header ${public_headers} +${generated_public_headers} ${root_public_headers}) get_filename_component(basename ${header} NAME) diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index c83eb92fcfb30a..b256544326a224 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -40,6 +40,7 @@ #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBLanguages.h" #include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 823a982e674380..21ea3530e24fcb 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -148,6 +148,9 @@ def getLibCxxArgs(self): return libcpp_args return [] +def getLLDBObjRoot(self): +return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)] + def _getDebugInfoArgs(self, debug_info): if debug_info is None: return [] @@ -185,6 +188,7 @@ def getBuildCommand( self.getSDKRootSpec(), self.getModuleCacheSpec(), self.getLibCxxArgs(), +self.getLLDBObjRoot(), self.getCmdLine(dictionary), ] command = list(itertools.chain(*command_parts)) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index bfd249ccd43f2e..bd8eea3d6f5a04 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -238,10 +238,11 @@ ifeq "$(OS)" "Darwin" endif ifeq "$(OS)" "Darwin" - CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include + CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) else - CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include + CFLAGS += $(ARCHFLAG)$(ARCH) endif +CFLAGS += -I$(LLDB_BASE_DIR)include -I$(LLDB_OBJ_ROOT)/include CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/90753 >From 5f66f7b0bf2add28eebdfefd2ae9459f8548a1b4 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 1 May 2024 10:36:51 -0700 Subject: [PATCH 1/3] [lldb] Use Python script to generate SBLanguages.h Use a Python script to generate SBLanguages.h instead of piggybacking on LLDB TableGen. This addresses Nico Weber's post-commit feedback. --- lldb/scripts/generate-sbapi-dwarf-enum.py | 65 + lldb/source/API/CMakeLists.txt | 18 -- lldb/utils/TableGen/CMakeLists.txt | 1 - lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp | 67 -- lldb/utils/TableGen/LLDBTableGen.cpp | 8 --- 5 files changed, 79 insertions(+), 80 deletions(-) create mode 100755 lldb/scripts/generate-sbapi-dwarf-enum.py delete mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py new file mode 100755 index 00..c4252223430ed6 --- /dev/null +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile(r'(^ *HANDLE_DW_LNAME *\( *([^,]+), ([^,]+), )"(.*)",.*\).*') + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.search(line) +if not match: +continue +f.write(f" /// {match.group(4)}.\n") +f.write(f" eLanguageName{match.group(3)} = {match.group(2)},\n") + +# Emit the footer +f.write(FOOTER) + + +def main(): +parser = argparse.ArgumentParser() +parser.add_argument("--output", "-o") +parser.add_argument("input") +args = parser.parse_args() + +emit_enum(args.input, args.output) + + +if __name__ == "__main__": +main() diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index ad960403ae70bf..a64c0d4a333425 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( + lldb-sbapi-dwarf-enums + "${Python3_EXECUTABLE}" + ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py + ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + -o ${sb_languages_file} + BYPRODUCTS ${sb_languages_file} + DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} +) add_lldb_library(liblldb SHARED ${option_framework} SBAddress.cpp @@ -106,7 +116,7 @@ add_lldb_library(liblldb SHARED ${option_framework} DEPENDS lldb-sbapi-dwarf-enums - + LINK_LIBS lldbBreakpoint lldbCore diff --git a/lldb/utils/TableGen/CMakeLists.txt b/lldb/utils/TableGen/CMakeLists.txt index 68547fe13e1aeb..47a6400b4287e2 100644 --- a/lldb/utils/TableGen/CMakeLists.txt +++ b/lldb/utils/TableGen/CMakeLists.txt @@ -10,7 +10,6 @@ if (NOT DEFINED LLDB_TABLEGEN_EXE) add_tablegen(lldb-tblgen LLDB LLDBOptionDefEmitter.cpp LLDBPropertyDefEmitter.cpp - LLDBSBAPIDWARFEnum.cpp LLDBTableGen.cpp LLDBTableGenUtils.cpp ) diff --git a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp b/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp deleted file mode 100644 index 084284ed6aa82a..00 --- a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===- LLDBPropertyDefEmitter.cpp -===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://
[Lldb-commits] [lldb] [lldb][Docs] Remove .txt copy of tutorial (PR #90585)
https://github.com/JDevlieghere approved this pull request. 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] [lldb][Docs] Use proper LLDB/GDB project branding in tutorial (PR #90712)
https://github.com/JDevlieghere approved this pull request. Thanks! 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] b88d211 - Install generated API headers into LLDB.framework (#90666)
Author: Adrian Prantl Date: 2024-05-01T12:47:43-07:00 New Revision: b88d21127f31c04139281de49dc7be7671bf47d8 URL: https://github.com/llvm/llvm-project/commit/b88d21127f31c04139281de49dc7be7671bf47d8 DIFF: https://github.com/llvm/llvm-project/commit/b88d21127f31c04139281de49dc7be7671bf47d8.diff LOG: Install generated API headers into LLDB.framework (#90666) Added: Modified: lldb/cmake/modules/LLDBConfig.cmake lldb/cmake/modules/LLDBFramework.cmake lldb/include/lldb/API/LLDB.h lldb/packages/Python/lldbsuite/test/builders/builder.py lldb/packages/Python/lldbsuite/test/make/Makefile.rules Removed: diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index a758261073ac57..3c6223b015bb1f 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -7,6 +7,7 @@ set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include") set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(LLDB_OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) message(FATAL_ERROR diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index f915839f6b45a5..df2f8ddf54a3d5 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -71,6 +71,7 @@ endif() # At configuration time, collect headers for the framework bundle and copy them # into a staging directory. Later we can copy over the entire folder. file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) +set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h) file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) list(REMOVE_ITEM root_public_headers ${root_private_headers}) @@ -80,6 +81,7 @@ find_program(unifdef_EXECUTABLE unifdef) set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) foreach(header ${public_headers} +${generated_public_headers} ${root_public_headers}) get_filename_component(basename ${header} NAME) diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index c83eb92fcfb30a..b256544326a224 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -40,6 +40,7 @@ #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBLanguages.h" #include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 823a982e674380..21ea3530e24fcb 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -148,6 +148,9 @@ def getLibCxxArgs(self): return libcpp_args return [] +def getLLDBObjRoot(self): +return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)] + def _getDebugInfoArgs(self, debug_info): if debug_info is None: return [] @@ -185,6 +188,7 @@ def getBuildCommand( self.getSDKRootSpec(), self.getModuleCacheSpec(), self.getLibCxxArgs(), +self.getLLDBObjRoot(), self.getCmdLine(dictionary), ] command = list(itertools.chain(*command_parts)) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index bfd249ccd43f2e..bd8eea3d6f5a04 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -238,10 +238,11 @@ ifeq "$(OS)" "Darwin" endif ifeq "$(OS)" "Darwin" - CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include + CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) else - CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include + CFLAGS += $(ARCHFLAG)$(ARCH) endif +CFLAGS += -I$(LLDB_BASE_DIR)include -I$(LLDB_OBJ_ROOT)/include CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Install generated API headers into LLDB.framework (PR #90666)
https://github.com/adrian-prantl closed https://github.com/llvm/llvm-project/pull/90666 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c4e8e2c - Skip timing-sensitive test under ASAN
Author: Adrian Prantl Date: 2024-05-01T12:55:36-07:00 New Revision: c4e8e2c67bbfff2d1b23210c375c173aa05e3848 URL: https://github.com/llvm/llvm-project/commit/c4e8e2c67bbfff2d1b23210c375c173aa05e3848 DIFF: https://github.com/llvm/llvm-project/commit/c4e8e2c67bbfff2d1b23210c375c173aa05e3848.diff LOG: Skip timing-sensitive test under ASAN Added: Modified: lldb/test/API/driver/quit_speed/TestQuitWithProcess.py Removed: diff --git a/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py b/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py index c75ac977ea2094..5cfcf5d69fd2a5 100644 --- a/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py +++ b/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py @@ -12,6 +12,7 @@ class DriverQuitSpeedTest(PExpectTest): source = "main.c" +@skipIfAsan def test_run_quit(self): """Test that the lldb driver's batch mode works correctly.""" import pexpect @@ -31,4 +32,4 @@ def test_run_quit(self): print("Got launch message") child.sendline("quit") print("sent quit") -child.expect(pexpect.EOF, timeout=60) +child.expect(pexpect.EOF, timeout=15) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] dcbf0fc - [lldb] Use Python script to generate SBLanguages.h (#90753)
Author: Jonas Devlieghere Date: 2024-05-01T13:02:47-07:00 New Revision: dcbf0fcd0d5572f7001ebdd3bda6062593ec172b URL: https://github.com/llvm/llvm-project/commit/dcbf0fcd0d5572f7001ebdd3bda6062593ec172b DIFF: https://github.com/llvm/llvm-project/commit/dcbf0fcd0d5572f7001ebdd3bda6062593ec172b.diff LOG: [lldb] Use Python script to generate SBLanguages.h (#90753) Use a Python script to generate SBLanguages.h instead of piggybacking on LLDB TableGen. This addresses Nico Weber's post-commit feedback. Added: lldb/scripts/generate-sbapi-dwarf-enum.py Modified: lldb/source/API/CMakeLists.txt lldb/utils/TableGen/CMakeLists.txt lldb/utils/TableGen/LLDBTableGen.cpp Removed: lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py new file mode 100755 index 00..5eeb8264a768ee --- /dev/null +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile( +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^"]+), "(?P.*)",.*\)' +) + + +def emit_enum(input, output): +# Read the input and break it up by lines. +lines = [] +with open(input, "r") as f: +lines = f.readlines() + +# Write the output. +with open(output, "w") as f: +# Emit the header. +f.write(HEADER) + +# Emit the enum values. +for line in lines: +match = REGEX.match(line) +if not match: +continue +f.write(f" /// {match.group('comment')}.\n") +f.write(f" eLanguageName{match.group('name')} = {match.group('value')},\n") + +# Emit the footer +f.write(FOOTER) + + +def main(): +parser = argparse.ArgumentParser() +parser.add_argument("--output", "-o") +parser.add_argument("input") +args = parser.parse_args() + +emit_enum(args.input, args.output) + + +if __name__ == "__main__": +main() diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index ad960403ae70bf..a64c0d4a333425 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -20,9 +20,19 @@ if(LLDB_ENABLE_LUA) set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) endif() -lldb_tablegen(../../include/lldb/API/SBLanguages.h -gen-lldb-sbapi-dwarf-enum - SOURCE ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def - TARGET lldb-sbapi-dwarf-enums) +# Target to generate SBLanguages.h from Dwarf.def. +set(sb_languages_file + ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h) +add_custom_target( + lldb-sbapi-dwarf-enums + "${Python3_EXECUTABLE}" + ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py + ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + -o ${sb_languages_file} + BYPRODUCTS ${sb_languages_file} + DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def + WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR} +) add_lldb_library(liblldb SHARED ${option_framework} SBAddress.cpp @@ -106,7 +116,7 @@ add_lldb_library(liblldb SHARED ${option_framework} DEPENDS lldb-sbapi-dwarf-enums - + LINK_LIBS lldbBreakpoint lldbCore diff --git a/lldb/utils/TableGen/CMakeLists.txt b/lldb/utils/TableGen/CMakeLists.txt index 68547fe13e1aeb..47a6400b4287e2 100644 --- a/lldb/utils/TableGen/CMakeLists.txt +++ b/lldb/utils/TableGen/CMakeLists.txt @@ -10,7 +10,6 @@ if (NOT DEFINED LLDB_TABLEGEN_EXE) add_tablegen(lldb-tblgen LLDB LLDBOptionDefEmitter.cpp LLDBPropertyDefEmitter.cpp - LLDBSBAPIDWARFEnum.cpp LLDBTableGen.cpp LLDBTableGenUtils.cpp ) diff --git a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp b/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp deleted file mode 100644 index 084284ed6aa82a..00 --- a/lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===- LLDBPropertyDefEmitter.cpp -===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use Python script to generate SBLanguages.h (PR #90753)
@@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import argparse +import re + +HEADER = """\ +//===-- SBLanguages.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBLANGUAGE_H +#define LLDB_API_SBLANGUAGE_H +/// Used by \\ref SBExpressionOptions. +/// These enumerations use the same language enumerations as the DWARF +/// specification for ease of use and consistency. +enum SBSourceLanguageName : uint16_t { +""" + +FOOTER = """\ +}; + +#endif +""" + +REGEX = re.compile( +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^"]+), "(?P.*)",.*\)' kastiglione wrote: to combine my feedback with Adrian's: ```python r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^,]+), "(?P[^"]*)",.*\)' ``` https://github.com/llvm/llvm-project/pull/90753 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fa9e96a - Skip pexpect test under ASAN
Author: Adrian Prantl Date: 2024-05-01T13:11:51-07:00 New Revision: fa9e96a2e55226b1f9f9744f42ac5e925297f819 URL: https://github.com/llvm/llvm-project/commit/fa9e96a2e55226b1f9f9744f42ac5e925297f819 DIFF: https://github.com/llvm/llvm-project/commit/fa9e96a2e55226b1f9f9744f42ac5e925297f819.diff LOG: Skip pexpect test under ASAN Added: Modified: lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py Removed: diff --git a/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py b/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py index f6bda16560b962..a7c749e1528b0f 100644 --- a/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py +++ b/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py @@ -117,6 +117,7 @@ def do_test(self, expect_regexes=None, settings_commands=None): self.runCmd("process continue") self.expect(expect_regexes) +@skipIfAsan # avoid dealing with pexpect timeout flakyness on bots @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) @skipUnlessDarwin @skipIfRemote # this test is currently written using lldb commands & assumes running on local system @@ -132,6 +133,7 @@ def test_nslog_output_is_displayed(self): self.assertGreater(len(self.child.match.groups()), 0) self.assertEqual("This is a message from NSLog", self.child.match.group(1)) +@skipIfAsan # avoid dealing with pexpect timeout flakyness on bots @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) @skipUnlessDarwin @skipIfRemote # this test is currently written using lldb commands & assumes running on local system ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b8c301f - Fix the regex in the sbapi python script
Author: Adrian Prantl Date: 2024-05-01T13:41:32-07:00 New Revision: b8c301f6e22a6a5ebec4b8870327237eb94c5b15 URL: https://github.com/llvm/llvm-project/commit/b8c301f6e22a6a5ebec4b8870327237eb94c5b15 DIFF: https://github.com/llvm/llvm-project/commit/b8c301f6e22a6a5ebec4b8870327237eb94c5b15.diff LOG: Fix the regex in the sbapi python script Added: Modified: lldb/scripts/generate-sbapi-dwarf-enum.py Removed: diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py b/lldb/scripts/generate-sbapi-dwarf-enum.py index 5eeb8264a768ee..464eb2afff7d6f 100755 --- a/lldb/scripts/generate-sbapi-dwarf-enum.py +++ b/lldb/scripts/generate-sbapi-dwarf-enum.py @@ -27,7 +27,7 @@ """ REGEX = re.compile( -r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P[^"]+), "(?P.*)",.*\)' +r'^ *HANDLE_DW_LNAME *\( *(?P[^,]+), (?P.*), "(?P[^"]+)",.*\)' ) ___ 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)
kevinfrei wrote: Can someone please approve this, so I can yet again see if one of the weird buildbot configurations I don't have the ability to try out fails on these tests? The C++ code really ought to ship, as it fixes some egregious issues that were regressed several months ago (due to lack of tests...) 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] Be conversative about setting highmem address masks (PR #90533)
@@ -1465,6 +1465,20 @@ class Process : public std::enable_shared_from_this, /// platforms where there is a difference (only Arm Thumb at this time). lldb::addr_t FixAnyAddress(lldb::addr_t pc); + /// Retrieve the actual address masks for high memory code/data, + /// without the normal fallbacks of returning the low-memory masks + /// or the user settings. Needed by SBProcess to determine if + /// the high address masks have actually been set, and should + /// be updated when "set all masks" is requested. In most cases, + /// the highmem masks should be left to have LLDB_INVALID_ADDRESS_MASK, + /// unset. + lldb::addr_t GetConcreteHighmemCodeAddressMask() { jasonmolenda wrote: Yeah this is a weird API I almost thought to make it a protected method because the only user should be SBFrame where we need to distinguish between the "currently in-effect high memory mask" and "the current Process mask setting, which may be unset". For the effective high memory mask, if the user hasn't specified a high memory addressable bits setting, and the process doesn't have a mask set, then we are in a "one-mask-for-all-addresses" mode and we return the low memory address mask. 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)
@@ -1465,6 +1465,20 @@ class Process : public std::enable_shared_from_this, /// platforms where there is a difference (only Arm Thumb at this time). lldb::addr_t FixAnyAddress(lldb::addr_t pc); + /// Retrieve the actual address masks for high memory code/data, + /// without the normal fallbacks of returning the low-memory masks + /// or the user settings. Needed by SBProcess to determine if + /// the high address masks have actually been set, and should + /// be updated when "set all masks" is requested. In most cases, + /// the highmem masks should be left to have LLDB_INVALID_ADDRESS_MASK, + /// unset. + lldb::addr_t GetConcreteHighmemCodeAddressMask() { jasonmolenda wrote: I think I also thought about moving to a std::optional for all the masks, but in the SB API I need a way to say "no mask available" and without creating an SBAddressMask object with an IsValid() method, I can't represent that without a magic invalid value. 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] fix step in AArch64 trampoline (PR #90783)
https://github.com/v-bulle created https://github.com/llvm/llvm-project/pull/90783 Detects AArch64 trampolines in order to be able to step in a function through a trampoline on AArch64. >From 12464941c1b11ffad0ff2566642df3d30976a3f9 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 18 Apr 2024 10:39:59 -0700 Subject: [PATCH] [lldb] fix step in AArch64 trampoline --- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 26 --- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 19 +- .../StepIn/Inputs/aarch64_thunk.cc| 15 +++ .../StepIn/step_through-aarch64-thunk.test| 17 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc create mode 100644 lldb/test/Shell/ExecControl/StepIn/step_through-aarch64-thunk.test diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 9fa245fc41d40c..232030268e42c8 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -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_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else if (target_name.consume_front("__AArch64AbsLongThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else { +images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, + target_symbols); + } typedef std::vector AddressVector; AddressVector addrs; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 16f6d2e884b577..1646ee9aa34a61 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2356,13 +2356,30 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, bool symbol_size_valid = symbol.st_size != 0 || symbol.getType() != STT_FUNC; +bool is_trampoline = false; +if (arch.IsValid() && (arch.GetMachine() == llvm::Triple::aarch64)) { + // On AArch64, trampolines are registered as code. + // If we detect a trampoline (which starts with __AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) we register the symbol as a trampoline. This + // way we will be able to detect the trampoline when we step in a function + // and step through the trampoline. + if (symbol_type == eSymbolTypeCode) { +llvm::StringRef trampoline_name = mangled.GetName().GetStringRef(); +if (trampoline_name.starts_with("__AArch64ADRPThunk_") || +trampoline_name.starts_with("__AArch64AbsLongThunk_")) { + symbol_type = eSymbolTypeTrampoline; + is_trampoline = true; +} + } +} + Symbol dc_symbol( i + start_id, // ID is the original symbol table index. mangled, symbol_type,// Type of this symbol is_global, // Is this globally visible? false, // Is this symbol debug info? -false, // Is this symbol a trampoline? +is_trampoline, // Is this symbol a trampoline? false, // Is this symbol artificial? AddressRange(symbol_section_sp, // Section in which this symbol is // defined or null. diff --git a/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc new file mode 100644 index 00..02f3bef32a59a3 --- /dev/null +++ b/lldb/test/Shell/ExecCont
[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Vincent Belliard (v-bulle) Changes Detects AArch64 trampolines in order to be able to step in a function through a trampoline on AArch64. --- Full diff: https://github.com/llvm/llvm-project/pull/90783.diff 4 Files Affected: - (modified) lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (+23-3) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+18-1) - (added) lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc (+15) - (added) lldb/test/Shell/ExecControl/StepIn/step_through-aarch64-thunk.test (+17) ``diff diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 9fa245fc41d40c..232030268e42c8 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -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_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else if (target_name.consume_front("__AArch64AbsLongThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else { +images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, + target_symbols); + } typedef std::vector AddressVector; AddressVector addrs; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 16f6d2e884b577..1646ee9aa34a61 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2356,13 +2356,30 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, bool symbol_size_valid = symbol.st_size != 0 || symbol.getType() != STT_FUNC; +bool is_trampoline = false; +if (arch.IsValid() && (arch.GetMachine() == llvm::Triple::aarch64)) { + // On AArch64, trampolines are registered as code. + // If we detect a trampoline (which starts with __AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) we register the symbol as a trampoline. This + // way we will be able to detect the trampoline when we step in a function + // and step through the trampoline. + if (symbol_type == eSymbolTypeCode) { +llvm::StringRef trampoline_name = mangled.GetName().GetStringRef(); +if (trampoline_name.starts_with("__AArch64ADRPThunk_") || +trampoline_name.starts_with("__AArch64AbsLongThunk_")) { + symbol_type = eSymbolTypeTrampoline; + is_trampoline = true; +} + } +} + Symbol dc_symbol( i + start_id, // ID is the original symbol table index. mangled, symbol_type,// Type of this symbol is_global, // Is this globally visible? false, // Is this symbol debug info? -false, // Is this symbol a trampoline? +is_trampoline, // Is this symbol a trampoline? false, // Is this symbol artificial? AddressRange(symbol_section_sp, // Section in which this symbol is // defined or null. diff --git a/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc new file mode 100644 index 00..02f3bef32a59a3 --- /dev/null +++ b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc @@ -0,0 +1,15 @@ +extern "C" int __attribute__((naked)) __AArch64ADRPThunk_step_here() { +asm ( + "adrp x16, step_here\n" + "add x16, x16, :lo12:step_here\n" + "br x16" +); +} + +
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 1/3] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -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). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 2/3] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcast
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -571,6 +571,17 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + + SBStructuredData data; + if (!IsValid()) +return data; + + data.m_impl_up->SetObjectSP(m_opaque_ptr->GetTranscript()); + return data; medismailben wrote: ```suggestion if (IsValid()) data.m_impl_up->SetObjectSP(m_opaque_ptr->GetTranscript()); return data; ``` 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)
@@ -2044,6 +2050,15 @@ bool CommandInterpreter::HandleCommand(const char *command_line, m_transcript_stream << result.GetOutputData(); m_transcript_stream << result.GetErrorData(); + // Add output and error to the transcript item after splitting lines. In the + // future, other aspects of the command (e.g. perf) can be added, too. + transcript_item->AddItem( + "output", StructuredData::Array::SplitString(result.GetOutputData(), '\n', + -1, false)); + transcript_item->AddItem( + "error", StructuredData::Array::SplitString(result.GetErrorData(), '\n', + -1, false)); medismailben wrote: Looks like you could set the `separator`, `maxSplit` & `keepEmpty` default value to what you have here. 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)
@@ -289,3 +292,35 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { s.Printf("%p", m_object); } + +/// This is the same implementation as `StringRef::split`. Not depending on +/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`. +StructuredData::ArraySP StructuredData::Array::SplitString(llvm::StringRef s, + char separator, + int maxSplit, + bool keepEmpty) { + auto array_sp = std::make_shared(); + + // Count down from MaxSplit. When MaxSplit is -1, this will just split + // "forever". This doesn't support splitting more than 2^31 times + // intentionally; if we ever want that we can make MaxSplit a 64-bit integer + // but that seems unlikely to be useful. medismailben wrote: nit: match variable casing ```suggestion // Count down from `maxSplit`. When `maxSplit` is -1, this will just split // "forever". This doesn't support splitting more than 2^31 times // intentionally; if we ever want that we can make `maxSplit` a 64-bit integer // but that seems unlikely to be useful. ``` 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)
@@ -289,3 +292,35 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { s.Printf("%p", m_object); } + +/// This is the same implementation as `StringRef::split`. Not depending on +/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`. medismailben wrote: This comment should be in the header file 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)
@@ -289,3 +292,35 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { s.Printf("%p", m_object); } + +/// This is the same implementation as `StringRef::split`. Not depending on +/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`. +StructuredData::ArraySP StructuredData::Array::SplitString(llvm::StringRef s, medismailben wrote: Although I see the use of this method in the patch, I think it should either land in a different patch or this patch should at least add some unit tests for 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] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -290,6 +290,9 @@ class StructuredData { void GetDescription(lldb_private::Stream &s) const override; +static ArraySP SplitString(llvm::StringRef s, char separator, int maxSplit, + bool keepEmpty); medismailben wrote: Could you document this method ? It's not clear what `maxSplit` & `keepEmpty` do 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)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 1/4] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -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). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 2/4] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcast
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -289,3 +292,35 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { s.Printf("%p", m_object); } + +/// This is the same implementation as `StringRef::split`. Not depending on +/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`. +StructuredData::ArraySP StructuredData::Array::SplitString(llvm::StringRef s, royitaqi wrote: Thanks for the prompt review. I appreciate it. > or this patch should at least add some unit tests for it. For sure. Let me add (and also other improvements that you have pointed out). 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)
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] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 1/5] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -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). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 2/5] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcast
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
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] Be conversative about setting highmem address masks (PR #90533)
jasonmolenda wrote: > On the face of it > > > When we have an unset high memory address mask, and we are told to set low- > > and high-memory to the same new address mask, maintain the high memory mask > > as unset in Process. The same thing is done with the > > SBProcess::SetAddressMask API when the user specifies > > lldb.eAddressMaskRangeAll. > > Seems to itself be confusing and if you're doing this to address > > > When high memory has a different set of masks, those become active in > > Process and the user can use highmem-virtual-addressable-bits to override > > only the highmem value, if it is wrong. > > You're adding one gotcha to avoid another. > > However, I think the result of the highmem mask being unset is the same as > setting both masks to the same value. Except that `virtual-addressable-bits` > will now effectively apply to both masks, until the user sets _only_ the high > mask to some value. At that point, `highmem-virtual-addressable-bits` must be > used to modify the high mem value. > > Correct? > > So this doesn't actually change anything for an API user that was setting > address masks for high and low all at once. They'll still think both are the > same value, but _internally_, lldb tries high, sees that it's unset, and > falls back to the low mask. I'm not thrilled about where I'm ending up. For the vast majority of our users, the separate address masks for high and low memory will never occur, it's an unusual environment that sets up the MMU this way, and operates in both halves of memory. The goal of this patch is to keep the high memory masks unset (set to LLDB_INVALID_MASK) unless someone sets them to a value distinct from the "low memory" masks. I almost think about changing these masks in Process to be a class which holds either {code, data} or {low code, low data, high code, high data} internally, with methods to get/set the masks and the requirement that high and low be set simultaneously when they're both going to be specified so we can detect if it's genuinely a split-address space situation. 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] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 created https://github.com/llvm/llvm-project/pull/90799 While adding a UI feature in VSCode to toggle hex/dec in variables view window. I noticed that it does not work after second toggle. Then I noticed that there is a bug that we only explicitly set hex format not reset back to default during further toggle. The new test demonstrates the bug. This PR resets the format back to default if not using hex. One complexity is that, we explicitly set registers value format to AddressInfo, which shouldn't be overridden by default or hex settings. >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None:
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
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 cf3c714e4bd7b8a68793f2827080fe3388ae8bb1 2daf4aeaee1ce9062dfa964f3baeef0d7477479c -- lldb/tools/lldb-dap/JSONUtils.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 55feab600a..206d08addf 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -988,7 +988,8 @@ VariableDescription::VariableDescription(lldb::SBValue v, bool format_hex, !raw_display_type_name.empty() ? raw_display_type_name : NO_TYPENAME; // Only format hex/default if there is no existing special format. - if (v.GetFormat() == lldb::eFormatDefault || v.GetFormat() == lldb::eFormatHex) { + if (v.GetFormat() == lldb::eFormatDefault || + v.GetFormat() == lldb::eFormatHex) { if (format_hex) v.SetFormat(lldb::eFormatHex); else `` 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] Fix dap variable value format issue (PR #90799)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r cf3c714e4bd7b8a68793f2827080fe3388ae8bb1...2daf4aeaee1ce9062dfa964f3baeef0d7477479c lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py `` View the diff from darker here. ``diff --- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-01 23:35:18.00 + +++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-01 23:41:05.012150 + @@ -485,11 +485,13 @@ return self.get_scope_variables( "Registers", frameIndex=frameIndex, threadId=threadId ) def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) +locals = self.get_local_variables( +frameIndex=frameIndex, threadId=threadId, is_hex=is_hex +) for local in locals: if "name" in local and local["name"] == name: return local return None @@ -499,17 +501,19 @@ ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): +def get_local_variable_child( +self, name, child_name, frameIndex=0, threadId=None, is_hex=None +): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ -"variables" -] +children = self.request_variables(local["variablesReference"], is_hex=is_hex)[ +"body" +]["variables"] for child in children: if child["name"] == child_name: return child return None @@ -1033,11 +1037,13 @@ thread[key] = thread_stop_info[key] else: self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None, is_hex=None): +def request_variables( +self, variablesReference, start=None, count=None, is_hex=None +): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count --- test/API/tools/lldb-dap/variables/TestDAP_variables.py 2024-05-01 23:35:18.00 + +++ test/API/tools/lldb-dap/variables/TestDAP_variables.py 2024-05-01 23:41:05.291722 + @@ -765,17 +765,17 @@ program = self.getBuildArtifact("a.out") self.build_and_launch(program) source = "main.cpp" breakpoint1_line = line_number(source, "// breakpoint 1") lines = [breakpoint1_line] - + breakpoint_ids = self.set_source_breakpoints(source, lines) self.assertEqual( len(breakpoint_ids), len(lines), "expect correct number of breakpoints" ) self.continue_to_breakpoints(breakpoint_ids) - + # Verify locals value format decimal is_hex = False var_pt_x = self.dap_server.get_local_variable_child("pt", "x", is_hex=is_hex) self.assertEquals(var_pt_x["value"], "11") var_pt_y = self.dap_server.get_local_variable_child("pt", "y", is_hex=is_hex) @@ -785,11 +785,11 @@ is_hex = True var_pt_x = self.dap_server.get_local_variable_child("pt", "x", is_hex=is_hex) self.assertEquals(var_pt_x["value"], "0x000b") var_pt_y = self.dap_server.get_local_variable_child("pt", "y", is_hex=is_hex) self.assertEquals(var_pt_y["value"], "0x0016") - + # Toggle and verify locals value format decimal again is_hex = False var_pt_x = self.dap_server.get_local_variable_child("pt", "x", is_hex=is_hex) self.assertEquals(var_pt_x["value"], "11") var_pt_y = self.dap_server.get_local_variable_child("pt", "y", is_hex=is_hex) `` 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] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90799 >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH 1/2] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count +if is_hex is not None: +args_dict["format"] = {"hex": is_hex} command_dict = { "command": "variables", "type": "request", diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index d886d0776ce58b..51e851abf8a54e 100644 --- a/lldb/test/API/tools/lldb-dap/v
[Lldb-commits] [lldb] LLDB Debuginfod tests and a fix or two (PR #90622)
https://github.com/JDevlieghere approved this pull request. 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] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
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] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 1/7] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -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). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 2/7] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcast
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90799 >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH 1/3] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count +if is_hex is not None: +args_dict["format"] = {"hex": is_hex} command_dict = { "command": "variables", "type": "request", diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index d886d0776ce58b..51e851abf8a54e 100644 --- a/lldb/test/API/tools/lldb-dap/v
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
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] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -289,3 +292,35 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { s.Printf("%p", m_object); } + +/// This is the same implementation as `StringRef::split`. Not depending on +/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`. +StructuredData::ArraySP StructuredData::Array::SplitString(llvm::StringRef s, royitaqi wrote: Done. If I'm not mistaken, the latest push should have addressed all your comments. I'm going through them again just to make sure. 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)
@@ -2044,6 +2050,15 @@ bool CommandInterpreter::HandleCommand(const char *command_line, m_transcript_stream << result.GetOutputData(); m_transcript_stream << result.GetErrorData(); + // Add output and error to the transcript item after splitting lines. In the + // future, other aspects of the command (e.g. perf) can be added, too. + transcript_item->AddItem( + "output", StructuredData::Array::SplitString(result.GetOutputData(), '\n', + -1, false)); + transcript_item->AddItem( + "error", StructuredData::Array::SplitString(result.GetErrorData(), '\n', + -1, false)); royitaqi wrote: The default for `keepEmpty` is `true` in `StringRef::split`, which I think make sense. For consistency, I set the same default values in `Array::SplitString`. However, in these call sites, we need `keepEmpty = false`. So, sadly, no usage of the default values. 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)
https://github.com/royitaqi commented: Updated according to @medismailben 's suggestions. 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)
@@ -290,6 +290,9 @@ class StructuredData { void GetDescription(lldb_private::Stream &s) const override; +static ArraySP SplitString(llvm::StringRef s, char separator, int maxSplit, + bool keepEmpty); royitaqi wrote: Moved. New document is in the header file, explaining all params and return. 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)
@@ -289,3 +292,35 @@ void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { s.Printf("%p", m_object); } + +/// This is the same implementation as `StringRef::split`. Not depending on +/// `StringRef::split` because it will involve a temporary `SmallVectorImpl`. royitaqi wrote: Moved and expanded. 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] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 ready_for_review 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] Fix dap variable value format issue (PR #90799)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jeffreytan81) Changes While adding a UI feature in VSCode to toggle hex/dec in variables view window. I noticed that it does not work after second toggle. Then I noticed that there is a bug that we only explicitly set hex format not reset back to default during further toggle. The new test demonstrates the bug. This PR resets the format back to default if not using hex. One complexity is that, we explicitly set registers value format to AddressInfo, which shouldn't be overridden by default or hex settings. --- Full diff: https://github.com/llvm/llvm-project/pull/90799.diff 3 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py (+21-13) - (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (+40) - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+7-3) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..e2126d67a5fe77 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,28 +486,32 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables( +frameIndex=frameIndex, threadId=threadId, is_hex=is_hex +) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child( +self, name, child_name, frameIndex=0, threadId=None, is_hex=None +): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ -"variables" -] +children = self.request_variables(local["variablesReference"], is_hex=is_hex)[ +"body" +]["variables"] for child in children: if child["name"] == child_name: return child @@ -1035,12 +1039,16 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables( +self, variablesReference, start=None, count=None, is_hex=None +): args_dict = {"variablesReference": variabl
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 1/8] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -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). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 2/8] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcast
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 1/9] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e6..d65f06d676f91f 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -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). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db60..242b3f8f09c48a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 2/9] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bfe..9474c41c0dcedd 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcast
[Lldb-commits] [lldb] Fix dap variable value format issue (PR #90799)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/90799 >From 2daf4aeaee1ce9062dfa964f3baeef0d7477479c Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Wed, 1 May 2024 16:35:18 -0700 Subject: [PATCH 1/4] Fix dap variable value format issue --- .../test/tools/lldb-dap/dap_server.py | 24 ++- .../lldb-dap/variables/TestDAP_variables.py | 40 +++ lldb/tools/lldb-dap/JSONUtils.cpp | 14 --- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5838281bcb1a10..54b8bb77e6ed61 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -448,7 +448,7 @@ def get_completions(self, text, frameId=None): response = self.request_completions(text, frameId) return response["body"]["targets"] -def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): +def get_scope_variables(self, scope_name, frameIndex=0, threadId=None, is_hex=None): stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId) if stackFrame is None: return [] @@ -462,7 +462,7 @@ def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): for scope in frame_scopes: if scope["name"] == scope_name: varRef = scope["variablesReference"] -variables_response = self.request_variables(varRef) +variables_response = self.request_variables(varRef, is_hex=is_hex) if variables_response: if "body" in variables_response: body = variables_response["body"] @@ -476,9 +476,9 @@ def get_global_variables(self, frameIndex=0, threadId=None): "Globals", frameIndex=frameIndex, threadId=threadId ) -def get_local_variables(self, frameIndex=0, threadId=None): +def get_local_variables(self, frameIndex=0, threadId=None, is_hex=None): return self.get_scope_variables( -"Locals", frameIndex=frameIndex, threadId=threadId +"Locals", frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) def get_registers(self, frameIndex=0, threadId=None): @@ -486,26 +486,26 @@ def get_registers(self, frameIndex=0, threadId=None): "Registers", frameIndex=frameIndex, threadId=threadId ) -def get_local_variable(self, name, frameIndex=0, threadId=None): -locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId) +def get_local_variable(self, name, frameIndex=0, threadId=None, is_hex=None): +locals = self.get_local_variables(frameIndex=frameIndex, threadId=threadId, is_hex=is_hex) for local in locals: if "name" in local and local["name"] == name: return local return None -def get_local_variable_value(self, name, frameIndex=0, threadId=None): +def get_local_variable_value(self, name, frameIndex=0, threadId=None, is_hex=None): variable = self.get_local_variable( -name, frameIndex=frameIndex, threadId=threadId +name, frameIndex=frameIndex, threadId=threadId, is_hex=is_hex ) if variable and "value" in variable: return variable["value"] return None -def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None): +def get_local_variable_child(self, name, child_name, frameIndex=0, threadId=None, is_hex=None): local = self.get_local_variable(name, frameIndex, threadId) if local["variablesReference"] == 0: return None -children = self.request_variables(local["variablesReference"])["body"][ +children = self.request_variables(local["variablesReference"], is_hex=is_hex)["body"][ "variables" ] for child in children: @@ -1035,12 +1035,14 @@ def request_threads(self): self.threads = None return response -def request_variables(self, variablesReference, start=None, count=None): +def request_variables(self, variablesReference, start=None, count=None, is_hex=None): args_dict = {"variablesReference": variablesReference} if start is not None: args_dict["start"] = start if count is not None: args_dict["count"] = count +if is_hex is not None: +args_dict["format"] = {"hex": is_hex} command_dict = { "command": "variables", "type": "request", diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index d886d0776ce58b..51e851abf8a54e 100644 --- a/lldb/test/API/tools/lldb-dap/v
[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/90808 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 >From 8145e9faaa52209f9800d473fb75f7cfbd2a1185 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 1 May 2024 18:06:50 -0700 Subject: [PATCH] [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_s
[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes 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 --- Full diff: https://github.com/llvm/llvm-project/pull/90808.diff 2 Files Affected: - (modified) lldb/tools/debugserver/source/MacOSX/MachProcess.mm (+4-4) - (modified) lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp (+19-12) ``diff 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.context.gpr.__pc); #endif -); -#if __has_feature(ptrauth_calls) && defined(__LP64__) +#if defined(DEBUGSERVER_IS_ARM
[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)
https://github.com/jasonmolenda edited 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