Skip to content

Commit e09264f

Browse files
authored
Merge pull request #9549 from ahoppen/revert-swift-call-site-breakpoints
Revert "Merge pull request #9493 from jimingham/swift-call-site-breakpoints"
2 parents 7e9b8f6 + c93fb6d commit e09264f

28 files changed

+147
-759
lines changed

lldb/include/lldb/Breakpoint/BreakpointLocation.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
#include <memory>
1313
#include <mutex>
14-
#include <optional>
1514

1615
#include "lldb/Breakpoint/BreakpointOptions.h"
1716
#include "lldb/Breakpoint/StoppointHitCounter.h"
1817
#include "lldb/Core/Address.h"
19-
#include "lldb/Symbol/LineEntry.h"
2018
#include "lldb/Utility/UserID.h"
2119
#include "lldb/lldb-private.h"
2220

@@ -284,25 +282,6 @@ class BreakpointLocation
284282
/// Returns the breakpoint location ID.
285283
lldb::break_id_t GetID() const { return m_loc_id; }
286284

287-
/// Set the line entry that should be shown to users for this location.
288-
/// It is up to the caller to verify that this is a valid entry to show.
289-
/// The current use of this is to distinguish among line entries from a
290-
/// virtual inlined call stack that all share the same address.
291-
/// The line entry must have the same start address as the address for this
292-
/// location.
293-
bool SetPreferredLineEntry(const LineEntry &line_entry) {
294-
if (m_address == line_entry.range.GetBaseAddress()) {
295-
m_preferred_line_entry = line_entry;
296-
return true;
297-
}
298-
assert(0 && "Tried to set a preferred line entry with a different address");
299-
return false;
300-
}
301-
302-
const std::optional<LineEntry> GetPreferredLineEntry() {
303-
return m_preferred_line_entry;
304-
}
305-
306285
protected:
307286
friend class BreakpointSite;
308287
friend class BreakpointLocationList;
@@ -327,16 +306,6 @@ class BreakpointLocation
327306
/// If it returns false we should continue, otherwise stop.
328307
bool IgnoreCountShouldStop();
329308

330-
/// If this location knows that the virtual stack frame it represents is
331-
/// not frame 0, return the suggested stack frame instead. This will happen
332-
/// when the location's address contains a "virtual inlined call stack" and
333-
/// the breakpoint was set on a file & line that are not at the bottom of that
334-
/// stack. For now we key off the "preferred line entry" - looking for that
335-
/// in the blocks that start with the stop PC.
336-
/// This version of the API doesn't take an "inlined" parameter because it
337-
/// only changes frames in the inline stack.
338-
std::optional<uint32_t> GetSuggestedStackFrameIndex();
339-
340309
private:
341310
void SwapLocation(lldb::BreakpointLocationSP swap_from);
342311

@@ -400,11 +369,6 @@ class BreakpointLocation
400369
lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
401370
StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
402371
/// location has been hit.
403-
/// If this exists, use it to print the stop description rather than the
404-
/// LineEntry m_address resolves to directly. Use this for instance when the
405-
/// location was given somewhere in the virtual inlined call stack since the
406-
/// Address always resolves to the lowest entry in the stack.
407-
std::optional<LineEntry> m_preferred_line_entry;
408372

