Skip to content

Commit

Permalink
MemoryMap update with new segment model.
Browse files Browse the repository at this point in the history
  • Loading branch information
bpotchik committed Jul 19, 2024
1 parent 214b8ba commit 5399427
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
10 changes: 5 additions & 5 deletions core/adapters/lldbadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ std::vector<DebugProcess> LldbAdapter::GetProcessList()
// example output lines:
// 1268 944 csrss.exe
// 37635 9677 xusheng arm64-apple-* Code Helper (Renderer)
//
//
// we've 56 bytes until process name which is calculated like this:
// (6 + 1) + (6 + 1) + (10 + 1) + (30 + 1)

Expand Down Expand Up @@ -513,13 +513,13 @@ bool LldbAdapter::SuspendThread(std::uint32_t tid)
SBThread thread = m_process.GetThreadByID(tid);
if (!thread.IsValid())
return false;

if (!thread.Suspend(error))
return false;

if (!error.Success())
return false;

return true;
}

Expand All @@ -529,7 +529,7 @@ bool LldbAdapter::ResumeThread(std::uint32_t tid)
SBThread thread = m_process.GetThreadByID(tid);
if (!thread.IsValid())
return false;

if (!thread.Resume(error))
return false;

Expand Down Expand Up @@ -610,7 +610,7 @@ DebugBreakpoint LldbAdapter::AddBreakpoint(const ModuleNameAndOffset& address, u
}
else
{
uint64_t addr = address.offset + m_originalBase;
uint64_t addr = address.offset + m_originalImageBase;
std::string entryBreakpointCommand = fmt::format("b -s \"{}\" -a 0x{:x}", address.module, addr);
auto ret = InvokeBackendCommand(entryBreakpointCommand);
DebuggerEvent evt;
Expand Down
2 changes: 1 addition & 1 deletion core/debugadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ DebugAdapter::DebugAdapter(BinaryView* data)
// Here we check if there is actually a function at the entry point, to determine if the entry point is real.
m_hasEntryFunction = (data->GetAnalysisEntryPoint() != nullptr);
m_start = data->GetStart();
m_originalBase = data->GetOriginalBase();
m_originalImageBase = data->GetOriginalImageBase();
if (data->GetDefaultArchitecture())
m_defaultArchitecture = data->GetDefaultArchitecture()->GetName();

Expand Down
8 changes: 4 additions & 4 deletions core/debugadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace BinaryNinjaDebugger {
uint64_t m_entryPoint;
bool m_hasEntryFunction;
uint64_t m_start;
uint64_t m_originalBase;
uint64_t m_originalImageBase;
std::string m_defaultArchitecture;
std::string m_originalFileName;

Expand Down Expand Up @@ -283,13 +283,13 @@ namespace BinaryNinjaDebugger {
virtual bool Go() = 0;

virtual bool GoReverse();

virtual bool StepInto() = 0;

virtual bool StepIntoReverse();

virtual bool StepOver() = 0;

virtual bool StepOverReverse();
// virtual bool RunTo(std::uintptr_t address) = 0;

Expand Down
13 changes: 1 addition & 12 deletions core/debuggercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2522,18 +2522,7 @@ bool DebuggerController::IsTTD()

bool DebuggerController::RemoveDebuggerMemoryRegion()
{
bool ret = GetData()->GetMemoryMap()->RemoveMemoryRegion("debugger");
if (!ret)
return false;

if (m_zeroSegmentAddedByDebugger)
{
auto segment = m_data->GetSegmentAt(0);
if (segment)
m_data->RemoveAutoSegment(segment->GetStart(), segment->GetLength());
}

return true;
return GetData()->GetMemoryMap()->RemoveMemoryRegion("debugger");
}


Expand Down

0 comments on commit 5399427

Please sign in to comment.