Implement "Set next statement".
Adds a context menu command allowing the user to specify that the active thread should be set to execute the specified statement next, by updating its instruction pointer. Implements second part of #9709. Note that care needs to be taken with this feature for now, as it doesn't yet sanity check the requested address. Setting the target to e.g. a statement in an entirely different function is likely to have unpredictable/unstable effects on the debugged program.
This commit is contained in:
@@ -314,6 +314,10 @@ private:
|
|||||||
void _ScrollToTop();
|
void _ScrollToTop();
|
||||||
void _ScrollToBottom();
|
void _ScrollToBottom();
|
||||||
|
|
||||||
|
bool _AddContextItem(BPopUpMenu* menu,
|
||||||
|
const char* text, uint32 what,
|
||||||
|
target_addr_t address) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
float fMaxLineWidth;
|
float fMaxLineWidth;
|
||||||
@@ -1255,31 +1259,20 @@ SourceView::TextView::MouseDown(BPoint where)
|
|||||||
if (!fSourceView->GetStatementForLine(line, statement))
|
if (!fSourceView->GetStatementForLine(line, statement))
|
||||||
return;
|
return;
|
||||||
BReference<Statement> statementReference(statement, true);
|
BReference<Statement> statementReference(statement, true);
|
||||||
|
target_addr_t address = statement->CoveringAddressRange().Start();
|
||||||
|
|
||||||
BPopUpMenu* menu = new(std::nothrow) BPopUpMenu("");
|
BPopUpMenu* menu = new(std::nothrow) BPopUpMenu("");
|
||||||
if (menu == NULL)
|
if (menu == NULL)
|
||||||
return;
|
return;
|
||||||
ObjectDeleter<BPopUpMenu> menuDeleter(menu);
|
ObjectDeleter<BPopUpMenu> menuDeleter(menu);
|
||||||
|
|
||||||
BMessage* message = new(std::nothrow) BMessage(MSG_THREAD_RUN);
|
if (!_AddContextItem(menu, "Run to cursor", MSG_THREAD_RUN, address))
|
||||||
if (message == NULL)
|
|
||||||
return;
|
|
||||||
ObjectDeleter<BMessage> messageDeleter(message);
|
|
||||||
|
|
||||||
message->AddUInt64("address", statement->CoveringAddressRange()
|
|
||||||
.Start());
|
|
||||||
BMenuItem* item = new(std::nothrow) BMenuItem("Run to cursor",
|
|
||||||
message);
|
|
||||||
if (item == NULL)
|
|
||||||
return;
|
|
||||||
ObjectDeleter<BMenuItem> itemDeleter(item);
|
|
||||||
messageDeleter.Detach();
|
|
||||||
|
|
||||||
if (!menu->AddItem(item))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
itemDeleter.Detach();
|
if (!_AddContextItem(menu, "Set next statement",
|
||||||
messageDeleter.Detach();
|
MSG_THREAD_SET_ADDRESS, address)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
menuDeleter.Detach();
|
menuDeleter.Detach();
|
||||||
|
|
||||||
BPoint screenWhere(where);
|
BPoint screenWhere(where);
|
||||||
@@ -1743,6 +1736,30 @@ SourceView::TextView::_ScrollToBottom(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SourceView::TextView::_AddContextItem(BPopUpMenu* menu, const char* text,
|
||||||
|
uint32 what, target_addr_t address) const
|
||||||
|
{
|
||||||
|
BMessage* message = new(std::nothrow) BMessage(what);
|
||||||
|
if (message == NULL)
|
||||||
|
return false;
|
||||||
|
ObjectDeleter<BMessage> messageDeleter(message);
|
||||||
|
|
||||||
|
message->AddUInt64("address", address);
|
||||||
|
BMenuItem* item = new(std::nothrow) BMenuItem(text, message);
|
||||||
|
if (item == NULL)
|
||||||
|
return false;
|
||||||
|
ObjectDeleter<BMenuItem> itemDeleter(item);
|
||||||
|
messageDeleter.Detach();
|
||||||
|
|
||||||
|
if (!menu->AddItem(item))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
itemDeleter.Detach();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - SourceView
|
// #pragma mark - SourceView
|
||||||
|
|
||||||
|
|
||||||
@@ -1795,6 +1812,7 @@ SourceView::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case MSG_THREAD_RUN:
|
case MSG_THREAD_RUN:
|
||||||
|
case MSG_THREAD_SET_ADDRESS:
|
||||||
{
|
{
|
||||||
target_addr_t address;
|
target_addr_t address;
|
||||||
if (message->FindUInt64("address", &address) != B_OK)
|
if (message->FindUInt64("address", &address) != B_OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user