409373
void SetShouldResolveIndirectFunctions(bool do_resolve) {
410374
m_should_resolve_indirect_functions = do_resolve;

lldb/include/lldb/Breakpoint/BreakpointSite.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
170170
/// \see lldb::DescriptionLevel
171171
void GetDescription(Stream *s, lldb::DescriptionLevel level);
172172

173-
// This runs through all the breakpoint locations owning this site and returns
174-
// the greatest of their suggested stack frame indexes. This only handles
175-
// inlined stack changes.
176-
std::optional<uint32_t> GetSuggestedStackFrameIndex();
177-
178173
/// Tell whether a breakpoint has a location at this site.
179174
///
180175
/// \param[in] bp_id

lldb/include/lldb/Core/Declaration.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,10 @@ class Declaration {
8484
/// \param[in] declaration
8585
/// The const Declaration object to compare with.
8686
///
87-
/// \param[in] full
88-
/// Same meaning as Full in FileSpec::Equal. True means an empty
89-
/// directory is not equal to a specified one, false means it is equal.
90-
///
9187
/// \return
9288
/// Returns \b true if \b declaration is at the same file and
9389
/// line, \b false otherwise.
94-
bool FileAndLineEqual(const Declaration &declaration, bool full) const;
90+
bool FileAndLineEqual(const Declaration &declaration) const;
9591

9692
/// Dump a description of this object to a Stream.
9793
///

lldb/include/lldb/Target/StopInfo.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ class StopInfo : public std::enable_shared_from_this<StopInfo> {
7777
m_description.clear();
7878
}
7979

80-
/// This gives the StopInfo a chance to suggest a stack frame to select.
81-
/// Passing true for inlined_stack will request changes to the inlined
82-
/// call stack. Passing false will request changes to the real stack
83-
/// frame. The inlined stack gets adjusted before we call into the thread
84-
/// plans so they can reason based on the correct values. The real stack
85-
/// adjustment is handled after the frame recognizers get a chance to adjust
86-
/// the frame.
87-
virtual std::optional<uint32_t>
88-
GetSuggestedStackFrameIndex(bool inlined_stack) {
89-
return {};
90-
}
91-
9280
virtual bool IsValidForOperatingSystemThread(Thread &thread) { return true; }
9381

9482
/// A Continue operation can result in a false stop event

lldb/include/lldb/Target/ThreadPlanStepInRange.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
100100
bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put
101101
// a switch in for this if there's
102102
// demand for that.
103-
LazyBool m_virtual_step; // true if we've just done a "virtual step", i.e.
104-
// just moved the inline stack depth.
103+
bool m_virtual_step; // true if we've just done a "virtual step", i.e. just
104+
// moved the inline stack depth.
105105
ConstString m_step_into_target;
106106
std::vector<lldb::break_id_t> m_step_in_deep_bps; // Places where we might
107107
// want to stop when we do a

lldb/source/Breakpoint/BreakpointLocation.cpp

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,8 @@ void BreakpointLocation::GetDescription(Stream *s,
508508
s->PutCString("re-exported target = ");
509509
else
510510
s->PutCString("where = ");
511-
512-
// If there's a preferred line entry for printing, use that.
513-
bool show_function_info = true;
514-
if (auto preferred = GetPreferredLineEntry()) {
515-
sc.line_entry = *preferred;
516-
// FIXME: We're going to get the function name wrong when the preferred
517-
// line entry is not the lowest one. For now, just leave the function
518-
// out in this case, but we really should also figure out how to easily
519-
// fake the function name here.
520-
show_function_info = false;
521-
}
522511
sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
523-
false, true, false, show_function_info,
524-
show_function_info, show_function_info);
512+
false, true, false, true, true, true);
525513
} else {
526514
if (sc.module_sp) {
527515
s->EOL();
@@ -549,10 +537,7 @@ void BreakpointLocation::GetDescription(Stream *s,
549537
if (sc.line_entry.line > 0) {
550538
s->EOL();
551539
s->Indent("location = ");
552-
if (auto preferred = GetPreferredLineEntry())
553-
preferred->DumpStopContext(s, true);
554-
else
555-
sc.line_entry.DumpStopContext(s, true);
540+
sc.line_entry.DumpStopContext(s, true);
556541
}
557542

558543
} else {
@@ -671,50 +656,6 @@ void BreakpointLocation::SendBreakpointLocationChangedEvent(
671656
}
672657
}
673658

674-
std::optional<uint32_t> BreakpointLocation::GetSuggestedStackFrameIndex() {
675-
auto preferred_opt = GetPreferredLineEntry();
676-
if (!preferred_opt)
677-
return {};
678-
LineEntry preferred = *preferred_opt;
679-
SymbolContext sc;
680-
if (!m_address.CalculateSymbolContext(&sc))
681-
return {};
682-
// Don't return anything special if frame 0 is the preferred line entry.
683-
// We not really telling the stack frame list to do anything special in that
684-
// case.
685-
if (!LineEntry::Compare(sc.line_entry, preferred))
686-
return {};
687-
688-
if (!sc.block)
689-
return {};
690-
691-
// Blocks have their line info in Declaration form, so make one here:
692-
Declaration preferred_decl(preferred.GetFile(), preferred.line,
693-
preferred.column);
694-
695-
uint32_t depth = 0;
696-
Block *inlined_block = sc.block->GetContainingInlinedBlock();
697-
while (inlined_block) {
698-
// If we've moved to a block that this isn't the start of, that's not
699-
// our inlining info or call site, so we can stop here.
700-
Address start_address;
701-
if (!inlined_block->GetStartAddress(start_address) ||
702-
start_address != m_address)
703-
return {};
704-
705-
const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo();
706-
if (info) {
707-
if (preferred_decl == info->GetDeclaration())
708-
return depth;
709-
if (preferred_decl == info->GetCallSite())
710-
return depth + 1;
711-
}
712-
inlined_block = inlined_block->GetInlinedParent();
713-
depth++;
714-
}
715-
return {};
716-
}
717-
718659
void BreakpointLocation::SwapLocation(BreakpointLocationSP swap_from) {
719660
m_address = swap_from->m_address;
720661
m_should_resolve_indirect_functions =

lldb/source/Breakpoint/BreakpointResolver.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,21 +340,6 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
340340
}
341341

342342
BreakpointLocationSP bp_loc_sp(AddLocation(line_start));
343-
// If the address that we resolved the location to returns a different
344-
// LineEntry from the one in the incoming SC, we're probably dealing with an
345-
// inlined call site, so set that as the preferred LineEntry:
346-
LineEntry resolved_entry;
347-
if (!skipped_prologue && bp_loc_sp &&
348-
line_start.CalculateSymbolContextLineEntry(resolved_entry) &&
349-
LineEntry::Compare(resolved_entry, sc.line_entry)) {
350-
// FIXME: The function name will also be wrong here. Do we need to record
351-
// that as well, or can we figure that out again when we report this
352-
// breakpoint location.
353-
if (!bp_loc_sp->SetPreferredLineEntry(sc.line_entry)) {
354-
LLDB_LOG(log, "Tried to add a preferred line entry that didn't have the "
355-
"same address as this location's address.");
356-
}
357-
}
358343
if (log && bp_loc_sp && !GetBreakpoint()->IsInternal()) {
359344
StreamString s;
360345
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);

lldb/source/Breakpoint/BreakpointSite.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,6 @@ void BreakpointSite::GetDescription(Stream *s, lldb::DescriptionLevel level) {
8787
m_constituents.GetDescription(s, level);
8888
}
8989

90-
std::optional<uint32_t> BreakpointSite::GetSuggestedStackFrameIndex() {
91-
92-
std::optional<uint32_t> result;
93-
std::lock_guard<std::recursive_mutex> guard(m_constituents_mutex);
94-
for (BreakpointLocationSP loc_sp : m_constituents.BreakpointLocations()) {
95-
std::optional<uint32_t> loc_frame_index =
96-
loc_sp->GetSuggestedStackFrameIndex();
97-
if (loc_frame_index) {
98-
if (result)
99-
result = std::max(*loc_frame_index, *result);
100-
else
101-
result = loc_frame_index;
102-
}
103-
}
104-
return result;
105-
}
106-
10790
bool BreakpointSite::IsInternal() const { return m_constituents.IsInternal(); }
10891

10992
uint8_t *BreakpointSite::GetTrapOpcodeBytes() { return &m_trap_opcode[0]; }

lldb/source/Core/Declaration.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ int Declaration::Compare(const Declaration &a, const Declaration &b) {
7070
return 0;
7171
}
7272

73-
bool Declaration::FileAndLineEqual(const Declaration &declaration,
74-
bool full) const {
75-
int file_compare = FileSpec::Compare(this->m_file, declaration.m_file, full);
73+
bool Declaration::FileAndLineEqual(const Declaration &declaration) const {
74+
int file_compare = FileSpec::Compare(this->m_file, declaration.m_file, true);
7675
return file_compare == 0 && this->m_line == declaration.m_line;
7776
}
7877

lldb/source/Symbol/Block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Block *Block::GetContainingInlinedBlockWithCallSite(
230230
const auto *function_info = inlined_block->GetInlinedFunctionInfo();
231231

232232
if (function_info &&
233-
function_info->GetCallSite().FileAndLineEqual(find_call_site, true))
233+
function_info->GetCallSite().FileAndLineEqual(find_call_site))
234234
return inlined_block;
235235
inlined_block = inlined_block->GetInlinedParent();
236236
}

0 commit comments

Comments
 (0)