[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
https://github.com/mdko updated https://github.com/llvm/llvm-project/pull/73596 >From 97a6e23c85457a14c91c5800fa03bb872e6f1fa6 Mon Sep 17 00:00:00 2001 From: Michael Christensen Date: Mon, 27 Nov 2023 12:49:24 -0800 Subject: [PATCH 1/4] Add option to pass thread ID to thread select command --- lldb/source/Commands/CommandObjectThread.cpp | 59 +-- lldb/source/Commands/Options.td | 5 ++ .../thread/select/TestThreadSelect.py | 23 +++- 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index a9f5a4f8a4fbd71..9384df319cc221d 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -1129,8 +1129,44 @@ class CommandObjectThreadUntil : public CommandObjectParsed { // CommandObjectThreadSelect +#define LLDB_OPTIONS_thread_select +#include "CommandOptions.inc" + class CommandObjectThreadSelect : public CommandObjectParsed { public: + class CommandOptions : public Options { + public: +CommandOptions() { OptionParsingStarting(nullptr); } + +~CommandOptions() override = default; + +void OptionParsingStarting(ExecutionContext *execution_context) override { + m_thread_id = false; +} + +Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + const int short_option = m_getopt_table[option_idx].val; + switch (short_option) { + case 't': { +m_thread_id = true; +break; + } + + default: +llvm_unreachable("Unimplemented option"); + } + + return {}; +} + +llvm::ArrayRef GetDefinitions() override { + return llvm::ArrayRef(g_thread_select_options); +} + +bool m_thread_id; + }; + CommandObjectThreadSelect(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "thread select", "Change the currently selected thread.", nullptr, @@ -1165,6 +1201,8 @@ class CommandObjectThreadSelect : public CommandObjectParsed { nullptr); } + Options *GetOptions() override { return &m_options; } + protected: void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); @@ -1173,22 +1211,29 @@ class CommandObjectThreadSelect : public CommandObjectParsed { return; } else if (command.GetArgumentCount() != 1) { result.AppendErrorWithFormat( - "'%s' takes exactly one thread index argument:\nUsage: %s\n", - m_cmd_name.c_str(), m_cmd_syntax.c_str()); + "'%s' takes exactly one thread %s argument:\nUsage: %s\n", + m_cmd_name.c_str(), m_options.m_thread_id ? "ID" : "index", + m_cmd_syntax.c_str()); return; } uint32_t index_id; if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) { - result.AppendErrorWithFormat("Invalid thread index '%s'", + result.AppendErrorWithFormat("Invalid thread %s '%s'", + m_options.m_thread_id ? "ID" : "index", command.GetArgumentAtIndex(0)); return; } -Thread *new_thread = -process->GetThreadList().FindThreadByIndexID(index_id).get(); +Thread *new_thread = nullptr; +if (m_options.m_thread_id) { +new_thread = process->GetThreadList().FindThreadByID(index_id).get(); +} else { +new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get(); +} if (new_thread == nullptr) { - result.AppendErrorWithFormat("invalid thread #%s.\n", + result.AppendErrorWithFormat("invalid thread %s%s.\n", + m_options.m_thread_id ? "ID " : "#", command.GetArgumentAtIndex(0)); return; } @@ -1196,6 +1241,8 @@ class CommandObjectThreadSelect : public CommandObjectParsed { process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true); result.SetStatus(eReturnStatusSuccessFinishNoResult); } + + CommandOptions m_options; }; // CommandObjectThreadList diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index 542c78be5a12dad..23886046df8f673 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -1117,6 +1117,11 @@ let Command = "thread plan list" in { Desc<"Display thread plans for unreported threads">; } +let Command = "thread select" in { + def thread_thread_id : Option<"thread_id", "t">, +Desc<"Provide a thread ID instead of a thread index.">; +} + let Command = "thread trace dump function calls" in { def thread_trace_dump_function_calls_file : Option<"file", "F">, Group<1>, Arg<"Filename">, diff --git a/lldb/test/API/commands/thread/select/TestThreadSelect.py b/lldb/test/AP
[Lldb-commits] [lldb] [lldb][test] TestConstStaticIntegralMember: relax assertion on number of global variables (PR #73707)
DavidSpickett wrote: lldb Arm Linux bots all green now, thanks for fixing this. https://github.com/llvm/llvm-project/pull/73707 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
https://github.com/mdko updated https://github.com/llvm/llvm-project/pull/73596 >From 97a6e23c85457a14c91c5800fa03bb872e6f1fa6 Mon Sep 17 00:00:00 2001 From: Michael Christensen Date: Mon, 27 Nov 2023 12:49:24 -0800 Subject: [PATCH 1/5] Add option to pass thread ID to thread select command --- lldb/source/Commands/CommandObjectThread.cpp | 59 +-- lldb/source/Commands/Options.td | 5 ++ .../thread/select/TestThreadSelect.py | 23 +++- 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index a9f5a4f8a4fbd71..9384df319cc221d 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -1129,8 +1129,44 @@ class CommandObjectThreadUntil : public CommandObjectParsed { // CommandObjectThreadSelect +#define LLDB_OPTIONS_thread_select +#include "CommandOptions.inc" + class CommandObjectThreadSelect : public CommandObjectParsed { public: + class CommandOptions : public Options { + public: +CommandOptions() { OptionParsingStarting(nullptr); } + +~CommandOptions() override = default; + +void OptionParsingStarting(ExecutionContext *execution_context) override { + m_thread_id = false; +} + +Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + const int short_option = m_getopt_table[option_idx].val; + switch (short_option) { + case 't': { +m_thread_id = true; +break; + } + + default: +llvm_unreachable("Unimplemented option"); + } + + return {}; +} + +llvm::ArrayRef GetDefinitions() override { + return llvm::ArrayRef(g_thread_select_options); +} + +bool m_thread_id; + }; + CommandObjectThreadSelect(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "thread select", "Change the currently selected thread.", nullptr, @@ -1165,6 +1201,8 @@ class CommandObjectThreadSelect : public CommandObjectParsed { nullptr); } + Options *GetOptions() override { return &m_options; } + protected: void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); @@ -1173,22 +1211,29 @@ class CommandObjectThreadSelect : public CommandObjectParsed { return; } else if (command.GetArgumentCount() != 1) { result.AppendErrorWithFormat( - "'%s' takes exactly one thread index argument:\nUsage: %s\n", - m_cmd_name.c_str(), m_cmd_syntax.c_str()); + "'%s' takes exactly one thread %s argument:\nUsage: %s\n", + m_cmd_name.c_str(), m_options.m_thread_id ? "ID" : "index", + m_cmd_syntax.c_str()); return; } uint32_t index_id; if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) { - result.AppendErrorWithFormat("Invalid thread index '%s'", + result.AppendErrorWithFormat("Invalid thread %s '%s'", + m_options.m_thread_id ? "ID" : "index", command.GetArgumentAtIndex(0)); return; } -Thread *new_thread = -process->GetThreadList().FindThreadByIndexID(index_id).get(); +Thread *new_thread = nullptr; +if (m_options.m_thread_id) { +new_thread = process->GetThreadList().FindThreadByID(index_id).get(); +} else { +new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get(); +} if (new_thread == nullptr) { - result.AppendErrorWithFormat("invalid thread #%s.\n", + result.AppendErrorWithFormat("invalid thread %s%s.\n", + m_options.m_thread_id ? "ID " : "#", command.GetArgumentAtIndex(0)); return; } @@ -1196,6 +1241,8 @@ class CommandObjectThreadSelect : public CommandObjectParsed { process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true); result.SetStatus(eReturnStatusSuccessFinishNoResult); } + + CommandOptions m_options; }; // CommandObjectThreadList diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index 542c78be5a12dad..23886046df8f673 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -1117,6 +1117,11 @@ let Command = "thread plan list" in { Desc<"Display thread plans for unreported threads">; } +let Command = "thread select" in { + def thread_thread_id : Option<"thread_id", "t">, +Desc<"Provide a thread ID instead of a thread index.">; +} + let Command = "thread trace dump function calls" in { def thread_trace_dump_function_calls_file : Option<"file", "F">, Group<1>, Arg<"Filename">, diff --git a/lldb/test/API/commands/thread/select/TestThreadSelect.py b/lldb/test/AP
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -1618,12 +1621,15 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, if (symbol->ValueIsAddress()) { DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, all_ranges, strm); + symbol->GetAddressRef(), verbose, all_ranges, strm, + use_color ? name : nullptr); DavidSpickett wrote: Enable colours symbol lookup name (no regex option) Expect that the results have no colouring https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [mlir] [clang-tools-extra] [clang] [lldb] [llvm] [compiler-rt] [libc] [flang] [DAGCombiner] Combine frem into fdiv+ftrunc+fma (PR #67642)
https://github.com/ecnelises updated https://github.com/llvm/llvm-project/pull/67642 >From 2ff3a666e4347f9224c1a406126282d98e3c9633 Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Thu, 28 Sep 2023 16:09:40 +0800 Subject: [PATCH 1/2] [DAGCombiner] Combine frem into fdiv+ftrunc+fma --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 ++ llvm/test/CodeGen/PowerPC/frem.ll | 142 +- 2 files changed, 49 insertions(+), 105 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 0d34ebb117667aa..2f5f295e199188a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -16958,6 +16958,18 @@ SDValue DAGCombiner::visitFREM(SDNode *N) { if (SDValue NewSel = foldBinOpIntoSelect(N)) return NewSel; + // (frem x, y) -> (fma (fneg (ftrunc (fdiv x, y))), y, x) + if (Flags.hasApproximateFuncs() && Flags.hasNoSignedZeros() && + Flags.hasNoInfs() && !TLI.isOperationLegalOrCustom(ISD::FREM, VT) && + TLI.isOperationLegalOrCustom(ISD::FTRUNC, VT) && + TLI.isOperationLegalOrCustom(ISD::FMA, VT)) { +SDLoc Loc(N); +SDValue Div = DAG.getNode(ISD::FDIV, Loc, VT, N0, N1); +SDValue Trunc = DAG.getNode(ISD::FTRUNC, Loc, VT, Div); +return DAG.getNode(ISD::FMA, Loc, VT, + DAG.getNode(ISD::FNEG, Loc, VT, Trunc), N1, N0); + } + return SDValue(); } diff --git a/llvm/test/CodeGen/PowerPC/frem.ll b/llvm/test/CodeGen/PowerPC/frem.ll index 8cb68e60f7f9b71..dff9c796289e96e 100644 --- a/llvm/test/CodeGen/PowerPC/frem.ll +++ b/llvm/test/CodeGen/PowerPC/frem.ll @@ -4,16 +4,13 @@ define float @frem32(float %a, float %b) { ; CHECK-LABEL: frem32: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT:mflr 0 -; CHECK-NEXT:stdu 1, -32(1) -; CHECK-NEXT:std 0, 48(1) -; CHECK-NEXT:.cfi_def_cfa_offset 32 -; CHECK-NEXT:.cfi_offset lr, 16 -; CHECK-NEXT:bl fmodf -; CHECK-NEXT:nop -; CHECK-NEXT:addi 1, 1, 32 -; CHECK-NEXT:ld 0, 16(1) -; CHECK-NEXT:mtlr 0 +; CHECK-NEXT:xsresp 0, 2 +; CHECK-NEXT:fmr 4, 1 +; CHECK-NEXT:xsmulsp 3, 1, 0 +; CHECK-NEXT:xsnmsubasp 4, 2, 3 +; CHECK-NEXT:xsmaddasp 3, 0, 4 +; CHECK-NEXT:xsrdpiz 0, 3 +; CHECK-NEXT:xsnmsubasp 1, 0, 2 ; CHECK-NEXT:blr entry: %rem = frem fast float %a, %b @@ -23,16 +20,17 @@ entry: define double @frem64(double %a, double %b) { ; CHECK-LABEL: frem64: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT:mflr 0 -; CHECK-NEXT:stdu 1, -32(1) -; CHECK-NEXT:std 0, 48(1) -; CHECK-NEXT:.cfi_def_cfa_offset 32 -; CHECK-NEXT:.cfi_offset lr, 16 -; CHECK-NEXT:bl fmod -; CHECK-NEXT:nop -; CHECK-NEXT:addi 1, 1, 32 -; CHECK-NEXT:ld 0, 16(1) -; CHECK-NEXT:mtlr 0 +; CHECK-NEXT:vspltisw 2, -1 +; CHECK-NEXT:xsredp 0, 2 +; CHECK-NEXT:fmr 4, 1 +; CHECK-NEXT:xvcvsxwdp 3, 34 +; CHECK-NEXT:xsmaddadp 3, 2, 0 +; CHECK-NEXT:xsnmsubadp 0, 0, 3 +; CHECK-NEXT:xsmuldp 3, 1, 0 +; CHECK-NEXT:xsnmsubadp 4, 2, 3 +; CHECK-NEXT:xsmaddadp 3, 0, 4 +; CHECK-NEXT:xsrdpiz 0, 3 +; CHECK-NEXT:xsnmsubadp 1, 0, 2 ; CHECK-NEXT:blr entry: %rem = frem fast double %a, %b @@ -42,59 +40,13 @@ entry: define <4 x float> @frem4x32(<4 x float> %a, <4 x float> %b) { ; CHECK-LABEL: frem4x32: ; CHECK: # %bb.0: # %entry -; CHECK-NEXT:mflr 0 -; CHECK-NEXT:stdu 1, -96(1) -; CHECK-NEXT:std 0, 112(1) -; CHECK-NEXT:.cfi_def_cfa_offset 96 -; CHECK-NEXT:.cfi_offset lr, 16 -; CHECK-NEXT:.cfi_offset v28, -64 -; CHECK-NEXT:.cfi_offset v29, -48 -; CHECK-NEXT:.cfi_offset v30, -32 -; CHECK-NEXT:.cfi_offset v31, -16 -; CHECK-NEXT:xxsldwi 0, 34, 34, 3 -; CHECK-NEXT:stxv 60, 32(1) # 16-byte Folded Spill -; CHECK-NEXT:xscvspdpn 1, 0 -; CHECK-NEXT:xxsldwi 0, 35, 35, 3 -; CHECK-NEXT:stxv 61, 48(1) # 16-byte Folded Spill -; CHECK-NEXT:stxv 62, 64(1) # 16-byte Folded Spill -; CHECK-NEXT:stxv 63, 80(1) # 16-byte Folded Spill -; CHECK-NEXT:xscvspdpn 2, 0 -; CHECK-NEXT:vmr 31, 3 -; CHECK-NEXT:vmr 30, 2 -; CHECK-NEXT:bl fmodf -; CHECK-NEXT:nop -; CHECK-NEXT:xxsldwi 0, 62, 62, 1 -; CHECK-NEXT:xscpsgndp 61, 1, 1 -; CHECK-NEXT:xscvspdpn 1, 0 -; CHECK-NEXT:xxsldwi 0, 63, 63, 1 -; CHECK-NEXT:xscvspdpn 2, 0 -; CHECK-NEXT:bl fmodf -; CHECK-NEXT:nop -; CHECK-NEXT:# kill: def $f1 killed $f1 def $vsl1 -; CHECK-NEXT:xxmrghd 0, 1, 61 -; CHECK-NEXT:xscvspdpn 1, 62 -; CHECK-NEXT:xscvspdpn 2, 63 -; CHECK-NEXT:xvcvdpsp 60, 0 -; CHECK-NEXT:bl fmodf -; CHECK-NEXT:nop -; CHECK-NEXT:xxswapd 0, 62 -; CHECK-NEXT:xscpsgndp 61, 1, 1 -; CHECK-NEXT:xscvspdpn 1, 0 -; CHECK-NEXT:xxswapd 0, 63 -; CHECK-NEXT:xscvspdpn 2, 0 -; CHECK-NEXT:bl fmodf -; CHECK-NEXT:nop -; CHECK-NEXT:# kill: def $f1 killed $f1 def $vsl1 -; CHECK-NEXT:xxmrghd 0, 61, 1 -; CHE
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -1618,12 +1621,15 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, if (symbol->ValueIsAddress()) { DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, all_ranges, strm); + symbol->GetAddressRef(), verbose, all_ranges, strm, + use_color ? name : nullptr); DavidSpickett wrote: I think there might be a bug here. We have this `name_is_regex` and this is not checking it. Should it be: ``` use_color && name_is_regex ? name : nullptr ``` So that when we have colours enabled, but do not search by regex, we do not get coloring. First step to confirm would be to add a test that checks this and see if it fails. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?Jos=C3=A9?= L. Junior Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + size_t last_pos = 0; + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); +Printf(format_str.c_str(), match.str().c_str()); +last_pos = match_start_pos + match.size(); +remaining = remaining.drop_front(last_pos); DavidSpickett wrote: Since last_pos is only used within the loop, declare it here as well. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
mdko wrote: [Latest changes]() update help and usage text, format specifier, add a general thread ID completion mechanism, and use this thread ID completion in the `thread select -t` argument. (If the thread ID completer is satisfactory, I can add it to other ThreadID args in [Options.td](https://github.com/mdko/llvm-project/blob/main/lldb/source/Commands/Options.td) in a later PR.) Example: ``` michristensen@devbig356 llvm/Debug » ./bin/lldb ~/scratch/cpp/threading/a.out NAME PASS STOP NOTIFY === === === === SIGPIPE true falsefalse (lldb) target create "/home/michristensen/scratch/cpp/threading/a.out" Current executable set to '/home/michristensen/scratch/cpp/threading/a.out' (x86_64). (lldb) b 18 Breakpoint 1: where = a.out`main + 80 at main.cpp:18:12, address = 0x0850 (lldb) run Process 2749371 launched: '/home/michristensen/scratch/cpp/threading/a.out' (x86_64) This is a thread, i=1 This is a thread, i=2 This is a thread, i=3 This is a thread, i=4 This is a thread, i=5 Process 2749371 stopped * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x55400850 a.out`main at main.cpp:18:12 15 for (int i = 0; i < 5; i++) { 16 pthread_create(&thread_ids[i], NULL, foo, NULL); 17 } -> 18 for (int i = 0; i < 5; i++) { 19 pthread_join(thread_ids[i], NULL); 20 } 21 return 0; (lldb) thread list Process 2749371 stopped * thread #1: tid = 2749371, 0x55400850 a.out`main at main.cpp:18:12, name = 'a.out', stop reason = breakpoint 1.1 thread #2: tid = 2749646, 0x768f9918 libc.so.6`__nanosleep + 72, name = 'a.out' thread #3: tid = 2749647, 0x768f9918 libc.so.6`__nanosleep + 72, name = 'a.out' thread #4: tid = 2749648, 0x768f9918 libc.so.6`__nanosleep + 72, name = 'a.out' thread #5: tid = 2749649, 0x768f9918 libc.so.6`__nanosleep + 72, name = 'a.out' thread #6: tid = 2749650, 0x768f9918 libc.so.6`__nanosleep + 72, name = 'a.out' (lldb) thread select -t 2749 Available completions: 2749371 -- * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x55400850 a.out`main at main.cpp:18:12 15 for (int i = 0; i < 5; i++) { 16 pthread_create(&thread_ids[i], NULL, foo, NULL); 17 } -> 18 for (int i = 0; i < 5; i++) { 19 pthread_join(thread_ids[i], NULL); 20 } 21 return 0; 2749646 -- thread #2, name = 'a.out' frame #0: 0x768f9918 libc.so.6`__nanosleep + 72 libc.so.6`__nanosleep: -> 0x768f9918 <+72>: cmpq $-0x1000, %rax ; imm = 0xF000 0x768f991e <+78>: ja 0x768f9952 ; <+130> 0x768f9920 <+80>: movl %edx, %edi 0x768f9922 <+82>: movl %eax, 0xc(%rsp) 2749647 -- thread #3, name = 'a.out' frame #0: 0x768f9918 libc.so.6`__nanosleep + 72 libc.so.6`__nanosleep: -> 0x768f9918 <+72>: cmpq $-0x1000, %rax ; imm = 0xF000 0x768f991e <+78>: ja 0x768f9952 ; <+130> 0x768f9920 <+80>: movl %edx, %edi 0x768f9922 <+82>: movl %eax, 0xc(%rsp) 2749648 -- thread #4, name = 'a.out' frame #0: 0x768f9918 libc.so.6`__nanosleep + 72 libc.so.6`__nanosleep: -> 0x768f9918 <+72>: cmpq $-0x1000, %rax ; imm = 0xF000 0x768f991e <+78>: ja 0x768f9952 ; <+130> 0x768f9920 <+80>: movl %edx, %edi 0x768f9922 <+82>: movl %eax, 0xc(%rsp) 2749649 -- thread #5, name = 'a.out' frame #0: 0x768f9918 libc.so.6`__nanosleep + 72 libc.so.6`__nanosleep: -> 0x768f9918 <+72>: cmpq $-0x1000, %rax ; imm = 0xF000 0x768f991e <+78>: ja 0x768f9952 ; <+130> 0x768f9920 <+80>: movl %edx, %edi 0x768f9922 <+82>: movl %eax, 0xc(%rsp) 2749650 -- thread #6, name = 'a.out' frame #0: 0x768f9918 libc.so.6`__nanosleep + 72 libc.so.6`__nanosleep: -> 0x768f9918 <+72>: cmpq $-0x1000, %rax ; imm = 0xF000 0x768f991e <+78>: ja 0x768f9952 ; <+130> 0x768f9920 <+80>: movl %edx, %edi 0x768f9922 <+82>: movl %eax, 0xc(%rsp) (lldb) thread select -t 2749371 * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x55400850 a.out`main at main.cpp:18:12 15 for (int i = 0; i < 5; i++) { 16 pthread_create(&thread_ids[i], NULL, foo, NULL); 17 } -> 18 for (int i = 0; i < 5; i++) { 19 pthread_join(thread_ids[i], NULL); 20 } 21 return 0; (lldb) thread select Available completions: 1 -- * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x55400850 a.out`main at main.cpp:18:12 15 for (int i = 0; i < 5; i++) { 16 pthread_create(&thread_ids[i], NULL, foo, NULL); 17 } -> 18 for (int i = 0; i < 5; i++) { 19 pthread_join(thread_ids[i], NULL); 20 } 21 return 0;
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; DavidSpickett wrote: > It would not allow me to create a PR that did not pass clang-format. Can you be more specific here, you could not open a PR at all without it being formatted? If that's the case it doesn't seem like what anyone would have intended. Your other workaround here would be to do a PR to reformat these files, then rebase this onto that after landing it. Review has already started though, so maybe do that as the last thing after approvals. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/taalhaataahir0102 updated https://github.com/llvm/llvm-project/pull/69422 >From c416443a93f7113a7f57d337682ec4862438522d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= Date: Tue, 7 Nov 2023 16:57:18 -0300 Subject: [PATCH 1/3] [lldb] colorize symbols in image lookup This creates the method PutCStringColorHighlighted for Stream class, which highlights searched symbols in red color for the image lookup command. A new shell test was added to verify functionality. Relevant methods were updated to accept the searched pattern/symbol as a parameter. Co-authored-by: Talha --- lldb/include/lldb/Core/Address.h | 4 +- lldb/include/lldb/Symbol/Symbol.h | 4 +- lldb/include/lldb/Symbol/SymbolContext.h | 8 ++-- lldb/include/lldb/Utility/Stream.h| 16 lldb/source/Commands/CommandObjectTarget.cpp | 16 +--- lldb/source/Core/Address.cpp | 21 ++ lldb/source/Symbol/Symbol.cpp | 18 ++--- lldb/source/Symbol/SymbolContext.cpp | 16 +--- lldb/source/Utility/Stream.cpp| 28 + .../Commands/command-image-lookup-color.test | 39 +++ 10 files changed, 138 insertions(+), 32 deletions(-) create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index b19e694427546f8..c3f2832be424efd 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -246,8 +246,8 @@ class Address { /// \see Address::DumpStyle bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style = DumpStyleInvalid, -uint32_t addr_byte_size = UINT32_MAX, -bool all_ranges = false) const; +uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false, +const char *pattern = nullptr) const; AddressClass GetAddressClass() const; diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index 44a2d560010fe40..0e41cd95e0ef17d 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope { void SetFlags(uint32_t flags) { m_flags = flags; } - void GetDescription(Stream *s, lldb::DescriptionLevel level, - Target *target) const; + void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, + const char *pattern = nullptr) const; bool IsSynthetic() const { return m_is_synthetic; } diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index b0f5ffead2a1656..9567c3f4384c175 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -150,8 +150,8 @@ class SymbolContext { bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, - bool show_function_arguments, - bool show_function_name) const; + bool show_function_arguments, bool show_function_name, + const char *pattern = nullptr) const; /// Get the address range contained within a symbol context. /// @@ -217,8 +217,8 @@ class SymbolContext { /// The symbol that was found, or \b nullptr if none was found. const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error); - void GetDescription(Stream *s, lldb::DescriptionLevel level, - Target *target) const; + void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, + const char *pattern = nullptr) const; uint32_t GetResolvedMask() const; diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index 1a5fd343e4df0dc..8e3fd48dfe70579 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -231,6 +231,22 @@ class Stream { /// The string to be output to the stream. size_t PutCString(llvm::StringRef cstr); + /// Output a C string to the stream with color highlighting. + /// + /// Print a C string \a text to the stream, applying red color highlighting to + /// the portions of the string that match the regex pattern \a pattern. The + /// pattern is matched as many times as possible throughout the string. If \a + /// pattern is nullptr, then no highlighting is applied. + /// + /// \param[in] text + /// The string to be output to the stream. + /// + /// \param[in] pattern + /// The regex pattern to match against the \a text string. Portions of \a + /// te
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -1618,12 +1621,15 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, if (symbol->ValueIsAddress()) { DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, all_ranges, strm); + symbol->GetAddressRef(), verbose, all_ranges, strm, + use_color ? name : nullptr); taalhaataahir0102 wrote: Ohh didn't realize this one. Thanks for pointing out. Have updated the code and added a test case using image lookup command without regex flag. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?Jos=C3=A9?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + size_t last_pos = 0; + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); +Printf(format_str.c_str(), match.str().c_str()); +last_pos = match_start_pos + match.size(); +remaining = remaining.drop_front(last_pos); taalhaataahir0102 wrote: Updated. Have limited last_pos to the scoop of loop https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/taalhaataahir0102 edited https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?Jos=C3=A9?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/DavidSpickett commented: Some minor comments on the printing loop. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?Jos=C3=A9?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + while (reg_pattern.match(remaining, &matches)) { DavidSpickett wrote: Blank line before the while please. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); DavidSpickett wrote: Here you could say: ``` PutCString(remaining.take_front(match_start_pos); ``` Just so that you're always using `PutCString`, intead of 1 `Write` and 1 `PutCString`. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); +size_t last_pos = match_start_pos; +Printf(format_str.c_str(), match.str().c_str()); DavidSpickett wrote: So because a StringRef doesn't point to a null terminated string (not always anyway) we have to make a std::string here. But... Instead what you could do is include the string length in the format string using `%.*s`, then the arguments would be `format.c_str(), match.size(), match.data()`. And the `*` becomes the match size and there's no need for `match.data()` to point to something null terminated. Therefore no need to make a std::string copy. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); +size_t last_pos = match_start_pos; +Printf(format_str.c_str(), match.str().c_str()); DavidSpickett wrote: https://cplusplus.com/reference/cstdio/printf/ "The precision is not specified in the format string..." https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
@@ -1618,12 +1621,15 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, if (symbol->ValueIsAddress()) { DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, all_ranges, strm); + symbol->GetAddressRef(), verbose, all_ranges, strm, + use_color ? name : nullptr); junior-jl wrote: Hi, David. I have a question about this one: Why wouldn't we want to colorize the symbols when searching without regex option? https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: @@ -1618,12 +1621,15 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, if (symbol->ValueIsAddress()) { DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), - symbol->GetAddressRef(), verbose, all_ranges, strm); + symbol->GetAddressRef(), verbose, all_ranges, strm, + use_color ? name : nullptr); DavidSpickett wrote: Yeah, I'm not 100% it should be regex only but my logic was that non-regex search looks for identical names, so the highlighting doesn't help you understand the result any more than the plain text does: ``` (lldb) image lookup -s ma (lldb) image lookup -s main 1 symbols match 'main' in /tmp/test.o: Address: test.o[0x074c] (test.o.PT_LOAD[0]..text + 316) Summary: test.o`main ``` The name will only ever show up if it matched exactly. Only when you've got something that could match in different ways does the colour help me: ``` (lldb) image lookup -s ma --regex 3 symbols match the regular expression 'ma' in /tmp/test.o: Name: __libc_start_main@@GLIBC_2.17 Value: 0x Address: test.o[0x074c] (test.o.PT_LOAD[0]..text + 316) Summary: test.o`main Address: test.o[0x05e0] (test.o.PT_LOAD[0]..plt + 48) Summary: test.o`symbol stub for: __libc_start_main <...> ``` Because it tells me what it matched. But I am bringing my bias in here, I understand what all the lines of output mean. Maybe if I didn't, I would appreciate knowing where my search term shows up? On the other hand, highlighting the same thing 99 times might just be noise on top of an already large amount of output. So I'm being 1. biased and 2. conservative. Perhaps you would find the highlighting useful in both modes, if so we can keep it. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [llvm] [mlir] [polly] [clang] [libc] [libcxx] [openmp] [lldb] [C API] Add support for setting/getting new nneg flag on zext instructions (PR #73592)
Benjins wrote: Bumping this: if it's good to land, can someone with write access merge it? https://github.com/llvm/llvm-project/pull/73592 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [llvm] [mlir] [polly] [clang] [libc] [libcxx] [openmp] [lldb] [C API] Add support for setting/getting new nneg flag on zext instructions (PR #73592)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/73592 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( cmtice wrote: It indicates the that these are constants. I can remove it if you like? https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; cmtice wrote: DavidSpickett: I created the PR, sort of, but... if you look at the bottom of this PR (for example) there's a small section that says "All Checks Passed". If you open that, you will see that one of the checks is a clang-format check. My original PR did not pass that check, so github would not "finish" creating the PR, i.e. it would not allow me to ask for reviews on it. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Do not land, just testing the formatting job! (PR #73811)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/73811 None >From 27e279c17fb7747f252b4eca58e3dd1d44845191 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Wed, 29 Nov 2023 16:03:37 + Subject: [PATCH] Do not land, just testing the formatting job! --- lldb/source/Utility/Scalar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index 5ad68065bce1b76..dc5c88724762c44 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -31,7 +31,7 @@ using llvm::APSInt; Scalar::PromotionKey Scalar::GetPromoKey() const { switch (m_type) { case e_void: -return PromotionKey{e_void, 0, false}; +return PromotionKey{e_void, 0, false }; case e_int: return PromotionKey{e_int, m_integer.getBitWidth(), m_integer.isUnsigned()}; case e_float: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Do not land, just testing the formatting job! (PR #73811)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/73811.diff 1 Files Affected: - (modified) lldb/source/Utility/Scalar.cpp (+1-1) ``diff diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index 5ad68065bce1b76..dc5c88724762c44 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -31,7 +31,7 @@ using llvm::APSInt; Scalar::PromotionKey Scalar::GetPromoKey() const { switch (m_type) { case e_void: -return PromotionKey{e_void, 0, false}; +return PromotionKey{e_void, 0, false }; case e_int: return PromotionKey{e_int, m_integer.getBitWidth(), m_integer.isUnsigned()}; case e_float: `` https://github.com/llvm/llvm-project/pull/73811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Do not land, just testing the formatting job! (PR #73811)
DavidSpickett wrote: Want to know if I'm allowed to add reviewers if the initial clang-format fails. https://github.com/llvm/llvm-project/pull/73811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Do not land, just testing the formatting job! (PR #73811)
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 953d675c42c254676ca446951bd728abefecf436 27e279c17fb7747f252b4eca58e3dd1d44845191 -- lldb/source/Utility/Scalar.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index dc5c887247..5ad68065bc 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -31,7 +31,7 @@ using llvm::APSInt; Scalar::PromotionKey Scalar::GetPromoKey() const { switch (m_type) { case e_void: -return PromotionKey{e_void, 0, false }; +return PromotionKey{e_void, 0, false}; case e_int: return PromotionKey{e_int, m_integer.getBitWidth(), m_integer.isUnsigned()}; case e_float: `` https://github.com/llvm/llvm-project/pull/73811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Do not land, just testing the formatting job! (PR #73811)
DavidSpickett wrote: I was able to add reviewers. https://github.com/llvm/llvm-project/pull/73811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Do not land, just testing the formatting job! (PR #73811)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/73811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; DavidSpickett wrote: That's annoying for sure. I'm a member of the repo, and I was able to add reviewers to this test PR https://github.com/llvm/llvm-project/pull/7381 that failed clang-format. Then again, Github tells me you're also a member, so that can't be the problem. Strange. If you can figure out the sequence of events or reproduce it, please open an issue because I'm not sure it's intended behaviour. Perhaps we're trying to be strict but still, there should be some way to ignore the check when needed. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; felipepiovezan wrote: I could be wrong here, but AFAICT the bot should _only_ check for formatting changes inside the diff of the commit, not inside the entire file. If this is not what the bot is doing, it is something we can probably improve upon. In the meantime though, my suggestion is to manually inspect the bot output: if it is complaining about lines not touched by this commit, just ignore that. This is favorable to editing lines that are not related to the patch https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; felipepiovezan wrote: I see this comment in [another PR](https://github.com/llvm/llvm-project/pull/73252#issuecomment-1832242278) > NB: not applying all the clang-format recommendations as it affects lines I'm > not editing, and I don't want to pollute git-blame That makes me think the bot is not running clang-format-diff? https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( bulbazord wrote: Oh I see, I don't mind it being there. Just hadn't seen it before. If they're constants though, then please mark them `const` as well. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; cmtice wrote: Question: For this PR, do you want me to un-do the clang-format changes that don't relate to my changes? https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Allow lldb to load .dwp files with large .debug_info or .debug_types. (PR #73736)
https://github.com/JDevlieghere approved this pull request. Makes sense to me! https://github.com/llvm/llvm-project/pull/73736 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
https://github.com/jimingham approved this pull request. This is great. Thanks for adding the thread ID completer as well! https://github.com/llvm/llvm-project/pull/73596 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
@@ -807,6 +808,23 @@ void CommandCompletions::TypeCategoryNames(CommandInterpreter &interpreter, }); } +void CommandCompletions::ThreadIDs(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + const ExecutionContext &exe_ctx = interpreter.GetExecutionContext(); + if (!exe_ctx.HasProcessScope()) +return; + + ThreadList &threads = exe_ctx.GetProcessPtr()->GetThreadList(); + lldb::ThreadSP thread_sp; + for (uint32_t idx = 0; (thread_sp = threads.GetThreadAtIndex(idx)); ++idx) { felipepiovezan wrote: minor nit, don't block the review on this, but why do you have ()s here? https://github.com/llvm/llvm-project/pull/73596 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Remove redundant parameter to AddMethodToObjCObjectType (PR #73832)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/73832 This parameter isn't used (neither in upstream LLVM nor in the Apple fork). This patch removes it. This parameter seems to have been unused since its introduction in `0f581665b768d100eece196e59b00eb16e7e`. This gets us a step closer to making `ParsedDWARFTypeAttributes` a `const`, which will make this function easier to refactor in upcoming patches. >From 48676104d471010265090004fee4cbe23adde214 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 29 Nov 2023 17:11:42 + Subject: [PATCH] [lldb][DWARFASTParserClang][NFC] Remove redundant parameter to AddMethodToObjCObjectType This parameter isn't used (neither in upstream LLVM nor in the Apple fork). This patch removes it. This parameter seems to have been unused since its introduction in `0f581665b768d100eece196e59b00eb16e7e`. This gets us a step closer to making `ParsedDWARFTypeAttributes` a `const`, which will make this function easier to refactor in upcoming patches. --- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 8 +--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++-- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h| 4 ++-- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 3 +-- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 4d7d27b64e4c7f2..3d722033c824db4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1090,16 +1090,10 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, } if (class_opaque_type) { - // If accessibility isn't set to anything valid, assume public - // for now... - if (attrs.accessibility == eAccessNone) -attrs.accessibility = eAccessPublic; - clang::ObjCMethodDecl *objc_method_decl = m_ast.AddMethodToObjCObjectType( class_opaque_type, attrs.name.GetCString(), clang_type, - attrs.accessibility, attrs.is_artificial, is_variadic, - attrs.is_objc_direct_call); + attrs.is_artificial, is_variadic, attrs.is_objc_direct_call); type_handled = objc_method_decl != nullptr; if (type_handled) { LinkDeclContextToDIE(objc_method_decl, die); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 6f65587c4acedd1..7c28935f5741c54 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -8110,8 +8110,8 @@ clang::ObjCMethodDecl *TypeSystemClang::AddMethodToObjCObjectType( const char *name, // the full symbol name as seen in the symbol table // (lldb::opaque_compiler_type_t type, "-[NString // stringWithCString:]") -const CompilerType &method_clang_type, lldb::AccessType access, -bool is_artificial, bool is_variadic, bool is_objc_direct_call) { +const CompilerType &method_clang_type, bool is_artificial, bool is_variadic, +bool is_objc_direct_call) { if (!type || !method_clang_type.IsValid()) return nullptr; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 0ec2d026e996105..19f267396e0f0e5 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -985,8 +985,8 @@ class TypeSystemClang : public TypeSystem { const char *name, // the full symbol name as seen in the symbol table // (lldb::opaque_compiler_type_t type, "-[NString // stringWithCString:]") - const CompilerType &method_compiler_type, lldb::AccessType access, - bool is_artificial, bool is_variadic, bool is_objc_direct_call); + const CompilerType &method_compiler_type, bool is_artificial, + bool is_variadic, bool is_objc_direct_call); static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern); diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp index c83e6ed1d418922..30d20b9587f9130 100644 --- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -941,8 +941,7 @@ TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) { bool artificial = false; bool objc_direct = false; clang::ObjCMethodDecl *method = TypeSystemClang::AddMethodToObjCObjectType( - c, "-[A foo]", func_type, lldb::eAccessPublic, artificial, variadic, - objc_direct); +
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Remove redundant parameter to AddMethodToObjCObjectType (PR #73832)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This parameter isn't used (neither in upstream LLVM nor in the Apple fork). This patch removes it. This parameter seems to have been unused since its introduction in `0f581665b768d100eece196e59b00eb16e7e`. This gets us a step closer to making `ParsedDWARFTypeAttributes` a `const`, which will make this function easier to refactor in upcoming patches. --- Full diff: https://github.com/llvm/llvm-project/pull/73832.diff 4 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+1-7) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-2) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+2-2) - (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+1-2) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 4d7d27b64e4c7f2..3d722033c824db4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1090,16 +1090,10 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, } if (class_opaque_type) { - // If accessibility isn't set to anything valid, assume public - // for now... - if (attrs.accessibility == eAccessNone) -attrs.accessibility = eAccessPublic; - clang::ObjCMethodDecl *objc_method_decl = m_ast.AddMethodToObjCObjectType( class_opaque_type, attrs.name.GetCString(), clang_type, - attrs.accessibility, attrs.is_artificial, is_variadic, - attrs.is_objc_direct_call); + attrs.is_artificial, is_variadic, attrs.is_objc_direct_call); type_handled = objc_method_decl != nullptr; if (type_handled) { LinkDeclContextToDIE(objc_method_decl, die); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 6f65587c4acedd1..7c28935f5741c54 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -8110,8 +8110,8 @@ clang::ObjCMethodDecl *TypeSystemClang::AddMethodToObjCObjectType( const char *name, // the full symbol name as seen in the symbol table // (lldb::opaque_compiler_type_t type, "-[NString // stringWithCString:]") -const CompilerType &method_clang_type, lldb::AccessType access, -bool is_artificial, bool is_variadic, bool is_objc_direct_call) { +const CompilerType &method_clang_type, bool is_artificial, bool is_variadic, +bool is_objc_direct_call) { if (!type || !method_clang_type.IsValid()) return nullptr; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 0ec2d026e996105..19f267396e0f0e5 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -985,8 +985,8 @@ class TypeSystemClang : public TypeSystem { const char *name, // the full symbol name as seen in the symbol table // (lldb::opaque_compiler_type_t type, "-[NString // stringWithCString:]") - const CompilerType &method_compiler_type, lldb::AccessType access, - bool is_artificial, bool is_variadic, bool is_objc_direct_call); + const CompilerType &method_compiler_type, bool is_artificial, + bool is_variadic, bool is_objc_direct_call); static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern); diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp index c83e6ed1d418922..30d20b9587f9130 100644 --- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -941,8 +941,7 @@ TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) { bool artificial = false; bool objc_direct = false; clang::ObjCMethodDecl *method = TypeSystemClang::AddMethodToObjCObjectType( - c, "-[A foo]", func_type, lldb::eAccessPublic, artificial, variadic, - objc_direct); + c, "-[A foo]", func_type, artificial, variadic, objc_direct); ASSERT_NE(method, nullptr); // The interface decl should still have external lexical storage. `` https://github.com/llvm/llvm-project/pull/73832 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFCI] Make ParsedDWARFTypeAttributes parameter const (PR #73833)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/73833 This will make future refactorings of `ParseSubroutine` simpler. Depends on https://github.com/llvm/llvm-project/pull/73832 >From a8aa1c80c5ce7debaea356815d8a3b0a83b976f0 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 29 Nov 2023 17:23:19 + Subject: [PATCH] [lldb][DWARFASTParserClang][NFC] Make ParsedDWARFTypeAttributes parameter const This will make future refactorings of `ParseSubroutine` simpler. --- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 12 +++- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 4d7d27b64e4c7f2..6d6ac910feeb65b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -980,8 +980,9 @@ ConvertDWARFCallingConventionToClang(const ParsedDWARFTypeAttributes &attrs) { return clang::CC_C; } -TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, - ParsedDWARFTypeAttributes &attrs) { +TypeSP +DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, + const ParsedDWARFTypeAttributes &attrs) { Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); SymbolFileDWARF *dwarf = die.GetDWARF(); @@ -1206,14 +1207,15 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, // Neither GCC 4.2 nor clang++ currently set a valid // accessibility in the DWARF for C++ methods... // Default to public for now... - if (attrs.accessibility == eAccessNone) -attrs.accessibility = eAccessPublic; + const auto accessibility = attrs.accessibility == eAccessNone + ? eAccessPublic + : attrs.accessibility; clang::CXXMethodDecl *cxx_method_decl = m_ast.AddMethodToCXXRecordType( class_opaque_type.GetOpaqueQualType(), attrs.name.GetCString(), attrs.mangled_name, - clang_type, attrs.accessibility, attrs.is_virtual, + clang_type, accessibility, attrs.is_virtual, is_static, attrs.is_inline, attrs.is_explicit, is_attr_used, attrs.is_artificial); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 81b705a036189eb..7b495419cf3241b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -368,7 +368,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser { const lldb_private::plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs); lldb::TypeSP ParseSubroutine(const lldb_private::plugin::dwarf::DWARFDIE &die, - ParsedDWARFTypeAttributes &attrs); + const ParsedDWARFTypeAttributes &attrs); lldb::TypeSP ParseArrayType(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs); lldb::TypeSP ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFCI] Make ParsedDWARFTypeAttributes parameter const (PR #73833)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This will make future refactorings of `ParseSubroutine` simpler. Depends on https://github.com/llvm/llvm-project/pull/73832 --- Full diff: https://github.com/llvm/llvm-project/pull/73833.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+7-5) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (+1-1) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 4d7d27b64e4c7f2..6d6ac910feeb65b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -980,8 +980,9 @@ ConvertDWARFCallingConventionToClang(const ParsedDWARFTypeAttributes &attrs) { return clang::CC_C; } -TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, - ParsedDWARFTypeAttributes &attrs) { +TypeSP +DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, + const ParsedDWARFTypeAttributes &attrs) { Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); SymbolFileDWARF *dwarf = die.GetDWARF(); @@ -1206,14 +1207,15 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, // Neither GCC 4.2 nor clang++ currently set a valid // accessibility in the DWARF for C++ methods... // Default to public for now... - if (attrs.accessibility == eAccessNone) -attrs.accessibility = eAccessPublic; + const auto accessibility = attrs.accessibility == eAccessNone + ? eAccessPublic + : attrs.accessibility; clang::CXXMethodDecl *cxx_method_decl = m_ast.AddMethodToCXXRecordType( class_opaque_type.GetOpaqueQualType(), attrs.name.GetCString(), attrs.mangled_name, - clang_type, attrs.accessibility, attrs.is_virtual, + clang_type, accessibility, attrs.is_virtual, is_static, attrs.is_inline, attrs.is_explicit, is_attr_used, attrs.is_artificial); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 81b705a036189eb..7b495419cf3241b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -368,7 +368,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser { const lldb_private::plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs); lldb::TypeSP ParseSubroutine(const lldb_private::plugin::dwarf::DWARFDIE &die, - ParsedDWARFTypeAttributes &attrs); + const ParsedDWARFTypeAttributes &attrs); lldb::TypeSP ParseArrayType(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs); lldb::TypeSP `` https://github.com/llvm/llvm-project/pull/73833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from +// `type` to `target_type`. +bool CompilerType::IsVirtualBase(CompilerType target_base, + CompilerType *virtual_base, + bool carry_virtual) const { + if (CompareTypes(target_base)) { +return carry_virtual; + } + + if (!carry_virtual) { +uint32_t num_virtual_bases = GetNumVirtualBaseClasses(); +for (uint32_t i = 0; i < num_virtual_bases; ++i) { + uint32_t bit_offset; + auto base = GetVirtualBaseClassAtIndex(i, &bit_offset); + if (base.IsVirtualBase(target_base, virtual_base, + /*carry_virtual*/ true)) { +if (virtual_base) { + *virtual_base = base; +} +return true; + } +} + } + + uint32_t num_direct_bases = GetNumDirectBaseClasses(); + for (uint32_t i = 0; i < num_direct_bases; ++i) { +uint32_t bit_offset; +auto base = GetDirect
[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
@@ -807,6 +808,23 @@ void CommandCompletions::TypeCategoryNames(CommandInterpreter &interpreter, }); } +void CommandCompletions::ThreadIDs(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + const ExecutionContext &exe_ctx = interpreter.GetExecutionContext(); + if (!exe_ctx.HasProcessScope()) +return; + + ThreadList &threads = exe_ctx.GetProcessPtr()->GetThreadList(); + lldb::ThreadSP thread_sp; + for (uint32_t idx = 0; (thread_sp = threads.GetThreadAtIndex(idx)); ++idx) { mdko wrote: It's to avoid this warning: ``` /home/michristensen/llvm/llvm-project/lldb/source/Commands/CommandCompletions.cpp:820:36: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] for (uint32_t idx = 0; thread_sp = threads.GetThreadAtIndex(idx); ++idx) { ~~^~~ /home/michristensen/llvm/llvm-project/lldb/source/Commands/CommandCompletions.cpp:820:36: note: place parentheses around the assignment to silence this warning for (uint32_t idx = 0; thread_sp = threads.GetThreadAtIndex(idx); ++idx) { ``` It's also consistent to how it was done in the ThreadIndex completer code: https://github.com/llvm/llvm-project/blob/e109a2ea37b20141aad8c4db4d39ff56e8a6dc4e/lldb/source/Commands/CommandCompletions.cpp#L776 https://github.com/llvm/llvm-project/pull/73596 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; felipepiovezan wrote: Yes, please :) https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)
https://github.com/felipepiovezan edited https://github.com/llvm/llvm-project/pull/73596 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Allow lldb to load .dwp files with large .debug_info or .debug_types. (PR #73736)
https://github.com/ayermolo approved this pull request. Thanks for fixing places I missed. https://github.com/llvm/llvm-project/pull/73736 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ce00133 - Allow lldb to load .dwp files with large .debug_info or .debug_types. (#73736)
Author: Greg Clayton Date: 2023-11-29T11:19:50-08:00 New Revision: ce00133e5f5b243b320d55f7e57a3f8ad2c9 URL: https://github.com/llvm/llvm-project/commit/ce00133e5f5b243b320d55f7e57a3f8ad2c9 DIFF: https://github.com/llvm/llvm-project/commit/ce00133e5f5b243b320d55f7e57a3f8ad2c9.diff LOG: Allow lldb to load .dwp files with large .debug_info or .debug_types. (#73736) A previous patch to llvm allowed the DWARFUnitIndex class to handle .debug_info.dwo and .debug_types.dwo sections to go over 4GB by checking for this case and fixing up the DWARFUnitIndex. LLDB's DWARF parser tries to use the llvm's DWARF parser when it can, and LLDB's DWARF parser uses the llvm::DWARFUnitIndex which should allow us to load large .dwp files, but there were a few things missing on the LLDB front: - support for parsing DWARFUnit objects when the offset exceeds 4GB due to a 32 bit truncation issue - not populating the required DWARF sections when we call DWARFContext::GetAsLLVM() which didn't allow the fixups to happen as the data was missing. This patch fixes these issues and now allows LLDB to parse large .dwp files without issues. The issue was discovered when running the "target modules dump separate-debug-info" command on one of these binaries that used a large .dwp file. This is unfortunately hard to test without creating a huge .dwp file, so there are currently no tests for this that I can think of adding that wouldn't cause disk space constraints or making testing times longer by producing a huge .dwp file. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp index ee347036dbbc034..e3872dc626be038 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -142,7 +142,10 @@ llvm::DWARFContext &DWARFContext::GetAsLLVM() { AddSection("debug_line_str", getOrLoadLineStrData()); AddSection("debug_cu_index", getOrLoadCuIndexData()); AddSection("debug_tu_index", getOrLoadTuIndexData()); - +if (isDwo()) { + AddSection("debug_info.dwo", getOrLoadDebugInfoData()); + AddSection("debug_types.dwo", getOrLoadDebugTypesData()); +} m_llvm_context = llvm::DWARFContext::create(section_map, addr_size); } return *m_llvm_context; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index 3aef03712d00dc8..3f528e913d8cfab 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -76,7 +76,7 @@ class DWARFUnitHeader { return m_unit_type == llvm::dwarf::DW_UT_type || m_unit_type == llvm::dwarf::DW_UT_split_type; } - uint32_t GetNextUnitOffset() const { return m_offset + m_length + 4; } + dw_offset_t GetNextUnitOffset() const { return m_offset + m_length + 4; } llvm::Error ApplyIndexEntry(const llvm::DWARFUnitIndex::Entry *index_entry); @@ -157,7 +157,7 @@ class DWARFUnit : public UserID { // Size of the CU data (without initial length and without header). size_t GetDebugInfoSize() const; // Size of the CU data incl. header but without initial length. - uint32_t GetLength() const { return m_header.GetLength(); } + dw_offset_t GetLength() const { return m_header.GetLength(); } uint16_t GetVersion() const { return m_header.GetVersion(); } const llvm::DWARFAbbreviationDeclarationSet *GetAbbreviations() const; dw_offset_t GetAbbrevOffset() const; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Allow lldb to load .dwp files with large .debug_info or .debug_types. (PR #73736)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/73736 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -194,6 +192,54 @@ class CompilerType { bool IsTypedefType() const; bool IsVoidType() const; + + bool IsSmartPtrType() const; + + bool IsInteger() const; + + bool IsFloat() const; + + bool IsEnumerationType() const; + + bool IsUnscopedEnumerationType() const; + + bool IsIntegerOrUnscopedEnumerationType() const; + + bool IsSigned() const; + + bool IsNullPtrType() const; + + bool IsBoolean() const; + + bool IsEnumerationIntegerTypeSigned() const; + + bool IsScalarOrUnscopedEnumerationType() const; + + bool IsPromotableIntegerType() const; + + bool IsPointerToVoid() const; + + bool IsRecordType() const; + + bool IsVirtualBase(CompilerType target_base, CompilerType *virtual_base, + bool carry_virtual = false) const; + + bool IsContextuallyConvertibleToBool() const; + + bool IsBasicType() const; + + std::string TypeDescription(); + + bool CompareTypes(CompilerType rhs) const; + + const char *GetTypeTag(); + + uint32_t GetNumberOfNonEmptyBaseClasses(); + + CompilerType GetTemplateArgumentType(uint32_t idx); + + CompilerType GetSmartPtrPointeeType(); cmtice wrote: Could you elaborate on this a little bit more please. I'm still learning the LLDB type system, and I don't quite understand what you're asking me to do. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [flang] [clang] [compiler-rt] [libcxx] [llvm] [lldb] [libc] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -1464,6 +1467,21 @@ class AnnotatingParser { } } + void parseEmbedDirective() { +if (CurrentToken && CurrentToken->is(tok::less)) { + next(); + while (CurrentToken) { +// Mark tokens up to the trailing line comments as implicit string +// literals. +if (CurrentToken->isNot(tok::comment) && +!CurrentToken->TokenText.startswith("//")) { + CurrentToken->setType(TT_ImplicitStringLiteral); owenca wrote: +1. https://github.com/llvm/llvm-project/pull/68620 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [flang] [clang] [compiler-rt] [libcxx] [llvm] [lldb] [libc] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
@@ -1464,6 +1467,21 @@ class AnnotatingParser { } } + void parseEmbedDirective() { +if (CurrentToken && CurrentToken->is(tok::less)) { + next(); + while (CurrentToken) { +// Mark tokens up to the trailing line comments as implicit string +// literals. +if (CurrentToken->isNot(tok::comment) && +!CurrentToken->TokenText.startswith("//")) { + CurrentToken->setType(TT_ImplicitStringLiteral); AaronBallman wrote: Thanks! When you get to the point of working on this, I'm happy to review/help how I can. https://github.com/llvm/llvm-project/pull/68620 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
@@ -1402,22 +1402,24 @@ void Debugger::SetDestroyCallback( static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, - bool is_debugger_specific) { + bool is_debugger_specific, + uint32_t is_aggregate) { medismailben wrote: nit: I'd use the enum type here instead of the `uint32_t` ```suggestion ProgressReportType report_type) { ``` https://github.com/llvm/llvm-project/pull/69516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
https://github.com/medismailben edited https://github.com/llvm/llvm-project/pull/69516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
@@ -55,6 +55,11 @@ namespace lldb_private { class Progress { public: + /// Enum that indicates the type of progress report + enum ProgressReportType { medismailben wrote: `enum class` ? https://github.com/llvm/llvm-project/pull/69516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
https://github.com/medismailben approved this pull request. LGTM with comments. https://github.com/llvm/llvm-project/pull/69516 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
https://github.com/cmtice updated https://github.com/llvm/llvm-project/pull/73472 >From a063ebd8ee8bbd491fff3449bc20d663d2e501ea Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Sun, 26 Nov 2023 17:24:39 -0800 Subject: [PATCH 1/2] [LLDB] Add more helper functions to CompilerType class (second try). This adds 23 new helper functions to LLDB's CompilerType class, things like IsSmartPtrType, IsPromotableIntegerType, GetNumberofNonEmptyBaseClasses, and GetTemplateArgumentType (to name a few). It also has run clang-format on the files CompilerType.{h,cpp}. These helper functions are needed as part of the implementation for the Data Inspection Language, (see https://discourse.llvm.org/t/rfc-data-inspection-language/69893). --- lldb/include/lldb/Symbol/CompilerType.h | 56 - lldb/source/Symbol/CompilerType.cpp | 285 ++-- 2 files changed, 320 insertions(+), 21 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 0a9533a1ac0efc1..a3331ad3269c01d 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -112,9 +112,7 @@ class CompilerType { /// Tests. /// \{ - explicit operator bool() const { -return m_type_system.lock() && m_type; - } + explicit operator bool() const { return m_type_system.lock() && m_type; } bool IsValid() const { return (bool)*this; } @@ -194,6 +192,54 @@ class CompilerType { bool IsTypedefType() const; bool IsVoidType() const; + + bool IsSmartPtrType() const; + + bool IsInteger() const; + + bool IsFloat() const; + + bool IsEnumerationType() const; + + bool IsUnscopedEnumerationType() const; + + bool IsIntegerOrUnscopedEnumerationType() const; + + bool IsSigned() const; + + bool IsNullPtrType() const; + + bool IsBoolean() const; + + bool IsEnumerationIntegerTypeSigned() const; + + bool IsScalarOrUnscopedEnumerationType() const; + + bool IsPromotableIntegerType() const; + + bool IsPointerToVoid() const; + + bool IsRecordType() const; + + bool IsVirtualBase(CompilerType target_base, CompilerType *virtual_base, + bool carry_virtual = false) const; + + bool IsContextuallyConvertibleToBool() const; + + bool IsBasicType() const; + + std::string TypeDescription(); + + bool CompareTypes(CompilerType rhs) const; + + const char *GetTypeTag(); + + uint32_t GetNumberOfNonEmptyBaseClasses(); + + CompilerType GetTemplateArgumentType(uint32_t idx); + + CompilerType GetSmartPtrPointeeType(); + /// \} /// Type Completion. @@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; + void DumpTypeDescription( + lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) const; /// Print a description of the type to a stream. The exact implementation /// varies, but the expectation is that eDescriptionLevelFull returns a diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 78cc8dad94a9c5f..854d6cab01b508e 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -54,7 +54,7 @@ bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size, if (IsValid()) if (auto type_system_sp = GetTypeSystem()) return type_system_sp->IsArrayType(m_type, element_type_ptr, size, - is_incomplete); + is_incomplete); if (element_type_ptr) element_type_ptr->Clear(); @@ -157,7 +157,8 @@ bool CompilerType::IsBlockPointerType( CompilerType *function_pointer_type_ptr) const { if (IsValid()) if (auto type_system_sp = GetTypeSystem()) - return type_system_sp->IsBlockPointerType(m_type, function_pointer_type_ptr); + return type_system_sp->IsBlockPointerType(m_type, +function_pointer_type_ptr); return false; } @@ -249,7 +250,7 @@ bool CompilerType::IsPossibleDynamicType(CompilerType *dynamic_pointee_type, if (IsValid()) if (auto type_system_sp = GetTypeSystem()) return type_system_sp->IsPossibleDynamicType(m_type, dynamic_pointee_type, -check_cplusplus, check_objc); + check_cplusplus, check_objc); return false; } @@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:aln
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -194,6 +192,54 @@ class CompilerType { bool IsTypedefType() const; bool IsVoidType() const; + + bool IsSmartPtrType() const; cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -194,6 +192,54 @@ class CompilerType { bool IsTypedefType() const; bool IsVoidType() const; + + bool IsSmartPtrType() const; + + bool IsInteger() const; + + bool IsFloat() const; + + bool IsEnumerationType() const; + + bool IsUnscopedEnumerationType() const; + + bool IsIntegerOrUnscopedEnumerationType() const; + + bool IsSigned() const; + + bool IsNullPtrType() const; + + bool IsBoolean() const; + + bool IsEnumerationIntegerTypeSigned() const; + + bool IsScalarOrUnscopedEnumerationType() const; + + bool IsPromotableIntegerType() const; + + bool IsPointerToVoid() const; + + bool IsRecordType() const; + + bool IsVirtualBase(CompilerType target_base, CompilerType *virtual_base, + bool carry_virtual = false) const; + + bool IsContextuallyConvertibleToBool() const; cmtice wrote: Done? I think? https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } cmtice wrote: Done (for entire change). https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
https://github.com/cmtice deleted https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from +// `type` to `target_type`. +bool CompilerType::IsVirtualBase(CompilerType target_base, + CompilerType *virtual_base, + bool carry_virtual) const { + if (CompareTypes(target_base)) { +return carry_virtual; + } cmtice wrote: Done (everywhere, I think). https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from +// `type` to `target_type`. +bool CompilerType::IsVirtualBase(CompilerType target_base, + CompilerType *virtual_base, + bool carry_virtual) const { + if (CompareTypes(target_base)) { +return carry_virtual; + } + + if (!carry_virtual) { +uint32_t num_virtual_bases = GetNumVirtualBaseClasses(); +for (uint32_t i = 0; i < num_virtual_bases; ++i) { + uint32_t bit_offset; + auto base = GetVirtualBaseClassAtIndex(i, &bit_offset); + if (base.IsVirtualBase(target_base, virtual_base, + /*carry_virtual*/ true)) { +if (virtual_base) { + *virtual_base = base; +} +return true; + } +} + } + + uint32_t num_direct_bases = GetNumDirectBaseClasses(); + for (uint32_t i = 0; i < num_direct_bases; ++i) { +uint32_t bit_offset; +auto base = GetDirect
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from +// `type` to `target_type`. +bool CompilerType::IsVirtualBase(CompilerType target_base, + CompilerType *virtual_base, + bool carry_virtual) const { + if (CompareTypes(target_base)) { +return carry_virtual; + } + + if (!carry_virtual) { +uint32_t num_virtual_bases = GetNumVirtualBaseClasses(); +for (uint32_t i = 0; i < num_virtual_bases; ++i) { + uint32_t bit_offset; + auto base = GetVirtualBaseClassAtIndex(i, &bit_offset); + if (base.IsVirtualBase(target_base, virtual_base, + /*carry_virtual*/ true)) { +if (virtual_base) { + *virtual_base = base; +} +return true; + } +} + } + + uint32_t num_direct_bases = GetNumDirectBaseClasses(); + for (uint32_t i = 0; i < num_direct_bases; ++i) { +uint32_t bit_offset; +auto base = GetDirect
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. cmtice wrote: Done. Renamed the libstdc++ variable names to contain 'libstdc++' instead of 'libc++'. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from cmtice wrote: Done (mostly). I still need to check on 'carry_virtual' and add a comment about it. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from +// `type` to `target_type`. +bool CompilerType::IsVirtualBase(CompilerType target_base, + CompilerType *virtual_base, + bool carry_virtual) const { + if (CompareTypes(target_base)) { +return carry_virtual; + } + + if (!carry_virtual) { +uint32_t num_virtual_bases = GetNumVirtualBaseClasses(); +for (uint32_t i = 0; i < num_virtual_bases; ++i) { + uint32_t bit_offset; + auto base = GetVirtualBaseClassAtIndex(i, &bit_offset); + if (base.IsVirtualBase(target_base, virtual_base, + /*carry_virtual*/ true)) { +if (virtual_base) { + *virtual_base = base; +} +return true; + } +} + } + + uint32_t num_direct_bases = GetNumDirectBaseClasses(); + for (uint32_t i = 0; i < num_direct_bases; ++i) { +uint32_t bit_offset; +auto base = GetDirect
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( + "^std::weak_ptr<.+>(( )?&)?$"); + // + llvm::StringRef name = GetTypeName(); + return k_libcxx_std_unique_ptr_regex.match(name) || + k_libcxx_std_shared_ptr_regex.match(name) || + k_libcxx_std_weak_ptr_regex.match(name) || + k_libcxx_std_unique_ptr_regex_2.match(name) || + k_libcxx_std_shared_ptr_regex_2.match(name) || + k_libcxx_std_weak_ptr_regex_2.match(name); +} + +bool CompilerType::IsInteger() const { + // This is used when you don't care about the signedness of the integer. + bool is_signed; + return IsIntegerType(is_signed); +} + +bool CompilerType::IsFloat() const { + uint32_t count = 0; + bool is_complex = false; + return IsFloatingPointType(count, is_complex); +} + +bool CompilerType::IsEnumerationType() const { + // This is used when you don't care about the signedness of the enum. + bool is_signed; + return IsEnumerationType(is_signed); +} + +bool CompilerType::IsUnscopedEnumerationType() const { + return IsEnumerationType() && !IsScopedEnumerationType(); +} + +bool CompilerType::IsIntegerOrUnscopedEnumerationType() const { + return IsInteger() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsSigned() const { + if (IsEnumerationType()) { +return IsEnumerationIntegerTypeSigned(); + } + return GetTypeInfo() & lldb::eTypeIsSigned; +} + +bool CompilerType::IsNullPtrType() const { + return GetCanonicalType().GetBasicTypeEnumeration() == + lldb::eBasicTypeNullPtr; +} + +bool CompilerType::IsBoolean() const { + return GetCanonicalType().GetBasicTypeEnumeration() == lldb::eBasicTypeBool; +} + +bool CompilerType::IsEnumerationIntegerTypeSigned() const { + if (IsValid()) { +return GetEnumerationIntegerType().GetTypeInfo() & lldb::eTypeIsSigned; + } + return false; +} + +bool CompilerType::IsScalarOrUnscopedEnumerationType() const { + return IsScalarType() || IsUnscopedEnumerationType(); +} + +bool CompilerType::IsPromotableIntegerType() const { + // Unscoped enums are always considered as promotable, even if their + // underlying type does not need to be promoted (e.g. "int"). + if (IsUnscopedEnumerationType()) { +return true; + } + + switch (GetCanonicalType().GetBasicTypeEnumeration()) { + case lldb::eBasicTypeBool: + case lldb::eBasicTypeChar: + case lldb::eBasicTypeSignedChar: + case lldb::eBasicTypeUnsignedChar: + case lldb::eBasicTypeShort: + case lldb::eBasicTypeUnsignedShort: + case lldb::eBasicTypeWChar: + case lldb::eBasicTypeSignedWChar: + case lldb::eBasicTypeUnsignedWChar: + case lldb::eBasicTypeChar16: + case lldb::eBasicTypeChar32: +return true; + + default: +return false; + } +} + +bool CompilerType::IsPointerToVoid() const { + if (!IsValid()) +return false; + + return IsPointerType() && + GetPointeeType().GetBasicTypeEnumeration() == lldb::eBasicTypeVoid; +} + +bool CompilerType::IsRecordType() const { + if (!IsValid()) +return false; + + return GetCanonicalType().GetTypeClass() & + (lldb::eTypeClassClass | lldb::eTypeClassStruct | + lldb::eTypeClassUnion); +} + +// Checks whether `target_base` is a virtual base of `type` (direct or +// indirect). If it is, stores the first virtual base type on the path from +// `type` to `target_type`. +bool CompilerType::IsVirtualBase(CompilerType target_base, + CompilerType *virtual_base, + bool carry_virtual) const { + if (CompareTypes(target_base)) { +return carry_virtual; + } + + if (!carry_virtual) { +uint32_t num_virtual_bases = GetNumVirtualBaseClasses(); +for (uint32_t i = 0; i < num_virtual_bases; ++i) { + uint32_t bit_offset; + auto base = GetVirtualBaseClassAtIndex(i, &bit_offset); + if (base.IsVirtualBase(target_base, virtual_base, + /*carry_virtual*/ true)) { +if (virtual_base) { + *virtual_base = base; +} +return true; + } +} + } + + uint32_t num_direct_bases = GetNumDirectBaseClasses(); + for (uint32_t i = 0; i < num_direct_bases; ++i) { +uint32_t bit_offset; +auto base = GetDirect
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -436,8 +482,8 @@ class CompilerType { ExecutionContextScope *exe_scope); /// Dump to stdout. - void DumpTypeDescription(lldb::DescriptionLevel level = - lldb::eDescriptionLevelFull) const; cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -54,7 +54,7 @@ bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size, if (IsValid()) if (auto type_system_sp = GetTypeSystem()) return type_system_sp->IsArrayType(m_type, element_type_ptr, size, - is_incomplete); + is_incomplete); cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -157,7 +157,8 @@ bool CompilerType::IsBlockPointerType( CompilerType *function_pointer_type_ptr) const { if (IsValid()) if (auto type_system_sp = GetTypeSystem()) - return type_system_sp->IsBlockPointerType(m_type, function_pointer_type_ptr); + return type_system_sp->IsBlockPointerType(m_type, cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -249,7 +250,7 @@ bool CompilerType::IsPossibleDynamicType(CompilerType *dynamic_pointee_type, if (IsValid()) if (auto type_system_sp = GetTypeSystem()) return type_system_sp->IsPossibleDynamicType(m_type, dynamic_pointee_type, -check_cplusplus, check_objc); + check_cplusplus, check_objc); cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)
@@ -302,6 +303,256 @@ bool CompilerType::IsBeingDefined() const { return false; } +bool CompilerType::IsSmartPtrType() const { + // These regular expressions cover shared, unique and weak pointers both from + // stdlibc++ and libc+++. + + static llvm::Regex k_libcxx_std_unique_ptr_regex( + "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex( + "^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex( + "^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"); + // + static llvm::Regex k_libcxx_std_unique_ptr_regex_2( + "^std::unique_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_shared_ptr_regex_2( + "^std::shared_ptr<.+>(( )?&)?$"); + static llvm::Regex k_libcxx_std_weak_ptr_regex_2( cmtice wrote: Done. https://github.com/llvm/llvm-project/pull/73472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/69516 >From 073ba299ab15c487bff28212563b5a103bdc5f60 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 18 Oct 2023 13:07:51 -0700 Subject: [PATCH 1/6] [lldb][progress] Add discrete boolean flag to progress reports This commit adds a boolean flag `is_discrete` is to progress reports in LLDB. The flag is set to false by default and indicates if a progress event is discrete, i.e. an operation that has no clear start and end and can happen multiple times during the course of a debug session. Operations that happen in this manner will report multiple individual progress events as they happen, so this flag gives the functionality to group multiple progress events so they can be reported in a less haphazard manner. --- lldb/include/lldb/Core/Debugger.h| 2 +- lldb/include/lldb/Core/DebuggerEvents.h | 7 +-- lldb/include/lldb/Core/Progress.h| 10 +- lldb/source/Core/Debugger.cpp| 16 +--- lldb/source/Core/DebuggerEvents.cpp | 1 + lldb/source/Core/Progress.cpp| 4 ++-- .../ObjectFile/Mach-O/ObjectFileMachO.cpp| 2 +- .../SymbolFile/DWARF/ManualDWARFIndex.cpp| 2 +- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 4 ++-- lldb/source/Symbol/LocateSymbolFile.cpp | 2 +- .../progress_reporting/TestProgressReporting.py | 11 +++ 11 files changed, 39 insertions(+), 22 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 5532cace606bfed..8e21502dac6dee2 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -618,7 +618,7 @@ class Debugger : public std::enable_shared_from_this, static void ReportProgress(uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, - std::optional debugger_id); + std::optional debugger_id, bool is_discrete); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 982b9701f89..88455d8d60bb488 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -21,10 +21,11 @@ class Stream; class ProgressEventData : public EventData { public: ProgressEventData(uint64_t progress_id, std::string title, std::string update, -uint64_t completed, uint64_t total, bool debugger_specific) +uint64_t completed, uint64_t total, bool debugger_specific, +bool is_discrete) : m_title(std::move(title)), m_details(std::move(update)), m_id(progress_id), m_completed(completed), m_total(total), -m_debugger_specific(debugger_specific) {} +m_debugger_specific(debugger_specific), m_is_discrete(is_discrete) {} static llvm::StringRef GetFlavorString(); @@ -52,6 +53,7 @@ class ProgressEventData : public EventData { const std::string &GetTitle() const { return m_title; } const std::string &GetDetails() const { return m_details; } bool IsDebuggerSpecific() const { return m_debugger_specific; } + bool IsDiscrete() const { return m_is_discrete; } private: /// The title of this progress event. The value is expected to remain stable @@ -68,6 +70,7 @@ class ProgressEventData : public EventData { uint64_t m_completed; const uint64_t m_total; const bool m_debugger_specific; + const bool m_is_discrete; ProgressEventData(const ProgressEventData &) = delete; const ProgressEventData &operator=(const ProgressEventData &) = delete; }; diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index b2b8781a43b0591..a48255fc88cf69b 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -69,8 +69,13 @@ class Progress { /// /// @param [in] debugger An optional debugger pointer to specify that this /// progress is to be reported only to specific debuggers. + /// + /// @param [in] is_discrete Boolean indicating whether or not + /// this progress report will happen once during a debug session or multiple + /// times as individual progress reports. Progress(std::string title, uint64_t total = UINT64_MAX, - lldb_private::Debugger *debugger = nullptr); + lldb_private::Debugger *debugger = nullptr, + bool is_discrete = false); /// Destroy the progress object. /// @@ -110,6 +115,9 @@ class Progress { /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete = false; + /// Set to true if the progress event is discrete; meaning it will happen
[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)
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 98e95a0055a4712fbd18495512c928bf2bd1adcc 4cfef945c2d77ec95cde3b0b13e832ee2dff19a1 -- lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/DebuggerEvents.h lldb/include/lldb/Core/Progress.h lldb/source/Core/Debugger.cpp lldb/source/Core/DebuggerEvents.cpp lldb/source/Core/Progress.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Symbol/LocateSymbolFile.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 462c033e88a..f538c40bfb4 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -417,55 +417,55 @@ public: /// hand, use INTERRUPT_REQUESTED so this gets done consistently. /// /// \param[in] formatv - /// A formatv string for the interrupt message. If the elements of the + /// A formatv string for the interrupt message. If the elements of the /// message are expensive to compute, you can use the no-argument form of - /// InterruptRequested, then make up the report using REPORT_INTERRUPTION. - /// + /// InterruptRequested, then make up the report using REPORT_INTERRUPTION. + /// /// \return /// A boolean value, if \b true an interruptible operation should interrupt /// itself. template - bool InterruptRequested(const char *cur_func, - const char *formatv, Args &&... args) { + bool InterruptRequested(const char *cur_func, const char *formatv, + Args &&...args) { bool ret_val = InterruptRequested(); if (ret_val) { if (!formatv) formatv = "Unknown message"; if (!cur_func) cur_func = ""; - ReportInterruption(InterruptionReport(cur_func, -llvm::formatv(formatv, -std::forward(args)...))); + ReportInterruption(InterruptionReport( + cur_func, llvm::formatv(formatv, std::forward(args)...))); } return ret_val; } - - + /// This handy define will keep you from having to generate a report for the /// interruption by hand. Use this except in the case where the arguments to /// the message description are expensive to compute. -#define INTERRUPT_REQUESTED(debugger, ...) \ -(debugger).InterruptRequested(__func__, __VA_ARGS__) +#define INTERRUPT_REQUESTED(debugger, ...) \ + (debugger).InterruptRequested(__func__, __VA_ARGS__) // This form just queries for whether to interrupt, and does no reporting: bool InterruptRequested(); - + // FIXME: Do we want to capture a backtrace at the interruption point? class InterruptionReport { public: -InterruptionReport(std::string function_name, std::string description) : -m_function_name(std::move(function_name)), -m_description(std::move(description)), -m_interrupt_time(std::chrono::system_clock::now()), -m_thread_id(llvm::get_threadid()) {} - -InterruptionReport(std::string function_name, -const llvm::formatv_object_base &payload); - - template - InterruptionReport(std::string function_name, - const char *format, Args &&... args) : -InterruptionReport(function_name, llvm::formatv(format, std::forward(args)...)) {} +InterruptionReport(std::string function_name, std::string description) +: m_function_name(std::move(function_name)), + m_description(std::move(description)), + m_interrupt_time(std::chrono::system_clock::now()), + m_thread_id(llvm::get_threadid()) {} + +InterruptionReport(std::string function_name, + const llvm::formatv_object_base &payload); + +template +InterruptionReport(std::string function_name, const char *format, + Args &&...args) +: InterruptionReport( + function_name, + llvm::formatv(format, std::forward(args)...)) {} std::string m_function_name; std::string m_description; @@ -473,14 +473,13 @@ public: const uint64_t m_thread_id; }; void ReportInterruption(const InterruptionReport &report); -#define REPORT_INTERRUPTION(debugger, ...) \ -(debugger).ReportInterruption(Debugger::InterruptionReport(__func__, \ -__VA_ARGS__)) +#define REPORT_INTERRUPTION(debugger, ...) \ + (debugger).ReportInterruption( \ + Debugger::InterruptionReport(__func__, __VA_ARGS__)) static
[Lldb-commits] [clang] [flang] [lldb] [lld] [libcxx] [compiler-rt] [llvm] [clang-tools-extra] [libc] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
@@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { +std::set supported_list {8, 16, 32, 64}; enh-google wrote: > So I think we should probably err on the side of specifying all the > bit-widths we specify in stdint.h. as a libc maintainer (who happens to have done a survey of the other libcs on this specific bit of C23 functionality, when zijunzhao was implementing it for bionic :-) ), i'd argue the opposite: none of bionic, glibc, musl, FreeBSD, and Apple's fork of FreeBSD libc supports these weird sizes[1]. nor does any hardware i'm aware of. i'd actually argue that the llvm stdint.h change that added these types should be reverted[2]. (presumably someone who knows the llvm code better can check whether it's possible for clang to ever actually define `__INT48_TYPE__` and its non-power-of-two friends? if there really _is_ such an architecture, we could at least get a useful code comment in stdint.h out of it!) as for the diagnostics, i'd argue (a) it doesn't make sense having this be libc-specific (like, for example, the existing "do math functions set errno?" configuration) since every libc in use would have the same "no, we don't support 48-bit ints" setting and (b) saying "well, 56-bit ints _might_ be a thing in theory, so we'll punt and leave it to be runtime error" isn't very helpful in a world where it will always be a runtime error. ___ 1. to be fair, a couple of them still don't implement %w at all. at the risk of making more work for zijunzhao, if you were going to teach clang about different libc versions, _that_ would at least be useful (for those targets that include a version in them): "which version of Android/iOS first had %b?" etc. if i'm using %b but targeting a version that didn't have it, that's a useful compile-time warning, at least as long as anyone's targeting old-enough versions. (and, full disclosure: for Android that's the same as %w: they're both new in this year's release --- https://android.googlesource.com/platform/bionic/+/HEAD/docs/status.md) 2. personally, i don't feel like the commit message on the change that introduced this stuff to stdint.h motivated it at all. i suspect if llvm hadn't still been an academic project back then, that change would never have been accepted in the first place! https://github.com/llvm/llvm-project/pull/71771 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Remove redundant parameter to AddMethodToObjCObjectType (PR #73832)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/73832 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFCI] Make ParsedDWARFTypeAttributes parameter const (PR #73833)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/73833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libcxx] [clang-tools-extra] [flang] [compiler-rt] [lld] [llvm] [lldb] [libc] Fix clang to recognize new C23 modifiers %w and %wf when printing (PR #71771)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/71771 >From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Thu, 9 Nov 2023 02:21:46 + Subject: [PATCH 1/3] Fix clang to recognize new C23 modifiers %w and %wf when printing --- clang/include/clang/AST/FormatString.h | 16 +++- clang/lib/AST/FormatString.cpp | 52 +- clang/lib/AST/PrintfFormatString.cpp | 19 ++ clang/test/Sema/format-strings-ms.c| 28 ++ 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h index 5c4ad9baaef608c..6a886854650f1d9 100644 --- a/clang/include/clang/AST/FormatString.h +++ b/clang/include/clang/AST/FormatString.h @@ -81,8 +81,10 @@ class LengthModifier { AsLongDouble, // 'L' AsAllocate, // for '%as', GNU extension to C90 scanf AsMAllocate, // for '%ms', GNU extension to scanf -AsWide, // 'w' (MSVCRT, like l but only for c, C, s, S, or Z -AsWideChar = AsLong // for '%ls', only makes sense for printf +AsWide, // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on windows + // 2. for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) +AsWideFast, // 'wf' (for b, d, i, o, u, x, or X) +AsWideChar = AsLong, // for '%ls', only makes sense for printf }; LengthModifier() @@ -417,6 +419,7 @@ class FormatSpecifier { /// http://www.opengroup.org/onlinepubs/009695399/functions/printf.html bool UsesPositionalArg; unsigned argIndex; + unsigned size; public: FormatSpecifier(bool isPrintf) : CS(isPrintf), VectorNumElts(false), @@ -460,6 +463,15 @@ class FormatSpecifier { FieldWidth = Amt; } + void setSize(unsigned s) { +size = s; + } + + unsigned getSize() const { +return size; + } + + bool usesPositionalArg() const { return UsesPositionalArg; } bool hasValidLengthModifier(const TargetInfo &Target, diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e0c9e18cfe3a243..ebc136e780717e4 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -286,7 +286,33 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, lmKind = LengthModifier::AsInt3264; break; case 'w': - lmKind = LengthModifier::AsWide; ++I; break; + ++I; + if (I == E) return false; + if (*I == 'f') { +lmKind = LengthModifier::AsWideFast; +++I; + } else { +lmKind = LengthModifier::AsWide; + } + + if (I == E) return false; + int s = 0; + while (unsigned(*I - '0') <= 9) { +s = 10 * s + unsigned(*I - '0'); +++I; + } + + // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows + // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 or 64) + if (s != 0) { +std::set supported_list {8, 16, 32, 64}; +if (supported_list.count(s) == 0) { + return false; +} +FS.setSize(s); + } + + break; } LengthModifier lm(lmPosition, lmKind); FS.setLengthModifier(lm); @@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const { return "m"; case AsWide: return "w"; + case AsWideFast: +return "wf"; case None: return ""; } @@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target, case ConversionSpecifier::SArg: case ConversionSpecifier::ZArg: return Target.getTriple().isOSMSVCRT(); +case ConversionSpecifier::bArg: +case ConversionSpecifier::dArg: +case ConversionSpecifier::iArg: +case ConversionSpecifier::oArg: +case ConversionSpecifier::uArg: +case ConversionSpecifier::xArg: +case ConversionSpecifier::XArg: + return true; +default: + return false; + } +case LengthModifier::AsWideFast: + switch (CS.getKind()) { +case ConversionSpecifier::bArg: +case ConversionSpecifier::dArg: +case ConversionSpecifier::iArg: +case ConversionSpecifier::oArg: +case ConversionSpecifier::uArg: +case ConversionSpecifier::xArg: +case ConversionSpecifier::XArg: + return true; default: return false; } @@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const { case LengthModifier::AsInt3264: case LengthModifier::AsInt64: case LengthModifier::AsWide: +case LengthModifier::AsWideFast: case LengthModifier::AsShortLong: // ??? return false; } diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp index f0b9d0ecaf23461..4b9111e8bcf509a 100644 --- a/clang/lib/AST/PrintfFormatString.cpp +++ b/clang/l
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/70996 >From b04c85dbed0b369e747aa2a3823789203156736b Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Wed, 18 Oct 2023 14:37:34 -0700 Subject: [PATCH 1/7] DEBUGINFOD based DWP acquisition for LLDB Summary: I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic downloading of DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set to a space delimited set of web servers, LLDB will try to use them as a last resort when searching for DWP files. If you do *not* have that environment variable set, nothing should be changed. There's also a setting, per Greg Clayton's request, that will override the env variable, or can be used instead of the env var. This setting is the reason for the additional API added to the llvm's Debuginfod library. Test Plan: Suggestions are welcome here. I should probably have some positive and negative tests, but I wanted to get the diff up for people who have a clue what they're doing to rip it to pieces before spending too much time validating my implementation. --- lldb/include/lldb/Target/Target.h | 3 +++ lldb/source/Core/CoreProperties.td| 2 +- lldb/source/Core/Debugger.cpp | 5 .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 1 + lldb/source/Symbol/CMakeLists.txt | 1 + lldb/source/Target/Target.cpp | 19 +- lldb/source/Target/TargetProperties.td| 4 +++ llvm/include/llvm/Debuginfod/Debuginfod.h | 4 +++ llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++- 9 files changed, 57 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index c37682e2a03859f..7f10f0409fb1315 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + Args GetDebugInfoDURLs() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); @@ -270,6 +272,7 @@ class TargetProperties : public Properties { void DisableASLRValueChangedCallback(); void InheritTCCValueChangedCallback(); void DisableSTDIOValueChangedCallback(); + void DebugInfoDURLsChangedCallback(); // Settings checker for target.jit-save-objects-dir: void CheckJITObjectsDir(); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 92884258347e9be..865030b0133bbb2 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -4,7 +4,7 @@ let Definition = "modulelist" in { def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">, Global, DefaultTrue, -Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">; +Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched. If all other methods fail, and the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol is used to acquire symbols from a compatible Debuginfod service.">; def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">, Global, DefaultFalse, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -61,6 +61,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" @@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { assert(g_debugger_list_ptr == nullptr && "Debugger::Initialize called more than once!"); + // We might be using the Debuginfod service, s
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -0,0 +1,142 @@ +//===-- SymbolLocatorDebuginfod.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 "SymbolLocatorDebuginfod.h" + +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/Args.h" + +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" + +using namespace lldb; +using namespace lldb_private; + +LLDB_PLUGIN_DEFINE(SymbolLocatorDebuginfod) + +namespace { + +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodProperties.inc" + +enum { +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodPropertiesEnum.inc" +}; + +class PluginProperties : public Properties { +public: + static llvm::StringRef GetSettingName() { +return SymbolLocatorDebuginfod::GetPluginNameStatic(); + } + + PluginProperties() { +m_collection_sp = std::make_shared(GetSettingName()); +m_collection_sp->Initialize(g_symbollocatordebuginfod_properties); + +// We need to read the default value first to read the environment variable. +llvm::SmallVector urls = llvm::getDefaultDebuginfodUrls(); +Args arg_urls{urls}; +m_collection_sp->SetPropertyAtIndexFromArgs(ePropertyServerURLs, arg_urls); + +m_collection_sp->SetValueChangedCallback( +ePropertyServerURLs, [this] { ServerURLsChangedCallback(); }); + } + + Args GetDebugInfoDURLs() const { +Args urls; +m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyServerURLs, urls); +return urls; + } + +private: + void ServerURLsChangedCallback() { +Args urls = GetDebugInfoDURLs(); +llvm::SmallVector dbginfod_urls; +llvm::transform(urls, dbginfod_urls.end(), +[](const auto &obj) { return obj.ref(); }); +llvm::setDefaultDebuginfodUrls(dbginfod_urls); + } +}; + +} // namespace + +static PluginProperties &GetGlobalPluginProperties() { + static PluginProperties g_settings; + return g_settings; +} + +SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {} + +void SymbolLocatorDebuginfod::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin( +GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, +LocateExecutableObjectFile, LocateExecutableSymbolFile, nullptr, +nullptr, SymbolLocatorDebuginfod::DebuggerInitialize); +llvm::HTTPClient::initialize(); + }); +} + +void SymbolLocatorDebuginfod::DebuggerInitialize(Debugger &debugger) { + if (!PluginManager::GetSettingForSymbolLocatorPlugin( + debugger, PluginProperties::GetSettingName())) { +const bool is_global_setting = true; +PluginManager::CreateSettingForSymbolLocatorPlugin( +debugger, GetGlobalPluginProperties().GetValueProperties(), +"Properties for the Debuginfod Symbol Locator plug-in.", +is_global_setting); + } +} + +void SymbolLocatorDebuginfod::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); + llvm::HTTPClient::cleanup(); +} + +llvm::StringRef SymbolLocatorDebuginfod::GetPluginDescriptionStatic() { + return "Debuginfod symbol locator."; +} + +SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() { + return new SymbolLocatorDebuginfod(); +} + +std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile( +const ModuleSpec &module_spec) { + const UUID &module_uuid = module_spec.GetUUID(); + if (module_uuid.IsValid() && llvm::canUseDebuginfod()) { +llvm::object::BuildID build_id(module_uuid.GetBytes()); +llvm::Expected result = +llvm::getCachedOrDownloadExecutable(build_id); +if (result) + return FileSpec(*result); +// An error here should be logged as a failure in the Debuginfod library, +// so just consume it here +consumeError(result.takeError()); + } + return {}; +} + +std::optional SymbolLocatorDebuginfod::LocateExecutableSymbolFile( +const ModuleSpec &module_spec, const FileSpecList &default_search_paths) { + const UUID &module_uuid = module_spec.GetUUID(); + if (module_uuid.IsValid() && llvm::canUseDebuginfod()) { +llvm::object::BuildID build_id(module_uuid.GetBytes()); +llvm::Expected result = +llvm::getCachedOrDownloadDebuginfo(build_id); +if (result) + return FileSpec(*result); +// An error here should be logged as a failure in the Debuginfod library, +// so just consume it here +consumeError(result.takeError()); + } kevinfrei wrote: I factored it into a helper to reduce copy-pasta https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.o
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -46,6 +46,10 @@ bool canUseDebuginfod(); /// environment variable. SmallVector getDefaultDebuginfodUrls(); +/// Sets the list of debuginfod server URLs to query. This overrides the +/// environment variable DEBUGINFOD_URLS. +void setDefaultDebuginfodUrls(SmallVector URLs); kevinfrei wrote: Done. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,23 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { +// Only read from the environment variable if the user hasn't already +// set the value +if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) + StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); +DebuginfodUrlsSet = true; + } return DebuginfodUrls; } +// Set the default debuginfod URL list, override the environment variable +void setDefaultDebuginfodUrls(SmallVector URLs) { + DebuginfodUrls.clear(); + DebuginfodUrls.insert(DebuginfodUrls.begin(), URLs.begin(), URLs.end()); + DebuginfodUrlsSet = true; kevinfrei wrote: So much cleaner! https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,23 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { +// Only read from the environment variable if the user hasn't already +// set the value +if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) + StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); +DebuginfodUrlsSet = true; kevinfrei wrote: Much better https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -47,6 +47,10 @@ namespace llvm { using llvm::object::BuildIDRef; +SmallVector DebuginfodUrls; kevinfrei wrote: Done https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,23 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { kevinfrei wrote: std::optional is very nice https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
https://github.com/jimingham updated https://github.com/llvm/llvm-project/pull/72565 >From f5d66b41bc06840648725daa640c6923b0eab923 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 16 Nov 2023 12:18:36 -0800 Subject: [PATCH 1/2] Send an explicit interrupt to cancel an attach waitfor. Currently when you interrupt a: (lldb) process attach -w -n some_process lldb just closes the connection to the stub and kills the process it made for the attach. The stub at the other end notices the connection go down and exits because of that. But when communication to a device is handled through some kind of proxy server, that signal might not be reliable, causing debugserver to persist on the machine. We can work around those failures by sending an explicit interrupt before closing down the connection. The stub will also have to be waiting for the interrupt for this to make any difference. I changed debugserver to do that. I didn't make the equivalent change in lldb-server. So long as you aren't faced with a flakey connection, this should not be necessary. --- .../Process/gdb-remote/ProcessGDBRemote.cpp | 6 ++-- lldb/source/Target/Process.cpp| 9 +- lldb/tools/debugserver/source/DNB.cpp | 30 +-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index f90a561aae2e3b7..b6fe1bd7104b280 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2372,8 +2372,10 @@ Status ProcessGDBRemote::DoHalt(bool &caused_stop) { Status error; if (m_public_state.GetValue() == eStateAttaching) { -// We are being asked to halt during an attach. We need to just close our -// file handle and debugserver will go away, and we can be done... +// We are being asked to halt during an attach. We used to just close our +// file handle and debugserver will go away, but with remote proxies, it +// is better to send a positive signal, so let's send the interrupt first... +caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout()); m_gdb_comm.Disconnect(); } else caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout()); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 21b80b8240ab64b..f3da2839e262e23 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3156,8 +3156,8 @@ Status Process::Halt(bool clear_thread_plans, bool use_run_lock) { // Don't hijack and eat the eStateExited as the code that was doing the // attach will be waiting for this event... RestoreProcessEvents(); -SetExitStatus(SIGKILL, "Cancelled async attach."); Destroy(false); +SetExitStatus(SIGKILL, "Cancelled async attach."); return Status(); } @@ -3843,6 +3843,13 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { ") woke up with an interrupt while attaching - " "forwarding interrupt.", __FUNCTION__, static_cast(this), GetID()); +// The server may be spinning waiting for a process to appear, in which +// case we should tell it to stop doing that. Normally, we don't NEED +// to do that because we will next close the communication to the stub +// and that will get it to shut down. But there are remote debugging +// cases where relying on that side-effect causes the shutdown to be +// flakey, so we should send a positive signal to interrupt the wait. +Status error = HaltPrivate(); BroadcastEvent(eBroadcastBitInterrupt, nullptr); } else if (StateIsRunningState(m_last_broadcast_state)) { LLDB_LOGF(log, diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index f6c1130fdd8054c..0ec50df42d1fedc 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -50,6 +50,7 @@ #include "MacOSX/MachProcess.h" #include "MacOSX/MachTask.h" #include "MacOSX/ThreadInfo.h" +#include "RNBRemote.h" typedef std::shared_ptr MachProcessSP; typedef std::map ProcessMap; @@ -745,7 +746,6 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } } else { - // Get the current process list, and check for matches that // aren't in our original list. If anyone wants to attach // to an existing process by name, they should do it with @@ -799,7 +799,33 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } - ::usleep(waitfor_interval); // Sleep for WAITFOR_INTERVAL, then poll again + // Now we're going to wait a while before polling again. But we also + // need to check whether we've gotten an event from the debug
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r a322d50804c5248f9e2981f3733bcb598fa13d51..f6be566cda37974027d2fb591465f385965bd7d1 lldb/test/API/python_api/process/cancel_attach/TestCancelAttach.py `` View the diff from darker here. ``diff --- TestCancelAttach.py 2023-11-30 01:25:00.00 + +++ TestCancelAttach.py 2023-11-30 01:28:51.443331 + @@ -26,14 +26,16 @@ # Make this a daemon thread so if we don't manage to interrupt, # Python will keep this thread from hanging the test. threading.Thread.__init__(self, daemon=True) self.target = target self.error = error - + def run(self): -self.target.AttachToProcessWithName(lldb.SBListener(), "LLDB-No-Such-Process", True, self.error) - +self.target.AttachToProcessWithName( +lldb.SBListener(), "LLDB-No-Such-Process", True, self.error +) + error = lldb.SBError() thread = AttachThread(target, error) thread.start() # Now wait till the attach on the child thread has made a process @@ -48,10 +50,9 @@ # Now send the attach interrupt: target.process.SendAsyncInterrupt() # We don't want to stall if we can't interrupt, so join with a timeout: thread.join(60) if thread.is_alive(): - self.fail("The attach thread is alive after timeout interval") +self.fail("The attach thread is alive after timeout interval") # Now check the error, should say the attach was interrupted: self.assertTrue(error.Fail(), "We succeeded in not attaching") - `` https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
jimingham wrote: I added a test case for cancelling attach. This should actually work everywhere so I didn't limit it to Darwin. It doesn't test the actual bug I was trying to fix because that would require coming up with an unreliable file handle repeater and that's way more work than it's worth. But since this uses Python threading, and interruption so I wouldn't be surprised if it doesn't work reliably everywhere. https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits