Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 16 additions & 34 deletions lldb/include/lldb/Target/StackID.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@
#define LLDB_TARGET_STACKID_H

#include "lldb/Core/AddressRange.h"
#include "lldb/lldb-private.h"

namespace lldb_private {

class Process;

class StackID {
public:
// Constructors and Destructors
StackID() = default;

explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
SymbolContextScope *symbol_scope, Process *process);

StackID(const StackID &rhs)
: m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}

~StackID() = default;

lldb::addr_t GetPC() const { return m_pc; }
Expand All @@ -51,41 +46,28 @@ class StackID {

void Dump(Stream *s);

// Operators
const StackID &operator=(const StackID &rhs) {
if (this != &rhs) {
m_pc = rhs.m_pc;
m_cfa = rhs.m_cfa;
m_symbol_scope = rhs.m_symbol_scope;
}
return *this;
}

protected:
friend class StackFrame;

void SetPC(lldb::addr_t pc, Process *process);
void SetCFA(lldb::addr_t cfa, Process *process);

lldb::addr_t m_pc =
LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
// frame. This will
// only get used if the symbol scope is nullptr (the code where we are
// stopped is not represented by any function or symbol in any shared
// library).
lldb::addr_t m_cfa =
LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
// at the beginning of the function that uniquely
// identifies this frame (along with m_symbol_scope
// below)
SymbolContextScope *m_symbol_scope =
nullptr; // If nullptr, there is no block or symbol for this frame.
// If not nullptr, this will either be the scope for the
// lexical block for the frame, or the scope for the
// symbol. Symbol context scopes are always be unique
// pointers since the are part of the Block and Symbol
// objects and can easily be used to tell if a stack ID
// is the same as another.
/// The pc value for the function/symbol for this frame. This will only get
/// used if the symbol scope is nullptr (the code where we are stopped is not
/// represented by any function or symbol in any shared library).
lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;

/// The call frame address (stack pointer) value at the beginning of the
/// function that uniquely identifies this frame (along with m_symbol_scope
/// below)
lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;

/// If nullptr, there is no block or symbol for this frame. If not nullptr,
/// this will either be the scope for the lexical block for the frame, or the
/// scope for the symbol. Symbol context scopes are always be unique pointers
/// since the are part of the Block and Symbol objects and can easily be used
/// to tell if a stack ID is the same as another.
SymbolContextScope *m_symbol_scope = nullptr;
};

bool operator==(const StackID &lhs, const StackID &rhs);
Expand Down
11 changes: 1 addition & 10 deletions lldb/source/Target/StackID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,7 @@ bool lldb_private::operator==(const StackID &lhs, const StackID &rhs) {
}

bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
return true;

SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();

if (lhs_scope == nullptr && rhs_scope == nullptr)
return lhs.GetPC() != rhs.GetPC();

return lhs_scope != rhs_scope;
return !(lhs == rhs);
}

bool lldb_private::operator<(const StackID &lhs, const StackID &rhs) {
Expand Down
Loading