Skip to content

Commit

Permalink
Support adding a breakpoint from the breakpoints widget
Browse files Browse the repository at this point in the history
  • Loading branch information
xusheng6 committed Feb 1, 2023
1 parent 82f09f5 commit ae406d2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ui/breakpointswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ DebugBreakpointsWidget::DebugBreakpointsWidget(ViewFrame* view, BinaryViewRef da
m_actionHandler.bindAction(
jumpToBreakpointActionName, UIAction([&]() { jump(); }, [&]() { return selectionNotEmpty(); }));

QString addBreakpointActionName = QString::fromStdString("Add Breakpoint...");
UIAction::registerAction(addBreakpointActionName);
m_menu->addAction(addBreakpointActionName, "Options", MENU_ORDER_NORMAL);
m_actionHandler.bindAction(
addBreakpointActionName, UIAction([&]() { add(); }));

connect(m_table, &QTableView::doubleClicked, this, &DebugBreakpointsWidget::onDoubleClicked);

updateContent();
Expand Down Expand Up @@ -319,6 +325,43 @@ void DebugBreakpointsWidget::jump()
}


void DebugBreakpointsWidget::add()
{
UIContext* ctxt = UIContext::contextForWidget(this);
if (!ctxt)
return;

ViewFrame* frame = ctxt->getCurrentViewFrame();
if (!frame)
return;

auto view = frame->getCurrentBinaryView();
if (!view)
return;

uint64_t address = 0;
if (!ViewFrame::getAddressFromInput(frame, view, address,
frame->getCurrentOffset(), "Add Breakpoint", "The address of the breakpoint:", true))
return;

bool isAbsoluteAddress = false;
if (view->GetTypeName() == "Debugger")
isAbsoluteAddress = true;

if (isAbsoluteAddress)
{
m_controller->AddBreakpoint(address);
}
else
{
std::string filename = m_controller->GetExecutablePath();
uint64_t offset = address - view->GetStart();
ModuleNameAndOffset info = {filename, offset};
m_controller->AddBreakpoint(info);
}
}


void DebugBreakpointsWidget::remove()
{
QModelIndexList sel = m_table->selectionModel()->selectedRows();
Expand Down
1 change: 1 addition & 0 deletions ui/breakpointswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private slots:
void jump();
void remove();
void onDoubleClicked();
void add();

public slots:
void updateContent();
Expand Down

0 comments on commit ae406d2

Please sign in to comment.