github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff 7da0a698526ff657c2348a6e4bb835fc764177da 9c6705b21df14dc911665e1082c9b31ce00d7e7c --extensions h,cpp -- lldb/include/lldb/Breakpoint/BreakpointLocation.h lldb/include/lldb/Breakpoint/BreakpointSite.h lldb/include/lldb/Target/StopInfo.h lldb/include/lldb/Target/ThreadPlanStepInRange.h lldb/source/Breakpoint/BreakpointLocation.cpp lldb/source/Breakpoint/BreakpointResolver.cpp lldb/source/Breakpoint/BreakpointSite.cpp lldb/source/Core/Declaration.cpp lldb/source/Symbol/CompileUnit.cpp lldb/source/Target/StackFrameList.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/Thread.cpp lldb/source/Target/ThreadPlanStepInRange.cpp lldb/source/Target/ThreadPlanStepOverRange.cpp lldb/test/API/functionalities/inline-stepping/calling.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index f9c258daf1..552fafab97 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -283,7 +283,7 @@ public: /// Returns the breakpoint location ID. lldb::break_id_t GetID() const { return m_loc_id; } - + // Set the line entry that should be shown to users for this location. // It is up to the caller to verify that this is a valid entry to show. // The current use of this is to distinguish among line entries from a @@ -291,7 +291,7 @@ public: void SetPreferredLineEntry(const LineEntry &line_entry) { m_preferred_line_entry = line_entry; } - + const std::optional<LineEntry> GetPreferredLineEntry() { return m_preferred_line_entry; } @@ -319,7 +319,7 @@ protected: /// It also takes care of decrementing the ignore counters. /// If it returns false we should continue, otherwise stop. bool IgnoreCountShouldStop(); - + // If this location knows that the virtual stack frame it represents is // not frame 0, return the suggested stack frame instead. This will happen // when the location's address contains a "virtual inlined call stack" and the @@ -393,13 +393,14 @@ private: lldb::break_id_t m_loc_id; ///< Breakpoint location ID. StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint /// location has been hit. - std::optional<LineEntry> m_preferred_line_entry; // If this exists, use it to print the stop - // description rather than the LineEntry - // m_address resolves to directly. Use this - // for instance when the location was given - // somewhere in the virtual inlined call - // stack since the Address always resolves - // to the lowest entry in the stack. + std::optional<LineEntry> + m_preferred_line_entry; // If this exists, use it to print the stop + // description rather than the LineEntry + // m_address resolves to directly. Use this + // for instance when the location was given + // somewhere in the virtual inlined call + // stack since the Address always resolves + // to the lowest entry in the stack. void SetShouldResolveIndirectFunctions(bool do_resolve) { m_should_resolve_indirect_functions = do_resolve; diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h b/lldb/include/lldb/Breakpoint/BreakpointSite.h index 30cb5a80b9..7b3f7be236 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointSite.h +++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h @@ -169,7 +169,7 @@ public: /// /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level); - + // This runs through all the breakpoint locations owning this site and returns // the greatest of their suggested stack frame indexes. This only handles // inlined stack changes. diff --git a/lldb/include/lldb/Target/StopInfo.h b/lldb/include/lldb/Target/StopInfo.h index d997e0fd6f..45beac129e 100644 --- a/lldb/include/lldb/Target/StopInfo.h +++ b/lldb/include/lldb/Target/StopInfo.h @@ -79,13 +79,14 @@ public: /// This gives the StopInfo a chance to suggest a stack frame to select. /// Passing true for inlined_stack will request changes to the inlined - /// call stack. Passing false will request changes to the real stack + /// call stack. Passing false will request changes to the real stack /// frame. The inlined stack gets adjusted before we call into the thread /// plans so they can reason based on the correct values. The real stack /// adjustment is handled after the frame recognizers get a chance to adjust /// the frame. - virtual std::optional<uint32_t> GetSuggestedStackFrameIndex(bool inlined_stack) { - return {}; + virtual std::optional<uint32_t> + GetSuggestedStackFrameIndex(bool inlined_stack) { + return {}; } virtual bool IsValidForOperatingSystemThread(Thread &thread) { return true; } diff --git a/lldb/include/lldb/Target/ThreadPlanStepInRange.h b/lldb/include/lldb/Target/ThreadPlanStepInRange.h index 6bd79e1d28..f2cb108530 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepInRange.h +++ b/lldb/include/lldb/Target/ThreadPlanStepInRange.h @@ -80,8 +80,8 @@ private: bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put // a switch in for this if there's // demand for that. - LazyBool m_virtual_step; // true if we've just done a "virtual step", i.e. just - // moved the inline stack depth. + LazyBool m_virtual_step; // true if we've just done a "virtual step", i.e. + // just moved the inline stack depth. ConstString m_step_into_target; ThreadPlanStepInRange(const ThreadPlanStepInRange &) = delete; const ThreadPlanStepInRange & diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 61fe467987..7e002b9ba4 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -508,7 +508,7 @@ void BreakpointLocation::GetDescription(Stream *s, s->PutCString("re-exported target = "); else s->PutCString("where = "); - + // If there's a preferred line entry for printing, use that. bool show_function_info = true; if (GetPreferredLineEntry()) { @@ -520,7 +520,8 @@ void BreakpointLocation::GetDescription(Stream *s, show_function_info = false; } sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address, - false, true, false, show_function_info, show_function_info, show_function_info); + false, true, false, show_function_info, + show_function_info, show_function_info); } else { if (sc.module_sp) { s->EOL(); @@ -670,7 +671,7 @@ void BreakpointLocation::SendBreakpointLocationChangedEvent( } } -std::optional<uint32_t> BreakpointLocation::GetSuggestedStackFrameIndex() { +std::optional<uint32_t> BreakpointLocation::GetSuggestedStackFrameIndex() { if (!GetPreferredLineEntry()) return {}; LineEntry preferred = *GetPreferredLineEntry(); @@ -682,12 +683,13 @@ std::optional<uint32_t> BreakpointLocation::GetSuggestedStackFrameIndex() { // case. if (!LineEntry::Compare(sc.line_entry, preferred)) return {}; - + if (!sc.block) return {}; // Blocks have their line info in Declaration form, so make one here: - Declaration preferred_decl(preferred.GetFile(), preferred.line, preferred.column); + Declaration preferred_decl(preferred.GetFile(), preferred.line, + preferred.column); uint32_t depth = 0; Block *inlined_block = sc.block->GetContainingInlinedBlock(); @@ -695,8 +697,8 @@ std::optional<uint32_t> BreakpointLocation::GetSuggestedStackFrameIndex() { // If we've moved to a block that this isn't the start of, that's not // our inlining info or call site, so we can stop here. Address start_address; - if (!inlined_block->GetStartAddress(start_address) - || start_address != m_address) + if (!inlined_block->GetStartAddress(start_address) || + start_address != m_address) return {}; const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo(); @@ -710,7 +712,6 @@ std::optional<uint32_t> BreakpointLocation::GetSuggestedStackFrameIndex() { depth++; } return {}; - } void BreakpointLocation::SwapLocation(BreakpointLocationSP swap_from) { diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index 465fc387aa..688dffa02e 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -340,17 +340,17 @@ void BreakpointResolver::AddLocation(SearchFilter &filter, } BreakpointLocationSP bp_loc_sp(AddLocation(line_start)); - // If the address that we resolved the location to returns a different + // If the address that we resolved the location to returns a different // LineEntry from the one in the incoming SC, we're probably dealing with an // inlined call site, so set that as the preferred LineEntry: LineEntry resolved_entry; - if (!skipped_prologue && bp_loc_sp && + if (!skipped_prologue && bp_loc_sp && line_start.CalculateSymbolContextLineEntry(resolved_entry) && LineEntry::Compare(resolved_entry, sc.line_entry)) { - // FIXME: The function name will also be wrong here. Do we need to record - // that as well, or can we figure that out again when we report this - // breakpoint location. - bp_loc_sp->SetPreferredLineEntry(sc.line_entry); + // FIXME: The function name will also be wrong here. Do we need to record + // that as well, or can we figure that out again when we report this + // breakpoint location. + bp_loc_sp->SetPreferredLineEntry(sc.line_entry); } if (log && bp_loc_sp && !GetBreakpoint()->IsInternal()) { StreamString s; diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index f4c61d6ec1..666e682ff5 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -251,8 +251,10 @@ void CompileUnit::ResolveSymbolContext( SymbolContextItem resolve_scope, SymbolContextList &sc_list, RealpathPrefixes *realpath_prefixes) { const FileSpec file_spec = src_location_spec.GetFileSpec(); - const uint32_t line = src_location_spec.GetLine().value_or(LLDB_INVALID_LINE_NUMBER); - const uint32_t column_num = src_location_spec.GetColumn().value_or(LLDB_INVALID_COLUMN_NUMBER); + const uint32_t line = + src_location_spec.GetLine().value_or(LLDB_INVALID_LINE_NUMBER); + const uint32_t column_num = + src_location_spec.GetColumn().value_or(LLDB_INVALID_COLUMN_NUMBER); const bool check_inlines = src_location_spec.GetCheckInlines(); // First find all of the file indexes that match our "file_spec". If @@ -312,42 +314,45 @@ void CompileUnit::ResolveSymbolContext( line_idx = line_table->FindLineEntryIndexByFileIndex( 0, file_indexes, src_location_spec, &line_entry); } - + // If we didn't manage to find a breakpoint that matched the line number - // requested, that might be because it is only an inline call site, and + // requested, that might be because it is only an inline call site, and // doesn't have a line entry in the line table. Scan for that here. // // We are making the assumption that if there was an inlined function it will - // contribute at least 1 non-call-site entry to the line table. That's handy - // because we don't move line breakpoints over function boundaries, so if we + // contribute at least 1 non-call-site entry to the line table. That's handy + // because we don't move line breakpoints over function boundaries, so if we // found a hit, and there were also a call site entry, it would have to be in // the function containing the PC of the line table match. That way we can // limit the call site search to that function. // We will miss functions that ONLY exist as a call site entry. - if (line_entry.IsValid() && (line_entry.line != line || line_entry.column != column_num) - && resolve_scope & eSymbolContextLineEntry && check_inlines) { + if (line_entry.IsValid() && + (line_entry.line != line || line_entry.column != column_num) && + resolve_scope & eSymbolContextLineEntry && check_inlines) { // We don't move lines over function boundaries, so the address in the // line entry will be the in function that contained the line that might // be a CallSite, and we can just iterate over that function to find any // inline records, and dig up their call sites. Address start_addr = line_entry.range.GetBaseAddress(); Function *function = start_addr.CalculateSymbolContextFunction(); - + Declaration sought_decl(file_spec, line, column_num); // We use this recursive function to descend the block structure looking // for a block that has this Declaration as in it's CallSite info. // This function recursively scans the sibling blocks of the incoming // block parameter. - std::function<void(Block&)> examine_block = - [&sought_decl, &sc_list, &src_location_spec, resolve_scope, &examine_block] (Block &block) -> void { + std::function<void(Block &)> examine_block = + [&sought_decl, &sc_list, &src_location_spec, resolve_scope, + &examine_block](Block &block) -> void { // Iterate over the sibling child blocks of the incoming block. Block *sibling_block = block.GetFirstChild(); while (sibling_block) { // We only have to descend through the regular blocks, looking for // immediate inlines, since those are the only ones that will have this // callsite. - const InlineFunctionInfo *inline_info = sibling_block->GetInlinedFunctionInfo(); + const InlineFunctionInfo *inline_info = + sibling_block->GetInlinedFunctionInfo(); if (inline_info) { // If this is the call-site we are looking for, record that: // We need to be careful because the call site from the debug info @@ -355,13 +360,14 @@ void CompileUnit::ResolveSymbolContext( // it. Declaration found_decl = inline_info->GetCallSite(); uint32_t sought_column = sought_decl.GetColumn(); - if (found_decl.FileAndLineEqual(sought_decl) - && (sought_column == LLDB_INVALID_COLUMN_NUMBER - || sought_column == found_decl.GetColumn())) { + if (found_decl.FileAndLineEqual(sought_decl) && + (sought_column == LLDB_INVALID_COLUMN_NUMBER || + sought_column == found_decl.GetColumn())) { // If we found a call site, it belongs not in this inlined block, // but in the parent block that inlined it. Address parent_start_addr; - if (sibling_block->GetParent()->GetStartAddress(parent_start_addr)) { + if (sibling_block->GetParent()->GetStartAddress( + parent_start_addr)) { SymbolContext sc; parent_start_addr.CalculateSymbolContext(&sc, resolve_scope); // Now swap out the line entry for the one we found. @@ -373,31 +379,32 @@ void CompileUnit::ResolveSymbolContext( // call site we found actually matches the location. if (src_location_spec.GetExactMatch()) { matches_spec = false; - if ((src_location_spec.GetFileSpec() == sc.line_entry.GetFile()) - && (src_location_spec.GetLine() && - *src_location_spec.GetLine() == call_site_line.line) - && (src_location_spec.GetColumn() && - *src_location_spec.GetColumn() == call_site_line.column)) - matches_spec = true; + if ((src_location_spec.GetFileSpec() == + sc.line_entry.GetFile()) && + (src_location_spec.GetLine() && + *src_location_spec.GetLine() == call_site_line.line) && + (src_location_spec.GetColumn() && + *src_location_spec.GetColumn() == call_site_line.column)) + matches_spec = true; } - if (matches_spec && + if (matches_spec && sibling_block->GetRangeAtIndex(0, call_site_line.range)) { - SymbolContext call_site_sc(sc.target_sp, sc.module_sp, sc.comp_unit, - sc.function, sc.block, &call_site_line, - sc.symbol); + SymbolContext call_site_sc(sc.target_sp, sc.module_sp, + sc.comp_unit, sc.function, sc.block, + &call_site_line, sc.symbol); sc_list.Append(call_site_sc); } } } } - + // Descend into the child blocks: examine_block(*sibling_block); // Now go to the next sibling: - sibling_block = sibling_block->GetSibling(); + sibling_block = sibling_block->GetSibling(); } }; - + if (function) { // We don't need to examine the function block, it can't be inlined. Block &func_block = function->GetBlock(true); @@ -405,7 +412,7 @@ void CompileUnit::ResolveSymbolContext( } // If we found entries here, we are done. We only get here because we // didn't find an exact line entry for this line & column, but if we found - // an exact match from the call site info that's strictly better than + // an exact match from the call site info that's strictly better than // continuing to look for matches further on in the file. // FIXME: Should I also do this for "call site line exists between the // given line number and the later line we found in the line table"? That's diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index cda360baed..94a381edd5 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -85,14 +85,14 @@ void StackFrameList::ResetCurrentInlinedDepth() { return; std::lock_guard<std::recursive_mutex> guard(m_mutex); - + m_current_inlined_pc = LLDB_INVALID_ADDRESS; m_current_inlined_depth = UINT32_MAX; StopInfoSP stop_info_sp = m_thread.GetStopInfo(); if (!stop_info_sp) return; - + bool inlined = true; auto inline_depth = stop_info_sp->GetSuggestedStackFrameIndex(inlined); // We're only adjusting the inlined stack here. @@ -745,27 +745,28 @@ void StackFrameList::SelectMostRelevantFrame() { bool found_relevant = false; if (stop_info_sp) { // Here we're only asking the stop info if it wants to adjust the real stack - // index. We have to ask about the m_inlined_stack_depth in + // index. We have to ask about the m_inlined_stack_depth in // Thread::ShouldStop since the plans need to reason with that info. bool inlined = false; - std::optional<uint32_t> stack_opt = stop_info_sp->GetSuggestedStackFrameIndex(inlined); + std::optional<uint32_t> stack_opt = + stop_info_sp->GetSuggestedStackFrameIndex(inlined); if (stack_opt) { stack_idx = *stack_opt; found_relevant = true; } } - + frame_sp = GetFrameAtIndex(stack_idx); if (!frame_sp) - LLDB_LOG(log, "Stop info suggested relevant frame {0} but it didn't exist", + LLDB_LOG(log, "Stop info suggested relevant frame {0} but it didn't exist", stack_idx); else if (found_relevant) LLDB_LOG(log, "Setting selected frame from stop info to {0}", stack_idx); // Note, we don't have to worry about "inlined" frames here, because we've - // already calculated the inlined frame in Thread::ShouldStop, and + // already calculated the inlined frame in Thread::ShouldStop, and // SetSelectedFrame will take care of that adjustment for us. SetSelectedFrame(frame_sp.get()); - + if (!found_relevant) LLDB_LOG(log, "No relevant frame!"); } diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index 8ba46366c8..aa9c97a615 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -247,7 +247,8 @@ public: return m_description.c_str(); } - std::optional<uint32_t> GetSuggestedStackFrameIndex(bool inlined_stack) override { + std::optional<uint32_t> + GetSuggestedStackFrameIndex(bool inlined_stack) override { if (!inlined_stack) return {}; @@ -258,10 +259,10 @@ public: thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value)); if (!bp_site_sp) return {}; - + return bp_site_sp->GetSuggestedStackFrameIndex(); } - + protected: bool ShouldStop(Event *event_ptr) override { // This just reports the work done by PerformAction or the synchronous @@ -1180,9 +1181,9 @@ public: else return m_description.c_str(); } - - std::optional<uint32_t> GetSuggestedStackFrameIndex(bool inlined_stack) override - { + + std::optional<uint32_t> + GetSuggestedStackFrameIndex(bool inlined_stack) override { // Trace only knows how to adjust inlined stacks: if (!inlined_stack) return {}; @@ -1201,7 +1202,7 @@ public: if (!block_ptr->GetRangeContainingAddress(pc_address, containing_range) || pc_address != containing_range.GetBaseAddress()) return {}; - + int num_inlined_functions = 0; for (Block *container_ptr = block_ptr->GetInlinedParent(); @@ -1218,7 +1219,6 @@ public: inlined_stack = true; return num_inlined_functions + 1; } - }; // StopInfoException diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index d13013c185..6c22b50d3b 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -620,7 +620,7 @@ void Thread::WillStop() { void Thread::SetupForResume() { if (GetResumeState() != eStateSuspended) { // First check whether this thread is going to "actually" resume at all. - // For instance, if we're stepping from one level to the next of an + // For instance, if we're stepping from one level to the next of an // virtual inlined call stack, we just change the inlined call stack index // without actually running this thread. In that case, for this thread we // shouldn't push a step over breakpoint plan or do that work. diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp index 5319afb4ed..325a706199 100644 --- a/lldb/source/Target/ThreadPlanStepInRange.cpp +++ b/lldb/source/Target/ThreadPlanStepInRange.cpp @@ -486,7 +486,7 @@ bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state, return true; } -bool ThreadPlanStepInRange::IsVirtualStep() { +bool ThreadPlanStepInRange::IsVirtualStep() { if (m_virtual_step == eLazyBoolCalculate) { Thread &thread = GetThread(); if (thread.GetCurrentInlinedDepth() == UINT32_MAX) @@ -494,5 +494,5 @@ bool ThreadPlanStepInRange::IsVirtualStep() { else m_virtual_step = eLazyBoolYes; } - return m_virtual_step == eLazyBoolYes; + return m_virtual_step == eLazyBoolYes; } diff --git a/lldb/test/API/functionalities/inline-stepping/calling.cpp b/lldb/test/API/functionalities/inline-stepping/calling.cpp index 0009388bd8..d7ee56b3c0 100644 --- a/lldb/test/API/functionalities/inline-stepping/calling.cpp +++ b/lldb/test/API/functionalities/inline-stepping/calling.cpp @@ -15,9 +15,9 @@ inline void inline_trivial_2 () __attribute__((always_inline)); // These three should share the same initial pc so we can test // virtual inline stepping. -inline void caller_trivial_inline_1 () __attribute__((always_inline)); -inline void caller_trivial_inline_2 () __attribute__((always_inline)); -inline void caller_trivial_inline_3 () __attribute__((always_inline)); +inline void caller_trivial_inline_1() __attribute__((always_inline)); +inline void caller_trivial_inline_2() __attribute__((always_inline)); +inline void caller_trivial_inline_3() __attribute__((always_inline)); void caller_trivial_1 (); void caller_trivial_2 (); @@ -88,24 +88,18 @@ caller_trivial_2 () // When you call caller_trivial_inline_1, the inlined call-site // should share a PC with all three of the following inlined // functions, so we can exercise "virtual inline stepping". -void -caller_trivial_inline_1 () -{ - caller_trivial_inline_2(); // In caller_trivial_inline_1. - inline_value += 1; +void caller_trivial_inline_1() { + caller_trivial_inline_2(); // In caller_trivial_inline_1. + inline_value += 1; } -void -caller_trivial_inline_2 () -{ - caller_trivial_inline_3(); // In caller_trivial_inline_2. - inline_value += 1; +void caller_trivial_inline_2() { + caller_trivial_inline_3(); // In caller_trivial_inline_2. + inline_value += 1; } -void -caller_trivial_inline_3 () -{ - inline_value += 1; // In caller_trivial_inline_3. +void caller_trivial_inline_3() { + inline_value += 1; // In caller_trivial_inline_3. } void @@ -162,6 +156,6 @@ main (int argc, char **argv) max_value(std::string("abc"), std::string("0022")); // Call max_value specialized caller_trivial_inline_1(); // At caller_trivial_inline_1. - + return 0; // About to return from main. } `````````` </details> https://github.com/llvm/llvm-project/pull/112939 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits