Skip to content

Commit 4d48545

Browse files
committed
create persistent breakpoints
1 parent f2212c5 commit 4d48545

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

lldb/include/lldb/API/SBTarget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,9 @@ class LLDB_API SBTarget {
737737

738738
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
739739

740+
lldb::SBBreakpoint BreakpointCreateByFileAddress(const SBFileSpec &file_spec,
741+
addr_t file_addr);
742+
740743
/// Create a breakpoint using a scripted resolver.
741744
///
742745
/// \param[in] class_name

lldb/include/lldb/Target/Target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ class Target : public std::enable_shared_from_this<Target>,
723723
lldb::BreakpointSP CreateBreakpoint(lldb::addr_t load_addr, bool internal,
724724
bool request_hardware);
725725

726-
// Use this to create a breakpoint from a load address and a module file spec
726+
// Use this to create a breakpoint from a file address and a module file spec
727727
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr,
728728
bool internal,
729729
const FileSpec &file_spec,

lldb/source/API/SBTarget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
#include "Commands/CommandObjectBreakpoint.h"
6868
#include "lldb/Interpreter/CommandReturnObject.h"
69+
#include "lldb/lldb-types.h"
6970
#include "llvm/Support/PrettyStackTrace.h"
7071
#include "llvm/Support/Regex.h"
7172

@@ -949,6 +950,19 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
949950
return sb_bp;
950951
}
951952

953+
SBBreakpoint SBTarget::BreakpointCreateByFileAddress(const SBFileSpec &file_spec, addr_t file_addr) {
954+
LLDB_INSTRUMENT_VA(this, file_spec, file_addr);
955+
956+
SBBreakpoint sb_bp;
957+
if (TargetSP target_sp = GetSP()) {
958+
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
959+
const bool hardware = false;
960+
sb_bp = target_sp->CreateAddressInModuleBreakpoint(file_addr, false, *file_spec.get(), hardware);
961+
}
962+
963+
return sb_bp;
964+
}
965+
952966
lldb::SBBreakpoint
953967
SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
954968
const lldb::SBFileSpec &source_file,

lldb/tools/lldb-dap/Protocol/DAPTypes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ bool fromJSON(const llvm::json::Value &Params, PersistenceData &PD,
99
llvm::json::Path P) {
1010
json::ObjectMapper O(Params, P);
1111
return O && O.mapOptional("module", PD.module) &&
12-
O.mapOptional("symbol_mangled_name", PD.symbol_mangled_name);
12+
O.mapOptional("file_addr", PD.file_addr);
1313
}
1414

1515
llvm::json::Value toJSON(const PersistenceData &PD) {
1616
json::Object result{
1717
{"module", PD.module},
18-
{"symbol_mangled_name", PD.symbol_mangled_name},
18+
{"file_addr", PD.file_addr},
1919
};
2020

2121
return result;

lldb/tools/lldb-dap/Protocol/DAPTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ struct PersistenceData {
3131
/// The source module path.
3232
std::string module;
3333

34-
/// The symbol unique name.
35-
std::string symbol_mangled_name;
34+
/// The file address inside the module.
35+
lldb::addr_t file_addr;
3636
};
3737
bool fromJSON(const llvm::json::Value &, PersistenceData &,
3838
llvm::json::Path);

lldb/tools/lldb-dap/SourceBreakpoint.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "JSONUtils.h"
1313
#include "ProtocolUtils.h"
1414
#include "lldb/API/SBBreakpoint.h"
15+
#include "lldb/API/SBFileSpec.h"
1516
#include "lldb/API/SBFileSpecList.h"
1617
#include "lldb/API/SBFrame.h"
1718
#include "lldb/API/SBInstruction.h"
@@ -115,6 +116,8 @@ llvm::Error SourceBreakpoint::CreateAssemblyBreakpointWithSourceReference(int64_
115116
}
116117

117118
llvm::Error SourceBreakpoint::CreateAssemblyBreakpointWithPersistenceData(const protocol::PersistenceData &persistence_data) {
119+
lldb::SBFileSpec file_spec(persistence_data.module.c_str());
120+
m_bp = m_dap.target.BreakpointCreateByFileAddress(file_spec, persistence_data.file_addr);
118121
return llvm::Error::success();
119122
}
120123

0 commit comments

Comments
 (0)