[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/119914 >From f6fdfaf4be339a6412019113462b05cbce66c753 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 22 Feb 2024 21:54:07 -0800 Subject: [PATCH 1/3] [lldb] Use the terminal height for paging editline completions Currently, we arbitrarily paginate editline completions to 40 elements. On large terminals, that leaves some real-estate unused. On small terminals, it's pretty annoying to not see the first completions. We can address both issues by using the terminal height for pagination. --- lldb/include/lldb/API/SBDebugger.h| 4 ++ lldb/include/lldb/Core/Debugger.h | 4 ++ lldb/include/lldb/Host/Editline.h | 3 ++ lldb/source/API/SBDebugger.cpp| 13 ++ lldb/source/Core/CoreProperties.td| 4 ++ lldb/source/Core/Debugger.cpp | 28 ++-- lldb/source/Host/common/Editline.cpp | 44 +-- .../API/terminal/TestEditlineCompletions.py | 34 ++ lldb/tools/driver/Driver.cpp | 7 ++- lldb/tools/driver/Driver.h| 2 +- 10 files changed, 124 insertions(+), 19 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 1f42ec3cdc7d51..787bd040dd15bb 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -382,6 +382,10 @@ class LLDB_API SBDebugger { void SetTerminalWidth(uint32_t term_width); + uint32_t GetTerminalHeight() const; + + void SetTerminalHeight(uint32_t term_height); + lldb::user_id_t GetID(); const char *GetPrompt() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 1d5f2fcc20626c..70f4c4216221c6 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -280,6 +280,10 @@ class Debugger : public std::enable_shared_from_this, bool SetTerminalWidth(uint64_t term_width); + uint64_t GetTerminalHeight() const; + + bool SetTerminalHeight(uint64_t term_height); + llvm::StringRef GetPrompt() const; llvm::StringRef GetPromptAnsiPrefix() const; diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index e8e8a6c0d4f67e..26deba38f8471c 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -240,6 +240,8 @@ class Editline { size_t GetTerminalWidth() { return m_terminal_width; } + size_t GetTerminalHeight() { return m_terminal_height; } + private: /// Sets the lowest line number for multi-line editing sessions. A value of /// zero suppresses line number printing in the prompt. @@ -373,6 +375,7 @@ class Editline { std::vector m_input_lines; EditorStatus m_editor_status; int m_terminal_width = 0; + int m_terminal_height = 0; int m_base_line_number = 0; unsigned m_current_line_index = 0; int m_current_line_rows = -1; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 4efec747aacff1..4e6b22492a0d1c 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1405,6 +1405,19 @@ void SBDebugger::SetTerminalWidth(uint32_t term_width) { m_opaque_sp->SetTerminalWidth(term_width); } +uint32_t SBDebugger::GetTerminalHeight() const { + LLDB_INSTRUMENT_VA(this); + + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); +} + +void SBDebugger::SetTerminalHeight(uint32_t term_height) { + LLDB_INSTRUMENT_VA(this, term_height); + + if (m_opaque_sp) +m_opaque_sp->SetTerminalHeight(term_height); +} + const char *SBDebugger::GetPrompt() const { LLDB_INSTRUMENT_VA(this); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index e11aad2660b461..d3816c3070bbc5 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -136,6 +136,10 @@ let Definition = "debugger" in { Global, DefaultUnsignedValue<80>, Desc<"The maximum number of columns to use for displaying text.">; + def TerminalHeight: Property<"term-height", "UInt64">, +Global, +DefaultUnsignedValue<24>, +Desc<"The number of rows used for displaying text.">; def ThreadFormat: Property<"thread-format", "FormatEntity">, Global, DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\
[Lldb-commits] [lldb] 8f151f0 - [lldb] Unify window resizing logic in command line driver
Author: Jonas Devlieghere Date: 2024-12-16T12:22:25-08:00 New Revision: 8f151f0f559c4881a0d206124c64226a82d44a79 URL: https://github.com/llvm/llvm-project/commit/8f151f0f559c4881a0d206124c64226a82d44a79 DIFF: https://github.com/llvm/llvm-project/commit/8f151f0f559c4881a0d206124c64226a82d44a79.diff LOG: [lldb] Unify window resizing logic in command line driver Unify the logic for window resizing in the command line driver. This was prompted by the Windows bot not knowing about the ws_col field. Added: Modified: lldb/tools/driver/Driver.cpp lldb/tools/driver/Driver.h Removed: diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 771663eb7bf0af..15cb0134fec8e0 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -446,14 +446,8 @@ int Driver::MainLoop() { m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor); m_debugger.SetShowInlineDiagnostics(true); - struct winsize window_size; - if ((isatty(STDIN_FILENO) != 0) && - ::ioctl(STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) { -if (window_size.ws_col > 0) - m_debugger.SetTerminalWidth(window_size.ws_col); -if (window_size.ws_row > 0) - m_debugger.SetTerminalHeight(window_size.ws_row); - } + // Set the terminal dimensions. + UpdateWindowSize(); SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter(); @@ -629,21 +623,24 @@ int Driver::MainLoop() { return sb_interpreter.GetQuitStatus(); } -void Driver::ResizeWindow(unsigned short col, unsigned short row) { - GetDebugger().SetTerminalWidth(col); - GetDebugger().SetTerminalHeight(row); -} - -void sigwinch_handler(int signo) { +void Driver::UpdateWindowSize() { struct winsize window_size; if ((isatty(STDIN_FILENO) != 0) && ::ioctl(STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) { -if ((window_size.ws_col > 0) && g_driver != nullptr) { - g_driver->ResizeWindow(window_size.ws_col, window_size.ws_row); -} +if (window_size.ws_col > 0) + m_debugger.SetTerminalWidth(window_size.ws_col); +#ifndef _WIN32 +if (window_size.ws_row > 0) + m_debugger.SetTerminalHeight(window_size.ws_row); +#endif } } +void sigwinch_handler(int signo) { + if (g_driver != nullptr) +g_driver->UpdateWindowSize(); +} + void sigint_handler(int signo) { #ifdef _WIN32 // Restore handler as it is not persistent on Windows signal(SIGINT, sigint_handler); diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h index ed400ca43575d4..eb268480361d96 100644 --- a/lldb/tools/driver/Driver.h +++ b/lldb/tools/driver/Driver.h @@ -92,7 +92,7 @@ class Driver : public lldb::SBBroadcaster { lldb::SBDebugger &GetDebugger() { return m_debugger; } - void ResizeWindow(unsigned short col, unsigned short row); + void UpdateWindowSize(); private: lldb::SBDebugger m_debugger; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (PR #120154)
llvmbot wrote: @llvm/pr-subscribers-lldb @llvm/pr-subscribers-clang Author: Michael Buch (Michael137) Changes In Objective-C, forward declarations are currently represented as: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) DW_AT_APPLE_runtime_class (DW_LANG_ObjC) ``` However, when compiling with `-gmodules`, when a class definition is turned into a forward declaration within a `DW_TAG_module`, the DIE for the forward declaration looks as follows: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) ``` Note the absence of `DW_AT_APPLE_runtime_class`. With recent changes in LLDB, not being able to differentiate between C++ and Objective-C forward declarations has become problematic (see attached test-case and explanation in https://github.com/llvm/llvm-project/pull/119860). --- Full diff: https://github.com/llvm/llvm-project/pull/120154.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+6-5) - (modified) clang/test/Modules/ExtDebugInfo.m (+2-1) - (modified) clang/test/Modules/ModuleDebugInfo.m (+1) - (added) lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test (+34) ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 60f32f76109e9a..ff27690d47b080 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2995,20 +2995,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, if (!ID) return nullptr; + auto RuntimeLang = + static_cast(TheCU->getSourceLanguage()); + // Return a forward declaration if this type was imported from a clang module, // and this is not the compile unit with the implementation of the type (which // may contain hidden ivars). if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() && !ID->getImplementation()) -return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - ID->getName(), - getDeclContextDescriptor(ID), Unit, 0); +return DBuilder.createForwardDecl( +llvm::dwarf::DW_TAG_structure_type, ID->getName(), +getDeclContextDescriptor(ID), Unit, 0, RuntimeLang); // Get overall information about the record type for the debug info. llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation()); - auto RuntimeLang = - static_cast(TheCU->getSourceLanguage()); // If this is just a forward declaration return a special forward-declaration // debug type since we won't be able to lay out the entire type. diff --git a/clang/test/Modules/ExtDebugInfo.m b/clang/test/Modules/ExtDebugInfo.m index b6a8b2676e5ba4..e2611ae5300634 100644 --- a/clang/test/Modules/ExtDebugInfo.m +++ b/clang/test/Modules/ExtDebugInfo.m @@ -75,7 +75,8 @@ int foo(ObjCClass *c) { // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MOD]], -// CHECK-SAME: flags: DIFlagFwdDecl) +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: runtimeLang: DW_LANG_ObjC) // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, diff --git a/clang/test/Modules/ModuleDebugInfo.m b/clang/test/Modules/ModuleDebugInfo.m index 62c6fd68dd8546..c527c43a0f4a2c 100644 --- a/clang/test/Modules/ModuleDebugInfo.m +++ b/clang/test/Modules/ModuleDebugInfo.m @@ -39,6 +39,7 @@ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK-SAME: scope: ![[MODULE]], +// CHECK-SAME: runtimeLang: DW_LANG_ObjC // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MODULE]], diff --git a/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test b/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test new file mode 100644 index 00..330a6b338c4723 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test @@ -0,0 +1,34 @@ +# REQUIRES: system-darwin + +# Test that we can set a breakpoint in a method of a class extension. +# This requires us to parse the method into an AST type, and the context +# too (which in DWARF is just a forward declaration). +# +# RUN: split-file %s %t +# RUN: %clangxx_host %t/lib.m -c -g -gmodules -fmodules -o %t/lib.o +# RUN: %clangxx_host %t/main.m -g -gmodules -fmodules %t/lib.o -o %t/a.out -framework Foundation +# +# RUN: %lldb %t/a.out -o "breakpoint set -f lib.m -l 6" -o exit | FileCheck %s + +# CHECK: (lldb) breakpoint set -f lib.m -l 6 +# CHECK: Breakpoint 1: where = a.out`-[NSObject(Foo) func] + +#--- main.m +int main() { + return 0; +} + +#--- lib.m +#import + +@implementation NSObject (Foo) +- (NSError *)func { +N
[Lldb-commits] [clang] [lldb] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (PR #120154)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Michael Buch (Michael137) Changes In Objective-C, forward declarations are currently represented as: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) DW_AT_APPLE_runtime_class (DW_LANG_ObjC) ``` However, when compiling with `-gmodules`, when a class definition is turned into a forward declaration within a `DW_TAG_module`, the DIE for the forward declaration looks as follows: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) ``` Note the absence of `DW_AT_APPLE_runtime_class`. With recent changes in LLDB, not being able to differentiate between C++ and Objective-C forward declarations has become problematic (see attached test-case and explanation in https://github.com/llvm/llvm-project/pull/119860). --- Full diff: https://github.com/llvm/llvm-project/pull/120154.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+6-5) - (modified) clang/test/Modules/ExtDebugInfo.m (+2-1) - (modified) clang/test/Modules/ModuleDebugInfo.m (+1) - (added) lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test (+34) ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 60f32f76109e9a..ff27690d47b080 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2995,20 +2995,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, if (!ID) return nullptr; + auto RuntimeLang = + static_cast(TheCU->getSourceLanguage()); + // Return a forward declaration if this type was imported from a clang module, // and this is not the compile unit with the implementation of the type (which // may contain hidden ivars). if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() && !ID->getImplementation()) -return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - ID->getName(), - getDeclContextDescriptor(ID), Unit, 0); +return DBuilder.createForwardDecl( +llvm::dwarf::DW_TAG_structure_type, ID->getName(), +getDeclContextDescriptor(ID), Unit, 0, RuntimeLang); // Get overall information about the record type for the debug info. llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation()); - auto RuntimeLang = - static_cast(TheCU->getSourceLanguage()); // If this is just a forward declaration return a special forward-declaration // debug type since we won't be able to lay out the entire type. diff --git a/clang/test/Modules/ExtDebugInfo.m b/clang/test/Modules/ExtDebugInfo.m index b6a8b2676e5ba4..e2611ae5300634 100644 --- a/clang/test/Modules/ExtDebugInfo.m +++ b/clang/test/Modules/ExtDebugInfo.m @@ -75,7 +75,8 @@ int foo(ObjCClass *c) { // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MOD]], -// CHECK-SAME: flags: DIFlagFwdDecl) +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: runtimeLang: DW_LANG_ObjC) // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, diff --git a/clang/test/Modules/ModuleDebugInfo.m b/clang/test/Modules/ModuleDebugInfo.m index 62c6fd68dd8546..c527c43a0f4a2c 100644 --- a/clang/test/Modules/ModuleDebugInfo.m +++ b/clang/test/Modules/ModuleDebugInfo.m @@ -39,6 +39,7 @@ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK-SAME: scope: ![[MODULE]], +// CHECK-SAME: runtimeLang: DW_LANG_ObjC // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MODULE]], diff --git a/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test b/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test new file mode 100644 index 00..330a6b338c4723 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test @@ -0,0 +1,34 @@ +# REQUIRES: system-darwin + +# Test that we can set a breakpoint in a method of a class extension. +# This requires us to parse the method into an AST type, and the context +# too (which in DWARF is just a forward declaration). +# +# RUN: split-file %s %t +# RUN: %clangxx_host %t/lib.m -c -g -gmodules -fmodules -o %t/lib.o +# RUN: %clangxx_host %t/main.m -g -gmodules -fmodules %t/lib.o -o %t/a.out -framework Foundation +# +# RUN: %lldb %t/a.out -o "breakpoint set -f lib.m -l 6" -o exit | FileCheck %s + +# CHECK: (lldb) breakpoint set -f lib.m -l 6 +# CHECK: Breakpoint 1: where = a.out`-[NSObject(Foo) func] + +#--- main.m +int main() { + return 0; +} + +#--- lib.m +#import + +@implementation NSObject (Foo) +- (NSError *)func { +NSLog(@"Hello, Worl
[Lldb-commits] [clang] [lldb] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (PR #120154)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/120154 In Objective-C, forward declarations are currently represented as: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) DW_AT_APPLE_runtime_class (DW_LANG_ObjC) ``` However, when compiling with `-gmodules`, when a class definition is turned into a forward declaration within a `DW_TAG_module`, the DIE for the forward declaration looks as follows: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) ``` Note the absence of `DW_AT_APPLE_runtime_class`. With recent changes in LLDB, not being able to differentiate between C++ and Objective-C forward declarations has become problematic (see attached test-case and explanation in https://github.com/llvm/llvm-project/pull/119860). >From 7c7fd60563244585adb8517bbd414ed45c249af7 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 16 Dec 2024 22:27:08 + Subject: [PATCH] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations In Objective-C, forward declarations are currently represented as: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) DW_AT_APPLE_runtime_class (DW_LANG_ObjC) ``` However, when compiling with `-gmodules`, when a class definition is turned into a forward declaration within a `DW_TAG_module`, the DIE for the forward declaration looks as follows: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) ``` Note the absence of `DW_AT_APPLE_runtime_class`. With recent changes in LLDB, not being able to differentiate between C++ and Objective-C forward declarations has become problematic (see attached test-case and explanation in https://github.com/llvm/llvm-project/pull/119860). --- clang/lib/CodeGen/CGDebugInfo.cpp | 11 +++--- clang/test/Modules/ExtDebugInfo.m | 3 +- clang/test/Modules/ModuleDebugInfo.m | 1 + .../DWARF/objc-gmodules-class-extension.test | 34 +++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 60f32f76109e9a..ff27690d47b080 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2995,20 +2995,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, if (!ID) return nullptr; + auto RuntimeLang = + static_cast(TheCU->getSourceLanguage()); + // Return a forward declaration if this type was imported from a clang module, // and this is not the compile unit with the implementation of the type (which // may contain hidden ivars). if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() && !ID->getImplementation()) -return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - ID->getName(), - getDeclContextDescriptor(ID), Unit, 0); +return DBuilder.createForwardDecl( +llvm::dwarf::DW_TAG_structure_type, ID->getName(), +getDeclContextDescriptor(ID), Unit, 0, RuntimeLang); // Get overall information about the record type for the debug info. llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation()); - auto RuntimeLang = - static_cast(TheCU->getSourceLanguage()); // If this is just a forward declaration return a special forward-declaration // debug type since we won't be able to lay out the entire type. diff --git a/clang/test/Modules/ExtDebugInfo.m b/clang/test/Modules/ExtDebugInfo.m index b6a8b2676e5ba4..e2611ae5300634 100644 --- a/clang/test/Modules/ExtDebugInfo.m +++ b/clang/test/Modules/ExtDebugInfo.m @@ -75,7 +75,8 @@ int foo(ObjCClass *c) { // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MOD]], -// CHECK-SAME: flags: DIFlagFwdDecl) +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: runtimeLang: DW_LANG_ObjC) // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, diff --git a/clang/test/Modules/ModuleDebugInfo.m b/clang/test/Modules/ModuleDebugInfo.m index 62c6fd68dd8546..c527c43a0f4a2c 100644 --- a/clang/test/Modules/ModuleDebugInfo.m +++ b/clang/test/Modules/ModuleDebugInfo.m @@ -39,6 +39,7 @@ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK-SAME: scope: ![[MODULE]], +// CHECK-SAME: runtimeLang: DW_LANG_ObjC // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MODULE]], diff --git a/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-exte
[Lldb-commits] [clang] [lldb] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (PR #120154)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Michael Buch (Michael137) Changes In Objective-C, forward declarations are currently represented as: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) DW_AT_APPLE_runtime_class (DW_LANG_ObjC) ``` However, when compiling with `-gmodules`, when a class definition is turned into a forward declaration within a `DW_TAG_module`, the DIE for the forward declaration looks as follows: ``` DW_TAG_structure_type DW_AT_name("Foo") DW_AT_declaration (true) ``` Note the absence of `DW_AT_APPLE_runtime_class`. With recent changes in LLDB, not being able to differentiate between C++ and Objective-C forward declarations has become problematic (see attached test-case and explanation in https://github.com/llvm/llvm-project/pull/119860). --- Full diff: https://github.com/llvm/llvm-project/pull/120154.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+6-5) - (modified) clang/test/Modules/ExtDebugInfo.m (+2-1) - (modified) clang/test/Modules/ModuleDebugInfo.m (+1) - (added) lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test (+34) ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 60f32f76109e9a..ff27690d47b080 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2995,20 +2995,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, if (!ID) return nullptr; + auto RuntimeLang = + static_cast(TheCU->getSourceLanguage()); + // Return a forward declaration if this type was imported from a clang module, // and this is not the compile unit with the implementation of the type (which // may contain hidden ivars). if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() && !ID->getImplementation()) -return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - ID->getName(), - getDeclContextDescriptor(ID), Unit, 0); +return DBuilder.createForwardDecl( +llvm::dwarf::DW_TAG_structure_type, ID->getName(), +getDeclContextDescriptor(ID), Unit, 0, RuntimeLang); // Get overall information about the record type for the debug info. llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation()); - auto RuntimeLang = - static_cast(TheCU->getSourceLanguage()); // If this is just a forward declaration return a special forward-declaration // debug type since we won't be able to lay out the entire type. diff --git a/clang/test/Modules/ExtDebugInfo.m b/clang/test/Modules/ExtDebugInfo.m index b6a8b2676e5ba4..e2611ae5300634 100644 --- a/clang/test/Modules/ExtDebugInfo.m +++ b/clang/test/Modules/ExtDebugInfo.m @@ -75,7 +75,8 @@ int foo(ObjCClass *c) { // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MOD]], -// CHECK-SAME: flags: DIFlagFwdDecl) +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: runtimeLang: DW_LANG_ObjC) // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, diff --git a/clang/test/Modules/ModuleDebugInfo.m b/clang/test/Modules/ModuleDebugInfo.m index 62c6fd68dd8546..c527c43a0f4a2c 100644 --- a/clang/test/Modules/ModuleDebugInfo.m +++ b/clang/test/Modules/ModuleDebugInfo.m @@ -39,6 +39,7 @@ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK-SAME: scope: ![[MODULE]], +// CHECK-SAME: runtimeLang: DW_LANG_ObjC // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MODULE]], diff --git a/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test b/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test new file mode 100644 index 00..330a6b338c4723 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/objc-gmodules-class-extension.test @@ -0,0 +1,34 @@ +# REQUIRES: system-darwin + +# Test that we can set a breakpoint in a method of a class extension. +# This requires us to parse the method into an AST type, and the context +# too (which in DWARF is just a forward declaration). +# +# RUN: split-file %s %t +# RUN: %clangxx_host %t/lib.m -c -g -gmodules -fmodules -o %t/lib.o +# RUN: %clangxx_host %t/main.m -g -gmodules -fmodules %t/lib.o -o %t/a.out -framework Foundation +# +# RUN: %lldb %t/a.out -o "breakpoint set -f lib.m -l 6" -o exit | FileCheck %s + +# CHECK: (lldb) breakpoint set -f lib.m -l 6 +# CHECK: Breakpoint 1: where = a.out`-[NSObject(Foo) func] + +#--- main.m +int main() { + return 0; +} + +#--- lib.m +#import + +@implementation NSObject (Foo) +- (NSError *)func { +NSLog(@"Hello, Worl
[Lldb-commits] [clang] [lldb] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (PR #120154)
@@ -2995,20 +2995,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, if (!ID) return nullptr; + auto RuntimeLang = + static_cast(TheCU->getSourceLanguage()); + // Return a forward declaration if this type was imported from a clang module, // and this is not the compile unit with the implementation of the type (which // may contain hidden ivars). if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() && !ID->getImplementation()) -return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - ID->getName(), - getDeclContextDescriptor(ID), Unit, 0); +return DBuilder.createForwardDecl( +llvm::dwarf::DW_TAG_structure_type, ID->getName(), +getDeclContextDescriptor(ID), Unit, 0, RuntimeLang); adrian-prantl wrote: Two things: 1. Shouldn't we do this only for ObjC class types? 2. Shouldn't — even in an ObjC++ CU — the runtimelang on an ObjC class be ObjC? https://github.com/llvm/llvm-project/pull/120154 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (PR #120154)
@@ -2995,20 +2995,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, if (!ID) return nullptr; + auto RuntimeLang = + static_cast(TheCU->getSourceLanguage()); + // Return a forward declaration if this type was imported from a clang module, // and this is not the compile unit with the implementation of the type (which // may contain hidden ivars). if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() && !ID->getImplementation()) -return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - ID->getName(), - getDeclContextDescriptor(ID), Unit, 0); +return DBuilder.createForwardDecl( +llvm::dwarf::DW_TAG_structure_type, ID->getName(), +getDeclContextDescriptor(ID), Unit, 0, RuntimeLang); Michael137 wrote: This overload is specifically for `const ObjCInterfaceType *Ty`. So we're always dealing with ObjC classes here. On line `3021` we're setting the RuntimeLang in the same way. I think we should stay consistent with whatever we attach to a definition. All the places in `dsymutil` and `LLDB` that read `DW_AT_APPLE_runtime_class` check for both `ObjC` and `ObjC++`. So looks like both are valid https://github.com/llvm/llvm-project/pull/120154 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,265 @@ +//===-- NativeProcessAIX.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "NativeProcessAIX.h" +#include "lldb/Host/Host.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "llvm/Support/Errno.h" +#include "llvm/Support/Error.h" +#include +#include +#include +#include +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_aix; +using namespace llvm; + +static constexpr unsigned k_ptrace_word_size = sizeof(void *); +static_assert(sizeof(long) >= k_ptrace_word_size, + "Size of long must be larger than ptrace word size"); + +// Simple helper function to ensure flags are enabled on the given file +// descriptor. +static llvm::Error EnsureFDFlags(int fd, int flags) { + Error error; + + int status = fcntl(fd, F_GETFL); + if (status == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + if (fcntl(fd, F_SETFL, status | flags) == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + return error; labath wrote: This isn't how llvm::Error is meant to be used (and I don't think it even compiles, given that the default Error constructor is not public). This is how I'd write this ```suggestion int status = fcntl(fd, F_GETFL); if (status == -1) return errorCodeToError(errnoAsErrorCode()); if (fcntl(fd, F_SETFL, status | flags) == -1) return errorCodeToError(errnoAsErrorCode()); return Error::success(); ``` https://github.com/llvm/llvm-project/pull/118160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][DWARFASTParserClang] Eagerly search definitions for Objective-C classes (PR #119860)
labath wrote: Unfortunate, but I guess there's nothing we can do to avoid it. https://github.com/llvm/llvm-project/pull/119860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,119 @@ +//===-- NativeProcessAIX.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 LIBLLDB_NATIVEPROCESSAIX_H_ +#define LIBLLDB_NATIVEPROCESSAIX_H_ + +#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h" +#include "lldb/Host/Debug.h" +#include "lldb/Host/common/NativeProcessProtocol.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-types.h" +#include "llvm/ADT/SmallPtrSet.h" +#include +#include + +namespace lldb_private { + +namespace process_aix { +/// \class NativeProcessAIX +/// Manages communication with the inferior (debugee) process. +/// +/// Upon construction, this class prepares and launches an inferior process +/// for debugging. +/// +/// Changes in the inferior process state are broadcasted. +class NativeProcessAIX : public NativeProcessProtocol { +public: + class Manager : public NativeProcessProtocol::Manager { + public: +Manager(MainLoop &mainloop); + +llvm::Expected> +Launch(ProcessLaunchInfo &launch_info, + NativeDelegate &native_delegate) override; + +llvm::Expected> +Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override; + +Extension GetSupportedExtensions() const override; + +void AddProcess(NativeProcessAIX &process) { m_processes.insert(&process); } + +void RemoveProcess(NativeProcessAIX &process) { + m_processes.erase(&process); +} + +// Collect an event for the given tid, waiting for it if necessary. +void CollectThread(::pid_t tid); + + private: +MainLoop::SignalHandleUP m_sigchld_handle; + +llvm::SmallPtrSet m_processes; labath wrote: Yeah, that's the idea. Common things == forking. Since we don't support follow-fork-mode=both (in the client at least), we'll ~never run into more processes (but it will still work if we do). https://github.com/llvm/llvm-project/pull/118160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,265 @@ +//===-- NativeProcessAIX.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "NativeProcessAIX.h" +#include "lldb/Host/Host.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "llvm/Support/Errno.h" +#include "llvm/Support/Error.h" +#include +#include +#include +#include +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_aix; +using namespace llvm; + +static constexpr unsigned k_ptrace_word_size = sizeof(void *); +static_assert(sizeof(long) >= k_ptrace_word_size, + "Size of long must be larger than ptrace word size"); + +// Simple helper function to ensure flags are enabled on the given file +// descriptor. +static llvm::Error EnsureFDFlags(int fd, int flags) { + Error error; + + int status = fcntl(fd, F_GETFL); + if (status == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + if (fcntl(fd, F_SETFL, status | flags) == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + return error; +} + +NativeProcessAIX::Manager::Manager(MainLoop &mainloop) +: NativeProcessProtocol::Manager(mainloop) { + Status status; + m_sigchld_handle = mainloop.RegisterSignal( + SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status); + assert(m_sigchld_handle && status.Success()); +} + +// Public Static Methods + +llvm::Expected> +NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info, + NativeDelegate &native_delegate) { + Log *log = GetLog(POSIXLog::Process); + + Status status; + ::pid_t pid = ProcessLauncherPosixFork() +.LaunchProcess(launch_info, status) +.GetProcessId(); + LLDB_LOG(log, "pid = {0:x}", pid); + if (status.Fail()) { +LLDB_LOG(log, "failed to launch process: {0}", status); +return status.ToError(); + } + + // Wait for the child process to trap on its call to execve. + int wstatus = 0; + ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0); + assert(wpid == pid); + UNUSED_IF_ASSERT_DISABLED(wpid); + if (!WIFSTOPPED(wstatus)) { +LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}", + WaitStatus::Decode(wstatus)); +return llvm::make_error("Could not sync with inferior process", + llvm::inconvertibleErrorCode()); + } + LLDB_LOG(log, "inferior started, now in stopped state"); + + ProcessInstanceInfo Info; + if (!Host::GetProcessInfo(pid, Info)) { +return llvm::make_error("Cannot get process architectrue", + llvm::inconvertibleErrorCode()); + } + + // Set the architecture to the exe architecture. + LLDB_LOG(log, "pid = {0}, detected architecture {1}", pid, + Info.GetArchitecture().GetArchitectureName()); + + return std::unique_ptr(new NativeProcessAIX( + pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate, + Info.GetArchitecture(), *this, {pid})); +} + +llvm::Expected> +NativeProcessAIX::Manager::Attach( +lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate) { + Log *log = GetLog(POSIXLog::Process); + LLDB_LOG(log, "pid = {0:x}", pid); + + ProcessInstanceInfo Info; + if (!Host::GetProcessInfo(pid, Info)) { +return llvm::make_error("Cannot get process architectrue", + llvm::inconvertibleErrorCode()); + } + auto tids_or = NativeProcessAIX::Attach(pid); + if (!tids_or) +return tids_or.takeError(); + + return std::unique_ptr(new NativeProcessAIX( + pid, -1, native_delegate, Info.GetArchitecture(), *this, *tids_or)); +} + +NativeProcessAIX::Extension +NativeProcessAIX::Manager::GetSupportedExtensions() const { + NativeProcessAIX::Extension supported = {}; + + return supported; +} + +void NativeProcessAIX::Manager::SigchldHandler() {} + +void NativeProcessAIX::Manager::CollectThread(::pid_t tid) {} + +// Public Instance Methods + +NativeProcessAIX::NativeProcessAIX(::pid_t pid, int terminal_fd, + NativeDelegate &delegate, + const ArchSpec &arch, Manager &manager, + llvm::ArrayRef<::pid_t> tids) +: NativeProcessProtocol(pid, terminal_fd, delegate), m_manager(manager), + m_arch(arch) { + manager.AddProcess(*this); + if (m_terminal_fd != -1) { +Status status =
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,265 @@ +//===-- NativeProcessAIX.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "NativeProcessAIX.h" +#include "lldb/Host/Host.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "llvm/Support/Errno.h" +#include "llvm/Support/Error.h" +#include +#include +#include +#include +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_aix; +using namespace llvm; + +static constexpr unsigned k_ptrace_word_size = sizeof(void *); +static_assert(sizeof(long) >= k_ptrace_word_size, + "Size of long must be larger than ptrace word size"); + +// Simple helper function to ensure flags are enabled on the given file +// descriptor. +static llvm::Error EnsureFDFlags(int fd, int flags) { + Error error; + + int status = fcntl(fd, F_GETFL); + if (status == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + if (fcntl(fd, F_SETFL, status | flags) == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + return error; +} + +NativeProcessAIX::Manager::Manager(MainLoop &mainloop) +: NativeProcessProtocol::Manager(mainloop) { + Status status; + m_sigchld_handle = mainloop.RegisterSignal( + SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status); + assert(m_sigchld_handle && status.Success()); +} + +// Public Static Methods + +llvm::Expected> +NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info, + NativeDelegate &native_delegate) { + Log *log = GetLog(POSIXLog::Process); + + Status status; + ::pid_t pid = ProcessLauncherPosixFork() +.LaunchProcess(launch_info, status) +.GetProcessId(); + LLDB_LOG(log, "pid = {0:x}", pid); + if (status.Fail()) { +LLDB_LOG(log, "failed to launch process: {0}", status); +return status.ToError(); + } + + // Wait for the child process to trap on its call to execve. + int wstatus = 0; + ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0); + assert(wpid == pid); + UNUSED_IF_ASSERT_DISABLED(wpid); + if (!WIFSTOPPED(wstatus)) { +LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}", + WaitStatus::Decode(wstatus)); +return llvm::make_error("Could not sync with inferior process", + llvm::inconvertibleErrorCode()); + } + LLDB_LOG(log, "inferior started, now in stopped state"); + + ProcessInstanceInfo Info; + if (!Host::GetProcessInfo(pid, Info)) { +return llvm::make_error("Cannot get process architectrue", + llvm::inconvertibleErrorCode()); + } + + // Set the architecture to the exe architecture. + LLDB_LOG(log, "pid = {0}, detected architecture {1}", pid, + Info.GetArchitecture().GetArchitectureName()); + + return std::unique_ptr(new NativeProcessAIX( + pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate, + Info.GetArchitecture(), *this, {pid})); +} + +llvm::Expected> +NativeProcessAIX::Manager::Attach( +lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate) { + Log *log = GetLog(POSIXLog::Process); + LLDB_LOG(log, "pid = {0:x}", pid); + + ProcessInstanceInfo Info; + if (!Host::GetProcessInfo(pid, Info)) { +return llvm::make_error("Cannot get process architectrue", + llvm::inconvertibleErrorCode()); + } + auto tids_or = NativeProcessAIX::Attach(pid); + if (!tids_or) +return tids_or.takeError(); + + return std::unique_ptr(new NativeProcessAIX( + pid, -1, native_delegate, Info.GetArchitecture(), *this, *tids_or)); +} + +NativeProcessAIX::Extension +NativeProcessAIX::Manager::GetSupportedExtensions() const { + NativeProcessAIX::Extension supported = {}; + + return supported; +} + +void NativeProcessAIX::Manager::SigchldHandler() {} + +void NativeProcessAIX::Manager::CollectThread(::pid_t tid) {} + +// Public Instance Methods + +NativeProcessAIX::NativeProcessAIX(::pid_t pid, int terminal_fd, + NativeDelegate &delegate, + const ArchSpec &arch, Manager &manager, + llvm::ArrayRef<::pid_t> tids) +: NativeProcessProtocol(pid, terminal_fd, delegate), m_manager(manager), + m_arch(arch) { + manager.AddProcess(*this); + if (m_terminal_fd != -1) { +Status status =
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,265 @@ +//===-- NativeProcessAIX.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "NativeProcessAIX.h" +#include "lldb/Host/Host.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/ProcessLaunchInfo.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "llvm/Support/Errno.h" +#include "llvm/Support/Error.h" +#include +#include +#include +#include +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_aix; +using namespace llvm; + +static constexpr unsigned k_ptrace_word_size = sizeof(void *); +static_assert(sizeof(long) >= k_ptrace_word_size, + "Size of long must be larger than ptrace word size"); + +// Simple helper function to ensure flags are enabled on the given file +// descriptor. +static llvm::Error EnsureFDFlags(int fd, int flags) { + Error error; + + int status = fcntl(fd, F_GETFL); + if (status == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + if (fcntl(fd, F_SETFL, status | flags) == -1) { +error = errorCodeToError(errnoAsErrorCode()); +return error; + } + + return error; +} + +NativeProcessAIX::Manager::Manager(MainLoop &mainloop) +: NativeProcessProtocol::Manager(mainloop) { + Status status; + m_sigchld_handle = mainloop.RegisterSignal( + SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status); + assert(m_sigchld_handle && status.Success()); +} + +// Public Static Methods + +llvm::Expected> +NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info, + NativeDelegate &native_delegate) { + Log *log = GetLog(POSIXLog::Process); + + Status status; + ::pid_t pid = ProcessLauncherPosixFork() +.LaunchProcess(launch_info, status) +.GetProcessId(); + LLDB_LOG(log, "pid = {0:x}", pid); + if (status.Fail()) { +LLDB_LOG(log, "failed to launch process: {0}", status); +return status.ToError(); + } + + // Wait for the child process to trap on its call to execve. + int wstatus = 0; + ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0); + assert(wpid == pid); + UNUSED_IF_ASSERT_DISABLED(wpid); + if (!WIFSTOPPED(wstatus)) { +LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}", + WaitStatus::Decode(wstatus)); +return llvm::make_error("Could not sync with inferior process", + llvm::inconvertibleErrorCode()); + } + LLDB_LOG(log, "inferior started, now in stopped state"); + + ProcessInstanceInfo Info; + if (!Host::GetProcessInfo(pid, Info)) { +return llvm::make_error("Cannot get process architectrue", + llvm::inconvertibleErrorCode()); + } + + // Set the architecture to the exe architecture. + LLDB_LOG(log, "pid = {0}, detected architecture {1}", pid, + Info.GetArchitecture().GetArchitectureName()); + + return std::unique_ptr(new NativeProcessAIX( + pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate, + Info.GetArchitecture(), *this, {pid})); +} + +llvm::Expected> +NativeProcessAIX::Manager::Attach( +lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate) { + Log *log = GetLog(POSIXLog::Process); + LLDB_LOG(log, "pid = {0:x}", pid); + + ProcessInstanceInfo Info; + if (!Host::GetProcessInfo(pid, Info)) { +return llvm::make_error("Cannot get process architectrue", + llvm::inconvertibleErrorCode()); + } + auto tids_or = NativeProcessAIX::Attach(pid); + if (!tids_or) +return tids_or.takeError(); + + return std::unique_ptr(new NativeProcessAIX( + pid, -1, native_delegate, Info.GetArchitecture(), *this, *tids_or)); +} + +NativeProcessAIX::Extension +NativeProcessAIX::Manager::GetSupportedExtensions() const { + NativeProcessAIX::Extension supported = {}; + + return supported; +} + +void NativeProcessAIX::Manager::SigchldHandler() {} + +void NativeProcessAIX::Manager::CollectThread(::pid_t tid) {} + +// Public Instance Methods + +NativeProcessAIX::NativeProcessAIX(::pid_t pid, int terminal_fd, + NativeDelegate &delegate, + const ArchSpec &arch, Manager &manager, + llvm::ArrayRef<::pid_t> tids) +: NativeProcessProtocol(pid, terminal_fd, delegate), m_manager(manager), + m_arch(arch) { + manager.AddProcess(*this); + if (m_terminal_fd != -1) { +Status status =
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,130 @@ +//===-- NativeProcessAIX.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 liblldb_NativeProcessAIX_H_ +#define liblldb_NativeProcessAIX_H_ + +#include +#include + +#include "lldb/Host/Debug.h" +#include "lldb/Host/HostThread.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-types.h" +#include "llvm/ADT/SmallPtrSet.h" + +#include "NativeThreadAIX.h" +#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h" +#include "lldb/Host/common/NativeProcessProtocol.h" + +namespace lldb_private { +class Status; +class Scalar; + +namespace process_aix { +/// \class NativeProcessAIX +/// Manages communication with the inferior (debugee) process. +/// +/// Upon construction, this class prepares and launches an inferior process +/// for debugging. +/// +/// Changes in the inferior process state are broadcasted. +class NativeProcessAIX : public NativeProcessProtocol, + private NativeProcessSoftwareSingleStep { +public: + class Manager : public NativeProcessProtocol::Manager { + public: +Manager(MainLoop &mainloop); + +llvm::Expected> +Launch(ProcessLaunchInfo &launch_info, + NativeDelegate &native_delegate) override; + +llvm::Expected> +Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override; + +Extension GetSupportedExtensions() const override; + +void AddProcess(NativeProcessAIX &process) { m_processes.insert(&process); } + +void RemoveProcess(NativeProcessAIX &process) { + m_processes.erase(&process); +} + +// Collect an event for the given tid, waiting for it if necessary. +void CollectThread(::pid_t tid); + + private: +MainLoop::SignalHandleUP m_sigchld_handle; + +llvm::SmallPtrSet m_processes; + +void SigchldHandler(); + }; + + // NativeProcessProtocol Interface + + ~NativeProcessAIX() override { m_manager.RemoveProcess(*this); } + + Status Resume(const ResumeActionList &resume_actions) override; + + Status Halt() override; + + Status Detach() override; + + Status Signal(int signo) override; + + Status Interrupt() override; + + Status Kill() override; + + const ArchSpec &GetArchitecture() const override { return m_arch; } + + Status SetBreakpoint(lldb::addr_t addr, uint32_t size, + bool hardware) override; + + Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override; + + Status GetFileLoadAddress(const llvm::StringRef &file_name, +lldb::addr_t &load_addr) override; + + static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, + void *data = nullptr, size_t data_size = 0, + long *result = nullptr); labath wrote: Except that in the cpp file the function returns a llvm::Error (with a by-ptr long result). I think that could work too (if you're able to provide a reason why is that better). In either case, I would like to make sure this code can at least compile (it doesn't have to run or do anything useful, *maybe* it doesn't even have to link) before we commit it. https://github.com/llvm/llvm-project/pull/118160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)
@@ -0,0 +1,119 @@ +//===-- NativeProcessAIX.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 LIBLLDB_NATIVEPROCESSAIX_H_ +#define LIBLLDB_NATIVEPROCESSAIX_H_ labath wrote: This is the header guard for elf core. I'd try to match that: `LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_PROCESSELFCORE_H` (the linux file still uses the old header probably guard because Jonas used some tool which only updates the files that are actually used in the build (and the linux file is not built on a mac) https://github.com/llvm/llvm-project/pull/118160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
@@ -1000,14 +1010,17 @@ PrintCompletion(FILE *output_file, if (position + description_length < max_length) { fprintf(output_file, "%.*s\n", static_cast(description_length), line.data()); +lines_printed++; labath wrote: It seems like this could be a problem if we cross the page boundary in the middle of a multi-line description. The worst part is that given that the code above checks for strict equality, this situation might end up cause us to dump everything in a single go. https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable TestIOHandlerResizeNoEditline.py for Windows hosts (PR #120025)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/120025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d576021 - [lldb] Disable TestIOHandlerResizeNoEditline.py for Windows hosts (#120025)
Author: Dmitry Vasilyev Date: 2024-12-16T19:52:30+04:00 New Revision: d576021853fd64c10fd746389a9b263cf10c5295 URL: https://github.com/llvm/llvm-project/commit/d576021853fd64c10fd746389a9b263cf10c5295 DIFF: https://github.com/llvm/llvm-project/commit/d576021853fd64c10fd746389a9b263cf10c5295.diff LOG: [lldb] Disable TestIOHandlerResizeNoEditline.py for Windows hosts (#120025) See #120021 for details. Added: Modified: lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py Removed: diff --git a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py index bbc2dcbe4e30ad..41b527a4e6b340 100644 --- a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py +++ b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py @@ -6,7 +6,10 @@ class TestCase(TestBase): @no_debug_info_test -@skipIfWindows +@skipIf( +hostoslist=["windows"], +bugnumber="https://github.com/llvm/llvm-project/issues/120021";, +) def test_resize_no_editline(self): """Tests terminal resizing if the editline isn't used.""" dbg = lldb.SBDebugger.Create(False) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Disable TestIOHandlerResizeNoEditline.py for Windows hosts (PR #120025)
https://github.com/slydiman closed https://github.com/llvm/llvm-project/pull/120025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b4c1f0c - [lldb][test] Prefer gmake to make and warn for potentially non-GNU make (#119573)
Author: David Spickett Date: 2024-12-16T08:47:48Z New Revision: b4c1f0cc492f1597397dcf0b06b816fa0a2135f1 URL: https://github.com/llvm/llvm-project/commit/b4c1f0cc492f1597397dcf0b06b816fa0a2135f1 DIFF: https://github.com/llvm/llvm-project/commit/b4c1f0cc492f1597397dcf0b06b816fa0a2135f1.diff LOG: [lldb][test] Prefer gmake to make and warn for potentially non-GNU make (#119573) System make on FreeBSD is missing some GNU make features so out of the box you get a lot of: ``` make: "<...>/Makefile.rules" line 569: Invalid line type ``` To solve this, you can install gmake which is a port of GNU make. However because we prefer 'make', gmake won't be used unless you set LLDB_TEST_MAKE. To fix that, prefer 'gmake'. Also check (as best we can) that the make we found is GNU make. This won't be perfect but it's better than the cryptic error shown above. ``` -- Found make: /usr/bin/make CMake Warning at /home/ec2-user/llvm-project/lldb/test/API/CMakeLists.txt:63 (message): 'make' tool /usr/bin/make may not be GNU make compatible. Some tests may fail to build. Provide a GNU compatible 'make' tool by setting LLDB_TEST_MAKE. ``` When a make isn't found at all, the warning message will show the names we tried: ``` -- Did not find one of: gmake make CMake Warning at /home/ec2-user/llvm-project/lldb/test/API/CMakeLists.txt:69 (message): Many LLDB API tests require a 'make' tool. Please provide it in Path or pass via LLDB_TEST_MAKE. ``` Added: Modified: lldb/test/API/CMakeLists.txt Removed: diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt index 36f4973ad9a452..da51f2252d0233 100644 --- a/lldb/test/API/CMakeLists.txt +++ b/lldb/test/API/CMakeLists.txt @@ -52,13 +52,24 @@ set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTA if(LLDB_TEST_MAKE) set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE}) else() - find_program(LLDB_DEFAULT_TEST_MAKE make gmake) + # Prefer gmake as it will be a version of GNU make. 'make' could be GNU compatible or not. + set(MAKE_NAMES "gmake" "make") + find_program(LLDB_DEFAULT_TEST_MAKE NAMES ${MAKE_NAMES}) if(LLDB_DEFAULT_TEST_MAKE) message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}") +execute_process(COMMAND ${LLDB_DEFAULT_TEST_MAKE} --version OUTPUT_VARIABLE MAKE_VERSION + ERROR_QUIET) +if(NOT MAKE_VERSION MATCHES "^GNU Make") + message(WARNING "'make' tool ${LLDB_DEFAULT_TEST_MAKE} may not be GNU make compatible. " + "Some tests may fail to build. Provide a GNU compatible 'make' tool by setting " + "LLDB_TEST_MAKE.") +endif() else() -message(STATUS "Not found: make") +list(JOIN "${MAKE_NAMES}" " " MAKE_NAMES_SPACES) +string(REPLACE ";" " " MAKE_NAMES_SPACES "${MAKE_NAMES}") +message(STATUS "Did not find one of: ${MAKE_NAMES_SPACES}") message(WARNING - "Many LLDB API tests require 'make' tool. Please provide it in Path " + "Many LLDB API tests require a 'make' tool. Please provide it in Path " "or pass via LLDB_TEST_MAKE.") endif() endif() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Prefer gmake to make and warn for potentially non-GNU make (PR #119573)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/119573 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Linux] Moving APIs from HostInfoLinux to HostInfoPosix (PR #119694)
https://github.com/labath commented: I agree with David except for the `GetProgramFileSpec` thingy -- where I have a question. https://github.com/llvm/llvm-project/pull/119694 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Linux] Moving APIs from HostInfoLinux to HostInfoPosix (PR #119694)
@@ -139,8 +177,53 @@ FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); } +FileSpec HostInfoPosix::GetProgramFileSpec() { + static FileSpec g_program_filespec; + + if (!g_program_filespec) { +char exe_path[PATH_MAX]; +ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1); +if (len > 0) { + exe_path[len] = 0; + g_program_filespec.SetFile(exe_path, FileSpec::Style::native); +} + } + + return g_program_filespec; +} labath wrote: I'm not too sure about this one. While other posix-like systems do have a "proc" file system, its contents tends to be very different. Juding by [this manpage](https://man.freebsd.org/cgi/man.cgi?query=procfs) the FreeBSD equivalent to `/proc/self/exe` *might* be `/proc/curproc/file`. @DavidSpickett, do you know if code like this would work for FreeBSD (with a change in the file name)? If so, then I'd say this is sufficient reason to put this code here. Otherwise, I'd probably keep it in Linux. (Depending on how similar the two end up looking, we may want to have a common linux/aix class or accept the duplication) https://github.com/llvm/llvm-project/pull/119694 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Linux] Moving APIs from HostInfoLinux to HostInfoPosix (PR #119694)
@@ -139,8 +177,53 @@ FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); } +FileSpec HostInfoPosix::GetProgramFileSpec() { + static FileSpec g_program_filespec; + + if (!g_program_filespec) { +char exe_path[PATH_MAX]; +ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1); +if (len > 0) { + exe_path[len] = 0; + g_program_filespec.SetFile(exe_path, FileSpec::Style::native); +} + } + + return g_program_filespec; +} DavidSpickett wrote: Let's leave this in Linux given that neither FreeBSD or NetBSD needed it until now. I tried this on FreeBSD and I think this from the manpage is relevant: ``` This functionality is deprecated. Users are advised to use libprocstat(3) and kvm(3) instead. ``` I had to mount it manually and this is on an AWS instance so I expect any default FreeBSD install to be the same. Once I did, only `/curproc/` worked, not `/self/`. NetBSD allows `/self/` for Linux compatibility (https://man.netbsd.org/mount_procfs.8) but I wouldn't be surprised if it also didn't mount procfs by default. https://github.com/llvm/llvm-project/pull/119694 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Linux] Moving APIs from HostInfoLinux to HostInfoPosix (PR #119694)
@@ -139,8 +177,53 @@ FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); } +FileSpec HostInfoPosix::GetProgramFileSpec() { + static FileSpec g_program_filespec; + + if (!g_program_filespec) { +char exe_path[PATH_MAX]; +ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1); +if (len > 0) { + exe_path[len] = 0; + g_program_filespec.SetFile(exe_path, FileSpec::Style::native); +} + } + + return g_program_filespec; +} DavidSpickett wrote: Probably best just to make an exact copy of the code for AIX, instead of making yet another class. If it's literally the same code then it's easy to find later if we really care about it. https://github.com/llvm/llvm-project/pull/119694 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0dbdc23 - [lldb] Add ability to rate-limit progress reports (#119377)
Author: Pavel Labath Date: 2024-12-16T11:35:43+01:00 New Revision: 0dbdc23e78ac1f34a5b563f2db73f9ca64714fac URL: https://github.com/llvm/llvm-project/commit/0dbdc23e78ac1f34a5b563f2db73f9ca64714fac DIFF: https://github.com/llvm/llvm-project/commit/0dbdc23e78ac1f34a5b563f2db73f9ca64714fac.diff LOG: [lldb] Add ability to rate-limit progress reports (#119377) For high-frequency multithreaded progress reports, the contention of taking the progress mutex and the overhead of generating event can significantly slow down the operation whose progress we are reporting. This patch adds an (optional) capability to rate-limit them. It's optional because this approach has one drawback: if the progress reporting has a pattern where it generates a burst of activity and then blocks (without reporting anything) for a large amount of time, it can appear as if less progress was made that it actually was (because we only reported the first event from the burst and dropped the other ones). I've also made a small refactor of the Progress class to better distinguish between const (don't need protection), atomic (are used on the hot path) and other (need mutex protection) members. Added: Modified: lldb/include/lldb/Core/Progress.h lldb/source/Core/Progress.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/unittests/Core/ProgressReportTest.cpp Removed: diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index 421e435a9e685a..f6cea282842e1c 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -10,6 +10,7 @@ #define LLDB_CORE_PROGRESS_H #include "lldb/Host/Alarm.h" +#include "lldb/Utility/Timeout.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" @@ -81,7 +82,8 @@ class Progress { /// progress is to be reported only to specific debuggers. Progress(std::string title, std::string details = {}, std::optional total = std::nullopt, - lldb_private::Debugger *debugger = nullptr); + lldb_private::Debugger *debugger = nullptr, + Timeout minimum_report_time = std::nullopt); /// Destroy the progress object. /// @@ -121,21 +123,32 @@ class Progress { private: void ReportProgress(); static std::atomic g_id; - /// More specific information about the current file being displayed in the - /// report. - std::string m_details; - /// How much work ([0...m_total]) that has been completed. - uint64_t m_completed; + /// Total amount of work, use a std::nullopt in the constructor for non /// deterministic progress. - uint64_t m_total; - std::mutex m_mutex; - /// Set to true when progress has been reported where m_completed == m_total - /// to ensure that we don't send progress updates after progress has - /// completed. - bool m_complete = false; + const uint64_t m_total; + + // Minimum amount of time between two progress reports. + const Timeout m_minimum_report_time; + /// Data needed by the debugger to broadcast a progress event. - ProgressData m_progress_data; + const ProgressData m_progress_data; + + /// How much work ([0...m_total]) that has been completed. + std::atomic m_completed = 0; + + /// Time (in nanoseconds since epoch) of the last progress report. + std::atomic m_last_report_time_ns; + + /// Guards non-const non-atomic members of the class. + std::mutex m_mutex; + + /// More specific information about the current file being displayed in the + /// report. + std::string m_details; + + /// The "completed" value of the last reported event. + std::optional m_prev_completed; }; /// A class used to group progress reports by category. This is done by using a diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp index c9a556472c06b6..ed8dfb85639b71 100644 --- a/lldb/source/Core/Progress.cpp +++ b/lldb/source/Core/Progress.cpp @@ -11,7 +11,8 @@ #include "lldb/Core/Debugger.h" #include "lldb/Utility/StreamString.h" #include "llvm/Support/Signposts.h" - +#include +#include #include #include #include @@ -26,17 +27,18 @@ static llvm::ManagedStatic g_progress_signposts; Progress::Progress(std::string title, std::string details, std::optional total, - lldb_private::Debugger *debugger) -: m_details(details), m_completed(0), - m_total(Progress::kNonDeterministicTotal), + lldb_private::Debugger *debugger, + Timeout minimum_report_time) +: m_total(total.value_or(Progress::kNonDeterministicTotal)), + m_minimum_report_time(minimum_report_time), m_progress_data{title, ++g_id, - /*m_progress_data.debugger_id=*/std::nullopt} { - if (total) -m_total = *total; - - if (debugger) -m_progress_data.debugger_id = debugger->GetID(); - +
[Lldb-commits] [lldb] [lldb] Add ability to rate-limit progress reports (PR #119377)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/119377 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)
@@ -81,9 +79,44 @@ ObjectFile *ObjectFileXCOFF::CreateInstance(const lldb::ModuleSP &module_sp, if (!objfile_up) return nullptr; + // Cache xcoff binary. + if (!objfile_up->CreateBinary()) +return nullptr; + + if (!objfile_up->ParseHeader()) +return nullptr; + return objfile_up.release(); } +bool ObjectFileXCOFF::CreateBinary() { + if (m_binary) +return true; + + Log *log = GetLog(LLDBLog::Object); + + auto binary = llvm::object::XCOFFObjectFile::createObjectFile( labath wrote: Ok, I see the problem now. I probably wouldn't go about this by changing the general `Binary` class, but rather `XCOFFObjectFile`. There are a couple of options, but I'd probably go with splitting the `create` function into two `create32|64` -- and then have that pass the right constant internally. This should also line up well with how the rest of this class is implemented (separate accessors for different bitwidths and all). This is something we could consult with the maintainer of the llvm class. Do you know who that is? It seems @diggerlin wrote most of the code -- do you have any thoughts on this? If that doesn't pan out for some reason, then I'd at least change this code to `llvm::object::ObjectFile::createObjectFile` -- as that's the function you're really calling. (The whole reason why I started looking into this is because I was wondering why *XCOFF*ObjectFile::createObjectFile does not return an result of type XCOFFObjectFile) https://github.com/llvm/llvm-project/pull/116338 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][DWARFASTParserClang] Eagerly search definitions for Objective-C classes (PR #119860)
@@ -1671,43 +1671,84 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, attrs.is_forward_declaration = true; } + DWARFDIE def_die; + if (attrs.is_forward_declaration && cu_language == eLanguageTypeObjC) { +def_die = dwarf->FindDefinitionDIE(die); + +if (!def_die) { + SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); + if (debug_map_symfile) { +// We weren't able to find a full declaration in this DWARF, +// see if we have a declaration anywhere else... +def_die = debug_map_symfile->FindDefinitionDIE(die); + } +} + +if (log) { + dwarf->GetObjectFile()->GetModule()->LogMessage( + log, + "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a " + "forward declaration, complete DIE is {5}", + static_cast(this), die.GetID(), DW_TAG_value_to_name(tag), + tag, attrs.name.GetCString(), + def_die ? llvm::utohexstr(def_die.GetID()) : "not found"); +} + +if (def_die) { + if (auto [it, inserted] = dwarf->GetDIEToType().try_emplace( + def_die.GetDIE(), DIE_IS_BEING_PARSED); + !inserted) { +if (it->getSecond() == nullptr || +it->getSecond() == DIE_IS_BEING_PARSED) + return nullptr; +return it->getSecond()->shared_from_this(); + } + attrs = ParsedDWARFTypeAttributes(def_die); +} + } + + if (!def_die) +def_die = die; + if (attrs.name) { -GetUniqueTypeNameAndDeclaration(die, cu_language, unique_typename, +GetUniqueTypeNameAndDeclaration(def_die, cu_language, unique_typename, labath wrote: The only catch there is that then `die` needs to be a value parameter, but I think that's a fine tradeoff. I contemplated doing that in #96484 (which is where the `def_die` name comes from, I think), and I didn't do it only because knew (well, I *thought* I knew) that code was going to be temporary). https://github.com/llvm/llvm-project/pull/119860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
@@ -1000,14 +1010,17 @@ PrintCompletion(FILE *output_file, if (position + description_length < max_length) { fprintf(output_file, "%.*s\n", static_cast(description_length), line.data()); +lines_printed++; labath wrote: I suppose its not the end of the world, though it that case, it might be better to bail out here (and skip printing the rest of the description) instead of pushing the first completion off the screen (and if it fit on one line, the user wouldn't even know that it was there). If this was c++20 I guess we could make this a coroutine which continues where it left off for the next page. Up to you, I guess... https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
@@ -1026,21 +1045,15 @@ void Editline::DisplayCompletions( const size_t max_len = longest->GetCompletion().size(); - if (results.size() < page_size) { -PrintCompletion(editline.m_output_file, results, max_len, -editline.GetTerminalWidth()); -return; - } - size_t cur_pos = 0; while (cur_pos < results.size()) { size_t remaining = results.size() - cur_pos; size_t next_size = all ? remaining : std::min(page_size, remaining); labath wrote: I think you don't need this now, and could always just pass the remainder of the list. https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
@@ -1000,14 +1010,17 @@ PrintCompletion(FILE *output_file, if (position + description_length < max_length) { fprintf(output_file, "%.*s\n", static_cast(description_length), line.data()); +lines_printed++; JDevlieghere wrote: Ah good point. I considered the situation where we would potentially exceed the page size if the last entry was a multiline one (and deemed that acceptable) but I didn't account for it in the check. We can make that a `>=`. https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 11d2911 - [lldb] Fix warnings
Author: Kazu Hirata Date: 2024-12-16T09:34:08-08:00 New Revision: 11d2911ef117aef2afb136339f0c24f8eee10c32 URL: https://github.com/llvm/llvm-project/commit/11d2911ef117aef2afb136339f0c24f8eee10c32 DIFF: https://github.com/llvm/llvm-project/commit/11d2911ef117aef2afb136339f0c24f8eee10c32.diff LOG: [lldb] Fix warnings This patch fixes: third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Werror,-Wsign-compare] Added: Modified: lldb/unittests/Core/ProgressReportTest.cpp Removed: diff --git a/lldb/unittests/Core/ProgressReportTest.cpp b/lldb/unittests/Core/ProgressReportTest.cpp index d03b3bc39f8e07..20324e92523874 100644 --- a/lldb/unittests/Core/ProgressReportTest.cpp +++ b/lldb/unittests/Core/ProgressReportTest.cpp @@ -225,14 +225,14 @@ TEST_F(ProgressReportTest, TestFiniteOverflow) { ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); EXPECT_TRUE(data->IsFinite()); - EXPECT_EQ(data->GetCompleted(), 0); - EXPECT_EQ(data->GetTotal(), 10); + EXPECT_EQ(data->GetCompleted(), 0U); + EXPECT_EQ(data->GetTotal(), 10U); ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); EXPECT_TRUE(data->IsFinite()); - EXPECT_EQ(data->GetCompleted(), 10); - EXPECT_EQ(data->GetTotal(), 10); + EXPECT_EQ(data->GetCompleted(), 10U); + EXPECT_EQ(data->GetTotal(), 10U); ASSERT_FALSE(listener_sp->GetEvent(event_sp, TIMEOUT)); } @@ -254,7 +254,7 @@ TEST_F(ProgressReportTest, TestNonDeterministicOverflow) { ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); EXPECT_FALSE(data->IsFinite()); - EXPECT_EQ(data->GetCompleted(), 0); + EXPECT_EQ(data->GetCompleted(), 0U); EXPECT_EQ(data->GetTotal(), Progress::kNonDeterministicTotal); ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); @@ -295,20 +295,20 @@ TEST_F(ProgressReportTest, TestMinimumReportTime) { ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); EXPECT_TRUE(data->IsFinite()); - EXPECT_EQ(data->GetCompleted(), 0); - EXPECT_EQ(data->GetTotal(), 20); + EXPECT_EQ(data->GetCompleted(), 0U); + EXPECT_EQ(data->GetTotal(), 20U); ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); EXPECT_TRUE(data->IsFinite()); - EXPECT_EQ(data->GetCompleted(), 11); - EXPECT_EQ(data->GetTotal(), 20); + EXPECT_EQ(data->GetCompleted(), 11U); + EXPECT_EQ(data->GetTotal(), 20U); ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT)); data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); EXPECT_TRUE(data->IsFinite()); - EXPECT_EQ(data->GetCompleted(), 20); - EXPECT_EQ(data->GetTotal(), 20); + EXPECT_EQ(data->GetCompleted(), 20U); + EXPECT_EQ(data->GetTotal(), 20U); ASSERT_FALSE(listener_sp->GetEvent(event_sp, TIMEOUT)); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/119914 >From f6fdfaf4be339a6412019113462b05cbce66c753 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 22 Feb 2024 21:54:07 -0800 Subject: [PATCH 1/4] [lldb] Use the terminal height for paging editline completions Currently, we arbitrarily paginate editline completions to 40 elements. On large terminals, that leaves some real-estate unused. On small terminals, it's pretty annoying to not see the first completions. We can address both issues by using the terminal height for pagination. --- lldb/include/lldb/API/SBDebugger.h| 4 ++ lldb/include/lldb/Core/Debugger.h | 4 ++ lldb/include/lldb/Host/Editline.h | 3 ++ lldb/source/API/SBDebugger.cpp| 13 ++ lldb/source/Core/CoreProperties.td| 4 ++ lldb/source/Core/Debugger.cpp | 28 ++-- lldb/source/Host/common/Editline.cpp | 44 +-- .../API/terminal/TestEditlineCompletions.py | 34 ++ lldb/tools/driver/Driver.cpp | 7 ++- lldb/tools/driver/Driver.h| 2 +- 10 files changed, 124 insertions(+), 19 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 1f42ec3cdc7d51..787bd040dd15bb 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -382,6 +382,10 @@ class LLDB_API SBDebugger { void SetTerminalWidth(uint32_t term_width); + uint32_t GetTerminalHeight() const; + + void SetTerminalHeight(uint32_t term_height); + lldb::user_id_t GetID(); const char *GetPrompt() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 1d5f2fcc20626c..70f4c4216221c6 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -280,6 +280,10 @@ class Debugger : public std::enable_shared_from_this, bool SetTerminalWidth(uint64_t term_width); + uint64_t GetTerminalHeight() const; + + bool SetTerminalHeight(uint64_t term_height); + llvm::StringRef GetPrompt() const; llvm::StringRef GetPromptAnsiPrefix() const; diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index e8e8a6c0d4f67e..26deba38f8471c 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -240,6 +240,8 @@ class Editline { size_t GetTerminalWidth() { return m_terminal_width; } + size_t GetTerminalHeight() { return m_terminal_height; } + private: /// Sets the lowest line number for multi-line editing sessions. A value of /// zero suppresses line number printing in the prompt. @@ -373,6 +375,7 @@ class Editline { std::vector m_input_lines; EditorStatus m_editor_status; int m_terminal_width = 0; + int m_terminal_height = 0; int m_base_line_number = 0; unsigned m_current_line_index = 0; int m_current_line_rows = -1; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 4efec747aacff1..4e6b22492a0d1c 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1405,6 +1405,19 @@ void SBDebugger::SetTerminalWidth(uint32_t term_width) { m_opaque_sp->SetTerminalWidth(term_width); } +uint32_t SBDebugger::GetTerminalHeight() const { + LLDB_INSTRUMENT_VA(this); + + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); +} + +void SBDebugger::SetTerminalHeight(uint32_t term_height) { + LLDB_INSTRUMENT_VA(this, term_height); + + if (m_opaque_sp) +m_opaque_sp->SetTerminalHeight(term_height); +} + const char *SBDebugger::GetPrompt() const { LLDB_INSTRUMENT_VA(this); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index e11aad2660b461..d3816c3070bbc5 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -136,6 +136,10 @@ let Definition = "debugger" in { Global, DefaultUnsignedValue<80>, Desc<"The maximum number of columns to use for displaying text.">; + def TerminalHeight: Property<"term-height", "UInt64">, +Global, +DefaultUnsignedValue<24>, +Desc<"The number of rows used for displaying text.">; def ThreadFormat: Property<"thread-format", "FormatEntity">, Global, DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
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 88bcf7283b35b979ace0c6be32736b13f6b771ae ae4e7a10d6f88e9c3d8fb7d47365c9f5b8ee2f2b --extensions h,cpp -- lldb/include/lldb/API/SBDebugger.h lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Host/Editline.h lldb/source/API/SBDebugger.cpp lldb/source/Core/Debugger.cpp lldb/source/Host/common/Editline.cpp lldb/tools/driver/Driver.cpp lldb/tools/driver/Driver.h `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index a18560fdd2..6e35b15d69 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -1047,10 +1047,10 @@ void Editline::DisplayCompletions( size_t cur_pos = 0; while (cur_pos < results.size()) { -cur_pos += PrintCompletion( -editline.m_output_file, results.slice(cur_pos), max_len, -editline.GetTerminalWidth(), -all ? std::nullopt : std::optional(page_size)); +cur_pos += +PrintCompletion(editline.m_output_file, results.slice(cur_pos), max_len, +editline.GetTerminalWidth(), +all ? std::nullopt : std::optional(page_size)); if (cur_pos >= results.size()) break; `` https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/119914 >From f6fdfaf4be339a6412019113462b05cbce66c753 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 22 Feb 2024 21:54:07 -0800 Subject: [PATCH 1/5] [lldb] Use the terminal height for paging editline completions Currently, we arbitrarily paginate editline completions to 40 elements. On large terminals, that leaves some real-estate unused. On small terminals, it's pretty annoying to not see the first completions. We can address both issues by using the terminal height for pagination. --- lldb/include/lldb/API/SBDebugger.h| 4 ++ lldb/include/lldb/Core/Debugger.h | 4 ++ lldb/include/lldb/Host/Editline.h | 3 ++ lldb/source/API/SBDebugger.cpp| 13 ++ lldb/source/Core/CoreProperties.td| 4 ++ lldb/source/Core/Debugger.cpp | 28 ++-- lldb/source/Host/common/Editline.cpp | 44 +-- .../API/terminal/TestEditlineCompletions.py | 34 ++ lldb/tools/driver/Driver.cpp | 7 ++- lldb/tools/driver/Driver.h| 2 +- 10 files changed, 124 insertions(+), 19 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 1f42ec3cdc7d51..787bd040dd15bb 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -382,6 +382,10 @@ class LLDB_API SBDebugger { void SetTerminalWidth(uint32_t term_width); + uint32_t GetTerminalHeight() const; + + void SetTerminalHeight(uint32_t term_height); + lldb::user_id_t GetID(); const char *GetPrompt() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 1d5f2fcc20626c..70f4c4216221c6 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -280,6 +280,10 @@ class Debugger : public std::enable_shared_from_this, bool SetTerminalWidth(uint64_t term_width); + uint64_t GetTerminalHeight() const; + + bool SetTerminalHeight(uint64_t term_height); + llvm::StringRef GetPrompt() const; llvm::StringRef GetPromptAnsiPrefix() const; diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index e8e8a6c0d4f67e..26deba38f8471c 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -240,6 +240,8 @@ class Editline { size_t GetTerminalWidth() { return m_terminal_width; } + size_t GetTerminalHeight() { return m_terminal_height; } + private: /// Sets the lowest line number for multi-line editing sessions. A value of /// zero suppresses line number printing in the prompt. @@ -373,6 +375,7 @@ class Editline { std::vector m_input_lines; EditorStatus m_editor_status; int m_terminal_width = 0; + int m_terminal_height = 0; int m_base_line_number = 0; unsigned m_current_line_index = 0; int m_current_line_rows = -1; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 4efec747aacff1..4e6b22492a0d1c 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1405,6 +1405,19 @@ void SBDebugger::SetTerminalWidth(uint32_t term_width) { m_opaque_sp->SetTerminalWidth(term_width); } +uint32_t SBDebugger::GetTerminalHeight() const { + LLDB_INSTRUMENT_VA(this); + + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); +} + +void SBDebugger::SetTerminalHeight(uint32_t term_height) { + LLDB_INSTRUMENT_VA(this, term_height); + + if (m_opaque_sp) +m_opaque_sp->SetTerminalHeight(term_height); +} + const char *SBDebugger::GetPrompt() const { LLDB_INSTRUMENT_VA(this); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index e11aad2660b461..d3816c3070bbc5 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -136,6 +136,10 @@ let Definition = "debugger" in { Global, DefaultUnsignedValue<80>, Desc<"The maximum number of columns to use for displaying text.">; + def TerminalHeight: Property<"term-height", "UInt64">, +Global, +DefaultUnsignedValue<24>, +Desc<"The number of rows used for displaying text.">; def ThreadFormat: Property<"thread-format", "FormatEntity">, Global, DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\
[Lldb-commits] [lldb] [lldb] Provide default impl for MightHaveChildren (NFC) (PR #119977)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/119977 >From 3bf901b53d98378cee4a1868d039a1289e9e5277 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Sat, 14 Dec 2024 09:26:17 -0800 Subject: [PATCH 1/3] [lldb] Provide default impl for MightHaveChildren (NFC) --- .../lldb/DataFormatters/TypeSynthetic.h | 2 +- .../lldb/DataFormatters/VectorIterator.h | 2 - lldb/source/DataFormatters/VectorType.cpp | 2 - .../Language/CPlusPlus/BlockPointer.cpp | 3 -- .../Plugins/Language/CPlusPlus/Coroutines.cpp | 5 --- .../Plugins/Language/CPlusPlus/Coroutines.h | 2 - .../Language/CPlusPlus/GenericBitset.cpp | 1 - .../Language/CPlusPlus/GenericOptional.cpp| 1 - .../Plugins/Language/CPlusPlus/LibCxx.cpp | 10 - .../Plugins/Language/CPlusPlus/LibCxx.h | 4 -- .../Language/CPlusPlus/LibCxxAtomic.cpp | 7 --- .../CPlusPlus/LibCxxInitializerList.cpp | 7 --- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 1 - .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 14 -- .../Language/CPlusPlus/LibCxxProxyArray.cpp | 7 --- .../Language/CPlusPlus/LibCxxQueue.cpp| 1 - .../CPlusPlus/LibCxxRangesRefView.cpp | 2 - .../Language/CPlusPlus/LibCxxSliceArray.cpp | 7 --- .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp | 7 --- .../Language/CPlusPlus/LibCxxTuple.cpp| 1 - .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 14 -- .../Language/CPlusPlus/LibCxxValarray.cpp | 7 --- .../Language/CPlusPlus/LibCxxVariant.cpp | 1 - .../Language/CPlusPlus/LibCxxVector.cpp | 9 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 10 - .../Language/CPlusPlus/LibStdcppTuple.cpp | 4 -- .../CPlusPlus/LibStdcppUniquePointer.cpp | 4 -- lldb/source/Plugins/Language/ObjC/NSArray.cpp | 22 - .../Plugins/Language/ObjC/NSDictionary.cpp| 45 --- lldb/source/Plugins/Language/ObjC/NSError.cpp | 2 - .../Plugins/Language/ObjC/NSException.cpp | 2 - lldb/source/Plugins/Language/ObjC/NSSet.cpp | 37 --- 32 files changed, 1 insertion(+), 242 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index bf6dc6a0c3c6bf..14e516964f2507 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -68,7 +68,7 @@ class SyntheticChildrenFrontEnd { // a false return value from this call if it returns true, then // CalculateNumChildren() can return any number >= 0 (0 being valid) it // should if at all possible be more efficient than CalculateNumChildren() - virtual bool MightHaveChildren() = 0; + virtual bool MightHaveChildren() { return true; } // if this function returns a non-null ValueObject, then the returned // ValueObject will stand for this ValueObject whenever a "value" request is diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h index 70bcf50ca1b1d2..d095f085cabab6 100644 --- a/lldb/include/lldb/DataFormatters/VectorIterator.h +++ b/lldb/include/lldb/DataFormatters/VectorIterator.h @@ -30,8 +30,6 @@ class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ChildCacheState Update() override; - bool MightHaveChildren() override; - size_t GetIndexOfChildWithName(ConstString name) override; private: diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index cba107b7da8900..fa3fb1b674efbe 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -268,8 +268,6 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return lldb::ChildCacheState::eRefetch; } - bool MightHaveChildren() override { return true; } - size_t GetIndexOfChildWithName(ConstString name) override { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp index d7d4654a6b5f44..6a22501c98aab8 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -144,9 +144,6 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return lldb::ChildCacheState::eRefetch; } - // maybe return false if the block pointer is, say, null - bool MightHaveChildren() override { return true; } - size_t GetIndexOfChildWithName(ConstString name) override { if (!m_block_struct_type.IsValid()) return UINT32_MAX; diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp index 5e63d1d7b21453..76a10d2393782c 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
[Lldb-commits] [lldb] 9ee454a - [lldb] Fix RST table formatting
Author: Adrian Prantl Date: 2024-12-16T10:42:37-08:00 New Revision: 9ee454a57c061e47223e079cdc64d315580367ed URL: https://github.com/llvm/llvm-project/commit/9ee454a57c061e47223e079cdc64d315580367ed DIFF: https://github.com/llvm/llvm-project/commit/9ee454a57c061e47223e079cdc64d315580367ed.diff LOG: [lldb] Fix RST table formatting Added: Modified: lldb/docs/resources/formatterbytecode.rst Removed: diff --git a/lldb/docs/resources/formatterbytecode.rst b/lldb/docs/resources/formatterbytecode.rst index a4fd2bbe804b24..20e148363ef957 100644 --- a/lldb/docs/resources/formatterbytecode.rst +++ b/lldb/docs/resources/formatterbytecode.rst @@ -58,7 +58,7 @@ These instructions manipulate the data stack directly. 0x03 `over` `(x y -> x y x)` 0x04 `swap` `(x y -> y x)` 0x05 `rot` `(x y z -> z x y)` -=== == === + == === Control flow ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3dfc1d9 - [lldb] Use the terminal height for paging editline completions (#119914)
Author: Jonas Devlieghere Date: 2024-12-16T11:11:17-08:00 New Revision: 3dfc1d9b0bc41eaf63e551ca357b44a71636b152 URL: https://github.com/llvm/llvm-project/commit/3dfc1d9b0bc41eaf63e551ca357b44a71636b152 DIFF: https://github.com/llvm/llvm-project/commit/3dfc1d9b0bc41eaf63e551ca357b44a71636b152.diff LOG: [lldb] Use the terminal height for paging editline completions (#119914) Currently, we arbitrarily paginate editline completions to 40 elements. On large terminals, that leaves some real-estate unused. On small terminals, it's pretty annoying to not see the first completions. We can address both issues by using the terminal height for pagination. This builds on the improvements of #116456. Added: Modified: lldb/include/lldb/API/SBDebugger.h lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Host/Editline.h lldb/source/API/SBDebugger.cpp lldb/source/Core/CoreProperties.td lldb/source/Core/Debugger.cpp lldb/source/Host/common/Editline.cpp lldb/test/API/functionalities/completion/TestCompletion.py lldb/test/API/terminal/TestEditlineCompletions.py lldb/tools/driver/Driver.cpp lldb/tools/driver/Driver.h Removed: diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 1f42ec3cdc7d51..787bd040dd15bb 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -382,6 +382,10 @@ class LLDB_API SBDebugger { void SetTerminalWidth(uint32_t term_width); + uint32_t GetTerminalHeight() const; + + void SetTerminalHeight(uint32_t term_height); + lldb::user_id_t GetID(); const char *GetPrompt() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 1d5f2fcc20626c..70f4c4216221c6 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -280,6 +280,10 @@ class Debugger : public std::enable_shared_from_this, bool SetTerminalWidth(uint64_t term_width); + uint64_t GetTerminalHeight() const; + + bool SetTerminalHeight(uint64_t term_height); + llvm::StringRef GetPrompt() const; llvm::StringRef GetPromptAnsiPrefix() const; diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index e8e8a6c0d4f67e..26deba38f8471c 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -240,6 +240,8 @@ class Editline { size_t GetTerminalWidth() { return m_terminal_width; } + size_t GetTerminalHeight() { return m_terminal_height; } + private: /// Sets the lowest line number for multi-line editing sessions. A value of /// zero suppresses line number printing in the prompt. @@ -373,6 +375,7 @@ class Editline { std::vector m_input_lines; EditorStatus m_editor_status; int m_terminal_width = 0; + int m_terminal_height = 0; int m_base_line_number = 0; unsigned m_current_line_index = 0; int m_current_line_rows = -1; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 4efec747aacff1..4e6b22492a0d1c 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1405,6 +1405,19 @@ void SBDebugger::SetTerminalWidth(uint32_t term_width) { m_opaque_sp->SetTerminalWidth(term_width); } +uint32_t SBDebugger::GetTerminalHeight() const { + LLDB_INSTRUMENT_VA(this); + + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); +} + +void SBDebugger::SetTerminalHeight(uint32_t term_height) { + LLDB_INSTRUMENT_VA(this, term_height); + + if (m_opaque_sp) +m_opaque_sp->SetTerminalHeight(term_height); +} + const char *SBDebugger::GetPrompt() const { LLDB_INSTRUMENT_VA(this); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index e11aad2660b461..d3816c3070bbc5 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -136,6 +136,10 @@ let Definition = "debugger" in { Global, DefaultUnsignedValue<80>, Desc<"The maximum number of columns to use for displaying text.">; + def TerminalHeight: Property<"term-height", "UInt64">, +Global, +DefaultUnsignedValue<24>, +Desc<"The number of rows used for displaying text.">; def ThreadFormat: Property<"thread-format", "FormatEntity">, Global, DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.r
[Lldb-commits] [lldb] [lldb] Use the terminal height for paging editline completions (PR #119914)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/119914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error reporting in GetLocation_DW_OP_addr (PR #120162)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Instead of simply raising an error flag, use an llvm::Expected to propagate a meaningful error to the caller, who can report it. rdar://139705570 --- Full diff: https://github.com/llvm/llvm-project/pull/120162.diff 3 Files Affected: - (modified) lldb/include/lldb/Expression/DWARFExpression.h (+4-7) - (modified) lldb/source/Expression/DWARFExpression.cpp (+12-10) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+16-12) ``diff diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index e85ba464dea6b6..2c1e717ee32eb7 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -16,6 +16,7 @@ #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h" +#include "llvm/Support/Error.h" #include namespace lldb_private { @@ -61,15 +62,11 @@ class DWARFExpression { /// The dwarf unit this expression belongs to. Only required to resolve /// DW_OP{addrx, GNU_addr_index}. /// - /// \param[out] error - /// If the location stream contains unknown DW_OP opcodes or the - /// data is missing, \a error will be set to \b true. - /// /// \return /// The address specified by the operation, if the operation exists, or - /// LLDB_INVALID_ADDRESS otherwise. - lldb::addr_t GetLocation_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu, - bool &error) const; + /// an llvm::Error otherwise. + llvm::Expected + GetLocation_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu) const; bool Update_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu, lldb::addr_t file_addr); diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index a7126b25c1cc38..1d826e341e2c44 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -343,30 +343,32 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, } } -lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu, - bool &error) const { - error = false; +llvm::Expected +DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu) const { lldb::offset_t offset = 0; while (m_data.ValidOffset(offset)) { const uint8_t op = m_data.GetU8(&offset); if (op == DW_OP_addr) return m_data.GetAddress(&offset); + if (op == DW_OP_GNU_addr_index || op == DW_OP_addrx) { - uint64_t index = m_data.GetULEB128(&offset); + const uint64_t index = m_data.GetULEB128(&offset); if (dwarf_cu) return dwarf_cu->ReadAddressFromDebugAddrSection(index); - error = true; - break; + return llvm::createStringError("cannot evaluate %s without a DWARF unit", + DW_OP_value_to_name(op)); } + const lldb::offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op, dwarf_cu); -if (op_arg_size == LLDB_INVALID_OFFSET) { - error = true; - break; -} +if (op_arg_size == LLDB_INVALID_OFFSET) + return llvm::createStringError("cannot get opcode data size for %s", + DW_OP_value_to_name(op)); + offset += op_arg_size; } + return LLDB_INVALID_ADDRESS; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 68e50902d641a2..5bf38b332b7f34 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Format.h" +#include "llvm/Support/FormatAdapters.h" #include "llvm/Support/Threading.h" #include "lldb/Core/Module.h" @@ -1705,7 +1706,7 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) { // We have a SymbolFileDWARFDebugMap, so let it find the right file if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) return debug_map->GetSymbolFileByOSOIndex(*file_index); - + // Handle the .dwp file case correctly if (*file_index == DIERef::k_file_index_mask) return GetDwpSymbolFile().get(); // DWP case @@ -3539,17 +3540,20 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, // Check if the location has a DW_OP_addr with any address value... lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS; if (!location_is_const_value_data) { - bool op_error = false; - const DWARFExpression* location = location_list.GetAlwaysValidExpr(); - if (locati
[Lldb-commits] [lldb] [lldb] Improve error reporting in GetLocation_DW_OP_addr (PR #120162)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/120162 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)
@@ -81,9 +79,44 @@ ObjectFile *ObjectFileXCOFF::CreateInstance(const lldb::ModuleSP &module_sp, if (!objfile_up) return nullptr; + // Cache xcoff binary. + if (!objfile_up->CreateBinary()) +return nullptr; + + if (!objfile_up->ParseHeader()) +return nullptr; + return objfile_up.release(); } +bool ObjectFileXCOFF::CreateBinary() { + if (m_binary) +return true; + + Log *log = GetLog(LLDBLog::Object); + + auto binary = llvm::object::XCOFFObjectFile::createObjectFile( DhruvSrivastavaX wrote: Yes, that will be good. In that case, I can open a PR under llvm code to split the createXCOFFObjectfile to `32|64`. If it goes through I can introduce the change for objectfilexcoff too, if we are able to introduce. For this one, I can change try changing to `llvm::object::ObjectFile::createObjectFile` https://github.com/llvm/llvm-project/pull/116338 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The improved error reporting in #120162 revealed that we were missing opcodes in GetOpcodeDataSize. rdar://139705570 --- Full diff: https://github.com/llvm/llvm-project/pull/120163.diff 1 Files Affected: - (modified) lldb/source/Expression/DWARFExpression.cpp (+3) ``diff diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index a7126b25c1cc38..34d508f97ae012 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -269,6 +269,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, // All opcodes that have a single ULEB (signed or unsigned) argument case DW_OP_addrx: // 0xa1 1 ULEB128 index + case DW_OP_constx: // 0xa2 1 ULEB128 index case DW_OP_constu: // 0x10 1 ULEB128 constant case DW_OP_consts: // 0x11 1 SLEB128 constant case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend @@ -307,6 +308,8 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, case DW_OP_regx:// 0x90 1 ULEB128 register case DW_OP_fbreg: // 0x91 1 SLEB128 offset case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed + case DW_OP_convert: // 0xa8 1 ULEB128 offset + case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index data.Skip_LEB128(&offset); `` https://github.com/llvm/llvm-project/pull/120163 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/120163 The improved error reporting in #120162 revealed that we were missing opcodes in GetOpcodeDataSize. rdar://139705570 >From 5aca34df18e4a64a5c7aacfa77d9086dd6ca5271 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 16 Dec 2024 15:58:52 -0800 Subject: [PATCH] [lldb] Add missing operations to GetOpcodeDataSize The improved error reporting in #120162 revealed that we were missing opcodes in GetOpcodeDataSize. rdar://139705570 --- lldb/source/Expression/DWARFExpression.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index a7126b25c1cc38..34d508f97ae012 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -269,6 +269,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, // All opcodes that have a single ULEB (signed or unsigned) argument case DW_OP_addrx: // 0xa1 1 ULEB128 index + case DW_OP_constx: // 0xa2 1 ULEB128 index case DW_OP_constu: // 0x10 1 ULEB128 constant case DW_OP_consts: // 0x11 1 SLEB128 constant case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend @@ -307,6 +308,8 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, case DW_OP_regx:// 0x90 1 ULEB128 register case DW_OP_fbreg: // 0x91 1 SLEB128 offset case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed + case DW_OP_convert: // 0xa8 1 ULEB128 offset + case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index data.Skip_LEB128(&offset); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error reporting in DWARFExpression::GetLocation_DW_OP_… (PR #120162)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/120162 …addr Instead of simply raising an error flag, use an llvm::Expected to propagate a meaningful error to the caller, who can report it. rdar://139705570 >From 9637e922d0646a4008c76ac0cbf9713511bf2d3e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 16 Dec 2024 15:08:25 -0800 Subject: [PATCH] [lldb] Improve error reporting in DWARFExpression::GetLocation_DW_OP_addr Instead of simply raising an error flag, use an llvm::Expected to propagate a meaningful error to the caller, who can report it. rdar://139705570 --- .../include/lldb/Expression/DWARFExpression.h | 11 +++- lldb/source/Expression/DWARFExpression.cpp| 22 --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 28 +++ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index e85ba464dea6b6..2c1e717ee32eb7 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -16,6 +16,7 @@ #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h" +#include "llvm/Support/Error.h" #include namespace lldb_private { @@ -61,15 +62,11 @@ class DWARFExpression { /// The dwarf unit this expression belongs to. Only required to resolve /// DW_OP{addrx, GNU_addr_index}. /// - /// \param[out] error - /// If the location stream contains unknown DW_OP opcodes or the - /// data is missing, \a error will be set to \b true. - /// /// \return /// The address specified by the operation, if the operation exists, or - /// LLDB_INVALID_ADDRESS otherwise. - lldb::addr_t GetLocation_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu, - bool &error) const; + /// an llvm::Error otherwise. + llvm::Expected + GetLocation_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu) const; bool Update_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu, lldb::addr_t file_addr); diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index a7126b25c1cc38..1d826e341e2c44 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -343,30 +343,32 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, } } -lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu, - bool &error) const { - error = false; +llvm::Expected +DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu) const { lldb::offset_t offset = 0; while (m_data.ValidOffset(offset)) { const uint8_t op = m_data.GetU8(&offset); if (op == DW_OP_addr) return m_data.GetAddress(&offset); + if (op == DW_OP_GNU_addr_index || op == DW_OP_addrx) { - uint64_t index = m_data.GetULEB128(&offset); + const uint64_t index = m_data.GetULEB128(&offset); if (dwarf_cu) return dwarf_cu->ReadAddressFromDebugAddrSection(index); - error = true; - break; + return llvm::createStringError("cannot evaluate %s without a DWARF unit", + DW_OP_value_to_name(op)); } + const lldb::offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op, dwarf_cu); -if (op_arg_size == LLDB_INVALID_OFFSET) { - error = true; - break; -} +if (op_arg_size == LLDB_INVALID_OFFSET) + return llvm::createStringError("cannot get opcode data size for %s", + DW_OP_value_to_name(op)); + offset += op_arg_size; } + return LLDB_INVALID_ADDRESS; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 68e50902d641a2..5bf38b332b7f34 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Format.h" +#include "llvm/Support/FormatAdapters.h" #include "llvm/Support/Threading.h" #include "lldb/Core/Module.h" @@ -1705,7 +1706,7 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) { // We have a SymbolFileDWARFDebugMap, so let it find the right file if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) return debug_map->GetSymbolFileByOSOIndex(*file_index); - + // Handle the .dwp file case correctly if (*file_index == DIERef::k_file_index_mask) return GetDwpSymbolFile().get(); // DWP case @@ -3539,17 +3540,20 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolCo
[Lldb-commits] [lldb] [lldb] Improve error reporting in GetLocation_DW_OP_addr (PR #120162)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/120162 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Make workaround for the Dynamic loader issue (PR #120166)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/120166 In #119598 my recent TLS feature seems to break crashpad symbols. I have a few ideas on how this is happening, but for now as a mitigation I'm checking if the Minidump was LLDB generated, and if so leveraging the dynamic loader. >From 697cf020203bcdee2289e5ba03dcd0d7f459aa90 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Mon, 16 Dec 2024 16:04:01 -0800 Subject: [PATCH] Make workaround for the Dynamic loader issue --- .../Minidump/MinidumpFileBuilder.cpp | 4 +- .../Process/minidump/MinidumpParser.cpp | 25 ++- .../Plugins/Process/minidump/MinidumpParser.h | 8 +- .../Process/minidump/ProcessMinidump.cpp | 205 +- .../Process/minidump/ProcessMinidump.h| 7 +- llvm/include/llvm/BinaryFormat/Minidump.h | 4 + 6 files changed, 137 insertions(+), 116 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index bcac5edbc1a793..a4541f8bddf1a2 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -918,8 +918,8 @@ Status MinidumpFileBuilder::DumpHeader() const { 0u), // not used in most of the writers header.TimeDateStamp = static_cast(std::time(nullptr)); - header.Flags = - static_cast(0u); // minidump normal flag + header.Flags = static_cast( + llvm::minidump::Header::LLDB_HEADER_FLAG); Status error; size_t bytes_written; diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp index afc095ddbb2f91..6a328b3b841ed0 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include using namespace lldb_private; using namespace minidump; @@ -45,6 +45,10 @@ llvm::ArrayRef MinidumpParser::GetData() { m_data_sp->GetByteSize()); } +const llvm::minidump::Header *MinidumpParser::GetHeader() const { + return reinterpret_cast(m_file.get()); +} + llvm::ArrayRef MinidumpParser::GetStream(StreamType stream_type) { return m_file->getRawStream(stream_type).value_or(llvm::ArrayRef()); } @@ -70,8 +74,7 @@ UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) { if (GetArchitecture().GetTriple().isOSBinFormatELF()) { if (pdb70_uuid->Age != 0) return UUID(pdb70_uuid, sizeof(*pdb70_uuid)); - return UUID(&pdb70_uuid->Uuid, -sizeof(pdb70_uuid->Uuid)); + return UUID(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid)); } return UUID(*pdb70_uuid); } else if (cv_signature == CvSignature::ElfBuildId) @@ -453,10 +456,12 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) { if (!GetStream(StreamType::Memory64List).empty()) { llvm::Error err = llvm::Error::success(); -for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { - if (memory_desc.first.StartOfMemoryRange <= addr - && addr < memory_desc.first.StartOfMemoryRange + memory_desc.first.DataSize) { -return minidump::Range(memory_desc.first.StartOfMemoryRange, memory_desc.second); +for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { + if (memory_desc.first.StartOfMemoryRange <= addr && + addr < memory_desc.first.StartOfMemoryRange + + memory_desc.first.DataSize) { +return minidump::Range(memory_desc.first.StartOfMemoryRange, + memory_desc.second); } } @@ -490,7 +495,8 @@ llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, return range->range_ref.slice(offset, overlap); } -llvm::iterator_range MinidumpParser::GetMemory64Iterator(llvm::Error &err) { +llvm::iterator_range +MinidumpParser::GetMemory64Iterator(llvm::Error &err) { llvm::ErrorAsOutParameter ErrAsOutParam(&err); return m_file->getMemory64List(err); } @@ -602,8 +608,7 @@ std::pair MinidumpParser::BuildMemoryRegions() { case StreamType::ST: \ return #ST -llvm::StringRef -MinidumpParser::GetStreamTypeAsString(StreamType stream_type) { +llvm::StringRef MinidumpParser::GetStreamTypeAsString(StreamType stream_type) { switch (stream_type) { ENUM_TO_CSTR(Unused); ENUM_TO_CSTR(ThreadList); diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.h b/lldb/source/Plugins/Process/minidump/MinidumpParser.h index f0b6e6027c52f0..e13065264668c2 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.h +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.h @@ -47,7 +47,8 @@ struct Range { } }; -using FallibleMemor
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Make workaround for the Dynamic loader issue (PR #120166)
https://github.com/Jlalond unassigned https://github.com/llvm/llvm-project/pull/120166 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Make workaround for the Dynamic loader issue (PR #120166)
llvmbot wrote: @llvm/pr-subscribers-llvm-binary-utilities Author: Jacob Lalonde (Jlalond) Changes In #119598 my recent TLS feature seems to break crashpad symbols. I have a few ideas on how this is happening, but for now as a mitigation I'm checking if the Minidump was LLDB generated, and if so leveraging the dynamic loader. --- Patch is 22.91 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/120166.diff 6 Files Affected: - (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp (+2-2) - (modified) lldb/source/Plugins/Process/minidump/MinidumpParser.cpp (+15-10) - (modified) lldb/source/Plugins/Process/minidump/MinidumpParser.h (+6-2) - (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp (+105-100) - (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.h (+5-2) - (modified) llvm/include/llvm/BinaryFormat/Minidump.h (+4) ``diff diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index bcac5edbc1a793..a4541f8bddf1a2 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -918,8 +918,8 @@ Status MinidumpFileBuilder::DumpHeader() const { 0u), // not used in most of the writers header.TimeDateStamp = static_cast(std::time(nullptr)); - header.Flags = - static_cast(0u); // minidump normal flag + header.Flags = static_cast( + llvm::minidump::Header::LLDB_HEADER_FLAG); Status error; size_t bytes_written; diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp index afc095ddbb2f91..6a328b3b841ed0 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include using namespace lldb_private; using namespace minidump; @@ -45,6 +45,10 @@ llvm::ArrayRef MinidumpParser::GetData() { m_data_sp->GetByteSize()); } +const llvm::minidump::Header *MinidumpParser::GetHeader() const { + return reinterpret_cast(m_file.get()); +} + llvm::ArrayRef MinidumpParser::GetStream(StreamType stream_type) { return m_file->getRawStream(stream_type).value_or(llvm::ArrayRef()); } @@ -70,8 +74,7 @@ UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) { if (GetArchitecture().GetTriple().isOSBinFormatELF()) { if (pdb70_uuid->Age != 0) return UUID(pdb70_uuid, sizeof(*pdb70_uuid)); - return UUID(&pdb70_uuid->Uuid, -sizeof(pdb70_uuid->Uuid)); + return UUID(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid)); } return UUID(*pdb70_uuid); } else if (cv_signature == CvSignature::ElfBuildId) @@ -453,10 +456,12 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) { if (!GetStream(StreamType::Memory64List).empty()) { llvm::Error err = llvm::Error::success(); -for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { - if (memory_desc.first.StartOfMemoryRange <= addr - && addr < memory_desc.first.StartOfMemoryRange + memory_desc.first.DataSize) { -return minidump::Range(memory_desc.first.StartOfMemoryRange, memory_desc.second); +for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { + if (memory_desc.first.StartOfMemoryRange <= addr && + addr < memory_desc.first.StartOfMemoryRange + + memory_desc.first.DataSize) { +return minidump::Range(memory_desc.first.StartOfMemoryRange, + memory_desc.second); } } @@ -490,7 +495,8 @@ llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, return range->range_ref.slice(offset, overlap); } -llvm::iterator_range MinidumpParser::GetMemory64Iterator(llvm::Error &err) { +llvm::iterator_range +MinidumpParser::GetMemory64Iterator(llvm::Error &err) { llvm::ErrorAsOutParameter ErrAsOutParam(&err); return m_file->getMemory64List(err); } @@ -602,8 +608,7 @@ std::pair MinidumpParser::BuildMemoryRegions() { case StreamType::ST: \ return #ST -llvm::StringRef -MinidumpParser::GetStreamTypeAsString(StreamType stream_type) { +llvm::StringRef MinidumpParser::GetStreamTypeAsString(StreamType stream_type) { switch (stream_type) { ENUM_TO_CSTR(Unused); ENUM_TO_CSTR(ThreadList); diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.h b/lldb/source/Plugins/Process/minidump/MinidumpParser.h index f0b6e6027c52f0..e13065264668c2 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.h +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.h @@ -47,7 +47,8 @@ struct R
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Make workaround for the Dynamic loader issue (PR #120166)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes In #119598 my recent TLS feature seems to break crashpad symbols. I have a few ideas on how this is happening, but for now as a mitigation I'm checking if the Minidump was LLDB generated, and if so leveraging the dynamic loader. --- Patch is 22.91 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/120166.diff 6 Files Affected: - (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp (+2-2) - (modified) lldb/source/Plugins/Process/minidump/MinidumpParser.cpp (+15-10) - (modified) lldb/source/Plugins/Process/minidump/MinidumpParser.h (+6-2) - (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp (+105-100) - (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.h (+5-2) - (modified) llvm/include/llvm/BinaryFormat/Minidump.h (+4) ``diff diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index bcac5edbc1a793..a4541f8bddf1a2 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -918,8 +918,8 @@ Status MinidumpFileBuilder::DumpHeader() const { 0u), // not used in most of the writers header.TimeDateStamp = static_cast(std::time(nullptr)); - header.Flags = - static_cast(0u); // minidump normal flag + header.Flags = static_cast( + llvm::minidump::Header::LLDB_HEADER_FLAG); Status error; size_t bytes_written; diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp index afc095ddbb2f91..6a328b3b841ed0 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include using namespace lldb_private; using namespace minidump; @@ -45,6 +45,10 @@ llvm::ArrayRef MinidumpParser::GetData() { m_data_sp->GetByteSize()); } +const llvm::minidump::Header *MinidumpParser::GetHeader() const { + return reinterpret_cast(m_file.get()); +} + llvm::ArrayRef MinidumpParser::GetStream(StreamType stream_type) { return m_file->getRawStream(stream_type).value_or(llvm::ArrayRef()); } @@ -70,8 +74,7 @@ UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) { if (GetArchitecture().GetTriple().isOSBinFormatELF()) { if (pdb70_uuid->Age != 0) return UUID(pdb70_uuid, sizeof(*pdb70_uuid)); - return UUID(&pdb70_uuid->Uuid, -sizeof(pdb70_uuid->Uuid)); + return UUID(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid)); } return UUID(*pdb70_uuid); } else if (cv_signature == CvSignature::ElfBuildId) @@ -453,10 +456,12 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) { if (!GetStream(StreamType::Memory64List).empty()) { llvm::Error err = llvm::Error::success(); -for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { - if (memory_desc.first.StartOfMemoryRange <= addr - && addr < memory_desc.first.StartOfMemoryRange + memory_desc.first.DataSize) { -return minidump::Range(memory_desc.first.StartOfMemoryRange, memory_desc.second); +for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { + if (memory_desc.first.StartOfMemoryRange <= addr && + addr < memory_desc.first.StartOfMemoryRange + + memory_desc.first.DataSize) { +return minidump::Range(memory_desc.first.StartOfMemoryRange, + memory_desc.second); } } @@ -490,7 +495,8 @@ llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, return range->range_ref.slice(offset, overlap); } -llvm::iterator_range MinidumpParser::GetMemory64Iterator(llvm::Error &err) { +llvm::iterator_range +MinidumpParser::GetMemory64Iterator(llvm::Error &err) { llvm::ErrorAsOutParameter ErrAsOutParam(&err); return m_file->getMemory64List(err); } @@ -602,8 +608,7 @@ std::pair MinidumpParser::BuildMemoryRegions() { case StreamType::ST: \ return #ST -llvm::StringRef -MinidumpParser::GetStreamTypeAsString(StreamType stream_type) { +llvm::StringRef MinidumpParser::GetStreamTypeAsString(StreamType stream_type) { switch (stream_type) { ENUM_TO_CSTR(Unused); ENUM_TO_CSTR(ThreadList); diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.h b/lldb/source/Plugins/Process/minidump/MinidumpParser.h index f0b6e6027c52f0..e13065264668c2 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.h +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.h @@ -47,7 +47,8 @@ struct Range { } };
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Make workaround for the Dynamic loader issue (PR #120166)
https://github.com/Jlalond unassigned https://github.com/llvm/llvm-project/pull/120166 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add external progress bit category (PR #120171)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/120171 As feedback on #119052, it was recommended I add a new bit to delineate internal and external progress events. This patch adds this new category, and sets up Progress.h to support external events via SBProgress. >From fcad0a35ec2e10ec90591079d05c3b1726d22967 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Mon, 16 Dec 2024 17:57:44 -0800 Subject: [PATCH] Add external progress bit category --- lldb/include/lldb/Core/Progress.h | 12 +++- lldb/include/lldb/lldb-enumerations.h | 13 +++-- lldb/source/Core/Progress.cpp | 13 ++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index f6cea282842e1c..1d56703a9f586a 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -21,6 +21,12 @@ namespace lldb_private { +/// Enum to indicate the origin of a progress event, internal or external. +enum class ProgressOrigin : uint8_t { + eLLDBInternal = 0, + eExternal = 1, +}; + /// A Progress indicator helper class. /// /// Any potentially long running sections of code in LLDB should report @@ -83,7 +89,8 @@ class Progress { Progress(std::string title, std::string details = {}, std::optional total = std::nullopt, lldb_private::Debugger *debugger = nullptr, - Timeout minimum_report_time = std::nullopt); + Timeout minimum_report_time = std::nullopt, + ProgressOrigin origin = ProgressOrigin::eLLDBInternal); /// Destroy the progress object. /// @@ -149,6 +156,9 @@ class Progress { /// The "completed" value of the last reported event. std::optional m_prev_completed; + + /// The origin of this progress event. + ProgressOrigin m_origin; }; /// A class used to group progress reports by category. This is done by using a diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 0094fcd596fdf7..aa9673feb1a586 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -195,10 +195,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this eFormatUnicode8, kNumFormats }; @@ -302,7 +302,7 @@ enum ConnectionStatus { eConnectionStatusNoConnection, ///< No connection eConnectionStatusLostConnection, ///< Lost connection while connected to a ///< valid connection - eConnectionStatusInterrupted ///< Interrupted read + eConnectionStatusInterrupted ///< Interrupted read }; enum ErrorType { @@ -1094,7 +1094,7 @@ enum PathType { ePathTypeGlobalLLDBTempSystemDir, ///< The LLDB temp directory for this ///< system, NOT cleaned up on a process ///< exit. - ePathTypeClangDir ///< Find path to Clang builtin headers + ePathTypeClangDir ///< Find path to Clang builtin headers }; /// Kind of member function. @@ -1357,6 +1357,7 @@ enum DebuggerBroadcastBit { eBroadcastBitError = (1 << 2), eBroadcastSymbolChange = (1 << 3), eBroadcastBitProgressCategory = (1 << 4), + eBroadcastBitExternalProgressCategory = (1 << 5), }; /// Used for expressing severity in logs and diagnostics. diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp index ed8dfb85639b71..e3161d79275693 100644 --- a/lldb/source/Core/Progress.cpp +++ b/lldb/source/Core/Progress.cpp @@ -28,7 +28,8 @@ static llvm::ManagedStatic g_progress_signposts; Progress::Progress(std::string title, std::string details, std::optional total, lldb_private::Debugger *debugger, - Timeout minimum_report_time) + Timeout minimum_report_time, + ProgressOrigin origin) : m_total(total.value_or(Progress::kNonDeterministicTotal)), m_minimum_report_time(minimum_report_time), m_progress_data{title, ++g_id, @@ -38,7 +39,7 @@ Progress::Progress(std::string title, std::string details, std::chrono::nanoseconds( std::chrono::steady_clock::now().time_since_epoch()) .count()), - m_details(std::move(details)) { + m_details(std::move(details)), m_origin(origin)
[Lldb-commits] [lldb] [LLDB] Add external progress bit category (PR #120171)
Jlalond wrote: @JDevlieghere I'm hoping I did this right, additionally any preference on where the enum should live? I debated on enumerations and just make a generic 'eventorigin' enumeration that we could reuse for events in the future. But I figured that was reaching. https://github.com/llvm/llvm-project/pull/120171 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add external progress bit category (PR #120171)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes As feedback on #119052, it was recommended I add a new bit to delineate internal and external progress events. This patch adds this new category, and sets up Progress.h to support external events via SBProgress. --- Full diff: https://github.com/llvm/llvm-project/pull/120171.diff 3 Files Affected: - (modified) lldb/include/lldb/Core/Progress.h (+11-1) - (modified) lldb/include/lldb/lldb-enumerations.h (+7-6) - (modified) lldb/source/Core/Progress.cpp (+10-3) ``diff diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index f6cea282842e1c..1d56703a9f586a 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -21,6 +21,12 @@ namespace lldb_private { +/// Enum to indicate the origin of a progress event, internal or external. +enum class ProgressOrigin : uint8_t { + eLLDBInternal = 0, + eExternal = 1, +}; + /// A Progress indicator helper class. /// /// Any potentially long running sections of code in LLDB should report @@ -83,7 +89,8 @@ class Progress { Progress(std::string title, std::string details = {}, std::optional total = std::nullopt, lldb_private::Debugger *debugger = nullptr, - Timeout minimum_report_time = std::nullopt); + Timeout minimum_report_time = std::nullopt, + ProgressOrigin origin = ProgressOrigin::eLLDBInternal); /// Destroy the progress object. /// @@ -149,6 +156,9 @@ class Progress { /// The "completed" value of the last reported event. std::optional m_prev_completed; + + /// The origin of this progress event. + ProgressOrigin m_origin; }; /// A class used to group progress reports by category. This is done by using a diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 0094fcd596fdf7..aa9673feb1a586 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -195,10 +195,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this eFormatUnicode8, kNumFormats }; @@ -302,7 +302,7 @@ enum ConnectionStatus { eConnectionStatusNoConnection, ///< No connection eConnectionStatusLostConnection, ///< Lost connection while connected to a ///< valid connection - eConnectionStatusInterrupted ///< Interrupted read + eConnectionStatusInterrupted ///< Interrupted read }; enum ErrorType { @@ -1094,7 +1094,7 @@ enum PathType { ePathTypeGlobalLLDBTempSystemDir, ///< The LLDB temp directory for this ///< system, NOT cleaned up on a process ///< exit. - ePathTypeClangDir ///< Find path to Clang builtin headers + ePathTypeClangDir ///< Find path to Clang builtin headers }; /// Kind of member function. @@ -1357,6 +1357,7 @@ enum DebuggerBroadcastBit { eBroadcastBitError = (1 << 2), eBroadcastSymbolChange = (1 << 3), eBroadcastBitProgressCategory = (1 << 4), + eBroadcastBitExternalProgressCategory = (1 << 5), }; /// Used for expressing severity in logs and diagnostics. diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp index ed8dfb85639b71..e3161d79275693 100644 --- a/lldb/source/Core/Progress.cpp +++ b/lldb/source/Core/Progress.cpp @@ -28,7 +28,8 @@ static llvm::ManagedStatic g_progress_signposts; Progress::Progress(std::string title, std::string details, std::optional total, lldb_private::Debugger *debugger, - Timeout minimum_report_time) + Timeout minimum_report_time, + ProgressOrigin origin) : m_total(total.value_or(Progress::kNonDeterministicTotal)), m_minimum_report_time(minimum_report_time), m_progress_data{title, ++g_id, @@ -38,7 +39,7 @@ Progress::Progress(std::string title, std::string details, std::chrono::nanoseconds( std::chrono::steady_clock::now().time_since_epoch()) .count()), - m_details(std::move(details)) { + m_details(std::move(details)), m_origin(origin) { std::lock_guard guard(m_mutex); ReportProgress(); @@ -106,9 +107,15 @@ void Progress::ReportProgress() { if (completed < m_