Move breakpoint control code out of view class - it doesn't really belong there

This commit is contained in:
Vas Crabb 2015-02-18 18:21:36 +11:00
parent 073e19b89d
commit 69c1475dbf
11 changed files with 348 additions and 267 deletions

View File

@ -37,6 +37,10 @@
- (IBAction)doCommand:(id)sender;
- (IBAction)debugToggleBreakpoint:(id)sender;
- (IBAction)debugToggleBreakpointEnable:(id)sender;
- (IBAction)debugRunToCursor:(id)sender;
- (IBAction)debugNewMemoryWindow:(id)sender;
- (IBAction)debugNewDisassemblyWindow:(id)sender;
- (IBAction)debugNewErrorLogWindow:(id)sender;

View File

@ -53,9 +53,7 @@
[regView release];
// create the disassembly view
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
machine:*machine
useConsole:YES];
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
[dasmView setExpression:@"curpc"];
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
[dasmScroll setDrawsBackground:YES];
@ -215,10 +213,13 @@
- (IBAction)doCommand:(id)sender {
NSString *command = [sender stringValue];
if ([command length] == 0) {
if ([command length] == 0)
{
debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
[history reset];
} else {
}
else
{
debug_console_execute_command(*machine, [command UTF8String], 1);
[history add:command];
[history edit];
@ -227,6 +228,54 @@
}
- (IBAction)debugToggleBreakpoint:(id)sender {
device_t &device = [dasmView source]->device();
if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device))
{
offs_t const address = [dasmView selectedAddress];
device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address
forDevice:device];
// if it doesn't exist, add a new one
NSString *command;
if (bp == NULL)
command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address];
else
command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()];
debug_console_execute_command(*machine, [command UTF8String], 1);
}
}
- (IBAction)debugToggleBreakpointEnable:(id)sender {
device_t &device = [dasmView source]->device();
if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device))
{
device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
forDevice:device];
if (bp != NULL)
{
NSString *command;
if (bp->enabled())
command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()];
else
command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()];
debug_console_execute_command(*machine, [command UTF8String], 1);
}
}
}
- (IBAction)debugRunToCursor:(id)sender {
device_t &device = [dasmView source]->device();
if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device))
{
NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)[dasmView selectedAddress]];
debug_console_execute_command(*machine, [command UTF8String], 1);
}
}
- (IBAction)debugNewMemoryWindow:(id)sender {
MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self];
[auxiliaryWindows addObject:win];
@ -419,4 +468,74 @@
[[[sender subviews] objectAtIndex:1] setFrame:second];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item {
SEL const action = [item action];
BOOL const inContextMenu = ([item menu] == [dasmView menu]);
BOOL const haveCursor = [dasmView cursorVisible];
BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == &[dasmView source]->device());
device_debug::breakpoint *breakpoint = NULL;
if (haveCursor)
{
breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
forDevice:[dasmView source]->device()];
}
if (action == @selector(debugToggleBreakpoint:))
{
if (haveCursor)
{
if (breakpoint != NULL)
{
if (inContextMenu)
[item setTitle:@"Clear Breakpoint"];
else
[item setTitle:@"Clear Breakpoint at Cursor"];
}
else
{
if (inContextMenu)
[item setTitle:@"Set Breakpoint"];
else
[item setTitle:@"Set Breakpoint at Cursor"];
}
}
else
{
if (inContextMenu)
[item setTitle:@"Toggle Breakpoint"];
else
[item setTitle:@"Toggle Breakpoint at Cursor"];
}
return haveCursor && isCurrent;
}
else if (action == @selector(debugToggleBreakpointEnable:))
{
if ((breakpoint != NULL) && !breakpoint->enabled())
{
if (inContextMenu)
[item setTitle:@"Enable Breakpoint"];
else
[item setTitle:@"Enable Breakpoint at Cursor"];
}
else
{
if (inContextMenu)
[item setTitle:@"Disable Breakpoint"];
else
[item setTitle:@"Disable Breakpoint at Cursor"];
}
return (breakpoint != NULL) && isCurrent;
}
else if (action == @selector(debugRunToCursor:))
{
return isCurrent;
}
else
{
return YES;
}
}
@end

View File

@ -44,6 +44,10 @@
- (NSFont *)font;
- (void)setFont:(NSFont *)f;
- (BOOL)cursorSupported;
- (BOOL)cursorVisible;
- (debug_view_xy)cursorPosition;
- (void)windowDidBecomeKey:(NSNotification *)notification;
- (void)windowDidResignKey:(NSNotification *)notification;

View File

@ -286,6 +286,21 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
}
- (BOOL)cursorSupported {
return view->cursor_supported();
}
- (BOOL)cursorVisible {
return view->cursor_visible();
}
- (debug_view_xy)cursorPosition {
return view->cursor_position();
}
- (void)windowDidBecomeKey:(NSNotification *)notification {
NSWindow *win = [notification object];
if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported())

View File

@ -12,6 +12,7 @@
#import "debugosx.h"
#include "emu.h"
#include "debug/debugcpu.h"
#import <Cocoa/Cocoa.h>
@ -34,6 +35,8 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification;
+ (void)addCommonActionItems:(NSMenu *)menu;
+ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame;
+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device;
- (id)initWithMachine:(running_machine &)m title:(NSString *)t;
- (void)activate;

View File

@ -14,8 +14,6 @@
#import "debugcommandhistory.h"
#import "debugview.h"
#include "debug/debugcpu.h"
//============================================================
// NOTIFICATIONS
@ -128,6 +126,14 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
}
+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device {
device_debug *const cpuinfo = device.debug();
device_debug::breakpoint *bp = cpuinfo->breakpoint_first();
while ((bp != NULL) && (address != bp->address())) bp = bp->next();
return bp;
}
- (id)initWithMachine:(running_machine &)m title:(NSString *)t {
if (!(self = [super init]))
return nil;
@ -421,4 +427,4 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
return NO;
}
@end
@end

View File

@ -21,10 +21,9 @@
@interface MAMEDisassemblyView : MAMEDebugView <MAMEDebugViewSubviewSupport, MAMEDebugViewExpressionSupport>
{
BOOL useConsole;
}
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc;
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m;
- (NSSize)maximumFrameSize;
@ -38,10 +37,7 @@
- (void)setExpression:(NSString *)exp;
- (debug_view_disasm_source const *)source;
- (IBAction)debugToggleBreakpoint:(id)sender;
- (IBAction)debugToggleBreakpointEnable:(id)sender;
- (IBAction)debugRunToCursor:(id)sender;
- (offs_t)selectedAddress;
- (IBAction)showRightColumn:(id)sender;

View File

@ -11,21 +11,11 @@
#import "disassemblyview.h"
#include "debugger.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include "debug/debugvw.h"
@implementation MAMEDisassemblyView
- (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device {
device_debug *cpuinfo = device.debug();
device_debug::breakpoint *bp;
for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) { }
return bp;
}
- (void)createContextMenu {
NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"];
NSMenuItem *item;
@ -34,13 +24,11 @@
action:@selector(debugToggleBreakpoint:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
[item setKeyEquivalentModifierMask:0];
[item setTarget:self];
item = [contextMenu addItemWithTitle:@"Disable Breakpoint"
action:@selector(debugToggleBreakpointEnable:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
[item setKeyEquivalentModifierMask:NSShiftKeyMask];
[item setTarget:self];
[contextMenu addItem:[NSMenuItem separatorItem]];
@ -48,7 +36,6 @@
action:@selector(debugRunToCursor:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
[item setKeyEquivalentModifierMask:0];
[item setTarget:self];
[contextMenu addItem:[NSMenuItem separatorItem]];
@ -75,10 +62,9 @@
}
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc {
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m]))
return nil;
useConsole = uc;
[self createContextMenu];
return self;
}
@ -91,68 +77,8 @@
- (BOOL)validateMenuItem:(NSMenuItem *)item {
SEL const action = [item action];
BOOL const inContextMenu = ([item menu] == [self menu]);
BOOL haveCursor = view->cursor_visible();
BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == view->source()->device());
device_debug::breakpoint *breakpoint = NULL;
if (haveCursor)
{
offs_t const address = downcast<debug_view_disasm *>(view)->selected_address();
breakpoint = [self findBreakpointAtAddress:address forDevice:[self source]->device()];
}
if (action == @selector(debugToggleBreakpoint:))
{
if (haveCursor)
{
if (breakpoint != NULL)
{
if (inContextMenu)
[item setTitle:@"Clear Breakpoint"];
else
[item setTitle:@"Clear Breakpoint at Cursor"];
}
else
{
if (inContextMenu)
[item setTitle:@"Set Breakpoint"];
else
[item setTitle:@"Set Breakpoint at Cursor"];
}
}
else
{
if (inContextMenu)
[item setTitle:@"Toggle Breakpoint"];
else
[item setTitle:@"Toggle Breakpoint at Cursor"];
}
return haveCursor && (!useConsole || isCurrent);
}
else if (action == @selector(debugToggleBreakpointEnable:))
{
if ((breakpoint != NULL) && !breakpoint->enabled())
{
if (inContextMenu)
[item setTitle:@"Enable Breakpoint"];
else
[item setTitle:@"Enable Breakpoint at Cursor"];
}
else
{
if (inContextMenu)
[item setTitle:@"Disable Breakpoint"];
else
[item setTitle:@"Disable Breakpoint at Cursor"];
}
return (breakpoint != NULL) && (!useConsole || isCurrent);
}
else if (action == @selector(debugRunToCursor:))
{
return !useConsole || isCurrent;
}
else if (action == @selector(showRightColumn:))
if (action == @selector(showRightColumn:))
{
[item setState:((downcast<debug_view_disasm *>(view)->right_column() == [item tag]) ? NSOnState : NSOffState)];
return YES;
@ -166,17 +92,13 @@
- (NSSize)maximumFrameSize {
debug_view_xy max(0, 0);
const debug_view_source *source = view->source();
for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next())
debug_view_source const *source = view->source();
for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next())
{
debug_view_xy current;
view->set_source(*source);
current = view->total_size();
if (current.x > max.x)
max.x = current.x;
if (current.y > max.y)
max.y = current.y;
debug_view_xy const current = view->total_size();
max.x = MAX(max.x, current.x);
max.y = MAX(max.y, current.y);
}
view->set_source(*source);
return NSMakeSize(max.x * fontWidth, max.y * fontHeight);
@ -267,101 +189,8 @@
}
- (IBAction)debugToggleBreakpoint:(id)sender {
if (view->cursor_visible())
{
device_t &device = [self source]->device();
if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device))
{
offs_t const address = downcast<debug_view_disasm *>(view)->selected_address();
device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device];
// if it doesn't exist, add a new one
if (useConsole)
{
NSString *command;
if (bp == NULL)
command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address];
else
command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()];
debug_console_execute_command(*machine, [command UTF8String], 1);
}
else
{
if (bp == NULL)
{
UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL);
debug_console_printf(*machine, "Breakpoint %X set\n", bpnum);
}
else
{
int const bpnum = bp->index();
device.debug()->breakpoint_clear(bpnum);
debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum);
}
}
// fail to do this and the display doesn't update
machine->debug_view().update_all();
debugger_refresh_display(*machine);
}
}
}
- (IBAction)debugToggleBreakpointEnable:(id)sender {
if (view->cursor_visible())
{
device_t &device = [self source]->device();
if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device))
{
offs_t const address = downcast<debug_view_disasm *>(view)->selected_address();
device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device];
if (bp != NULL)
{
if (useConsole)
{
NSString *command;
if (bp->enabled())
command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()];
else
command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()];
debug_console_execute_command(*machine, [command UTF8String], 1);
}
else
{
device.debug()->breakpoint_enable(bp->index(), !bp->enabled());
debug_console_printf(*machine,
"Breakpoint %X %s\n",
(UINT32)bp->index(),
bp->enabled() ? "enabled" : "disabled");
}
machine->debug_view().update_all();
debugger_refresh_display(*machine);
}
}
}
}
- (IBAction)debugRunToCursor:(id)sender {
if (view->cursor_visible())
{
device_t &device = [self source]->device();
if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device))
{
offs_t const address = downcast<debug_view_disasm *>(view)->selected_address();
if (useConsole)
{
NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)address];
debug_console_execute_command(*machine, [command UTF8String], 1);
}
else
{
device.debug()->go(address);
}
}
}
- (offs_t)selectedAddress {
return downcast<debug_view_disasm *>(view)->selected_address();
}
@ -371,64 +200,55 @@
- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index {
{
NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor"
action:@selector(debugToggleBreakpoint:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
atIndex:index++];
[breakItem setKeyEquivalentModifierMask:0];
[breakItem setTarget:self];
}
{
NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor"
action:@selector(debugToggleBreakpointEnable:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
atIndex:index++];
[disableItem setKeyEquivalentModifierMask:NSShiftKeyMask];
[disableItem setAlternate:YES];
[disableItem setTarget:self];
}
{
NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu];
NSMenuItem *runItem;
if (runMenu != nil) {
runItem = [runMenu addItemWithTitle:@"to Cursor"
action:@selector(debugRunToCursor:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
} else {
runItem = [menu insertItemWithTitle:@"Run to Cursor"
action:@selector(debugRunToCursor:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]
atIndex:index++];
}
[runItem setKeyEquivalentModifierMask:0];
[runItem setTarget:self];
NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor"
action:@selector(debugToggleBreakpoint:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
atIndex:index++];
[breakItem setKeyEquivalentModifierMask:0];
NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor"
action:@selector(debugToggleBreakpointEnable:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
atIndex:index++];
[disableItem setKeyEquivalentModifierMask:NSShiftKeyMask];
NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu];
NSMenuItem *runItem;
if (runMenu != nil) {
runItem = [runMenu addItemWithTitle:@"to Cursor"
action:@selector(debugRunToCursor:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
} else {
runItem = [menu insertItemWithTitle:@"Run to Cursor"
action:@selector(debugRunToCursor:)
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]
atIndex:index++];
}
[runItem setKeyEquivalentModifierMask:0];
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
{
NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes"
action:@selector(showRightColumn:)
keyEquivalent:@"r"
atIndex:index++];
[rawItem setTarget:self];
[rawItem setTag:DASM_RIGHTCOL_RAW];
}
{
NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes"
action:@selector(showRightColumn:)
keyEquivalent:@"e"
atIndex:index++];
[encItem setTarget:self];
[encItem setTag:DASM_RIGHTCOL_ENCRYPTED];
}
{
NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments"
action:@selector(showRightColumn:)
keyEquivalent:@"n"
atIndex:index++];
[commentsItem setTarget:self];
[commentsItem setTag:DASM_RIGHTCOL_COMMENTS];
}
NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes"
action:@selector(showRightColumn:)
keyEquivalent:@"r"
atIndex:index++];
[rawItem setTarget:self];
[rawItem setTag:DASM_RIGHTCOL_RAW];
NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes"
action:@selector(showRightColumn:)
keyEquivalent:@"e"
atIndex:index++];
[encItem setTarget:self];
[encItem setTag:DASM_RIGHTCOL_ENCRYPTED];
NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments"
action:@selector(showRightColumn:)
keyEquivalent:@"n"
atIndex:index++];
[commentsItem setTarget:self];
[commentsItem setTag:DASM_RIGHTCOL_COMMENTS];
if (index < [menu numberOfItems])
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
}

View File

@ -31,6 +31,10 @@
- (BOOL)selectSubviewForDevice:(device_t *)device;
- (BOOL)selectSubviewForSpace:(address_space *)space;
- (IBAction)debugToggleBreakpoint:(id)sender;
- (IBAction)debugToggleBreakpointEnable:(id)sender;
- (IBAction)debugRunToCursor:(id)sender;
- (IBAction)changeSubview:(id)sender;
@end

View File

@ -15,6 +15,8 @@
#import "debugview.h"
#import "disassemblyview.h"
#include "debugger.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
@ -69,9 +71,7 @@
[expressionContainer release];
// create the disassembly view
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
machine:*machine
useConsole:NO];
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
[dasmView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0];
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,
0,
@ -161,9 +161,127 @@
}
- (IBAction)debugToggleBreakpoint:(id)sender {
if ([dasmView cursorVisible])
{
device_t &device = [dasmView source]->device();
offs_t const address = [dasmView selectedAddress];
device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device];
// if it doesn't exist, add a new one
if (bp == NULL)
{
UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL);
debug_console_printf(*machine, "Breakpoint %X set\n", bpnum);
}
else
{
int const bpnum = bp->index();
device.debug()->breakpoint_clear(bpnum);
debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum);
}
// fail to do this and the display doesn't update
machine->debug_view().update_all();
debugger_refresh_display(*machine);
}
}
- (IBAction)debugToggleBreakpointEnable:(id)sender {
if ([dasmView cursorVisible])
{
device_t &device = [dasmView source]->device();
offs_t const address = [dasmView selectedAddress];
device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device];
if (bp != NULL)
{
device.debug()->breakpoint_enable(bp->index(), !bp->enabled());
debug_console_printf(*machine,
"Breakpoint %X %s\n",
(UINT32)bp->index(),
bp->enabled() ? "enabled" : "disabled");
machine->debug_view().update_all();
debugger_refresh_display(*machine);
}
}
}
- (IBAction)debugRunToCursor:(id)sender {
if ([dasmView cursorVisible])
[dasmView source]->device().debug()->go([dasmView selectedAddress]);
}
- (IBAction)changeSubview:(id)sender {
[dasmView selectSubviewAtIndex:[[sender selectedItem] tag]];
[window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item {
SEL const action = [item action];
BOOL const inContextMenu = ([item menu] == [dasmView menu]);
BOOL const haveCursor = [dasmView cursorVisible];
device_debug::breakpoint *breakpoint = NULL;
if (haveCursor)
{
breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
forDevice:[dasmView source]->device()];
}
if (action == @selector(debugToggleBreakpoint:))
{
if (haveCursor)
{
if (breakpoint != NULL)
{
if (inContextMenu)
[item setTitle:@"Clear Breakpoint"];
else
[item setTitle:@"Clear Breakpoint at Cursor"];
}
else
{
if (inContextMenu)
[item setTitle:@"Set Breakpoint"];
else
[item setTitle:@"Set Breakpoint at Cursor"];
}
}
else
{
if (inContextMenu)
[item setTitle:@"Toggle Breakpoint"];
else
[item setTitle:@"Toggle Breakpoint at Cursor"];
}
return haveCursor;
}
else if (action == @selector(debugToggleBreakpointEnable:))
{
if ((breakpoint != NULL) && !breakpoint->enabled())
{
if (inContextMenu)
[item setTitle:@"Enable Breakpoint"];
else
[item setTitle:@"Enable Breakpoint at Cursor"];
}
else
{
if (inContextMenu)
[item setTitle:@"Disable Breakpoint"];
else
[item setTitle:@"Disable Breakpoint at Cursor"];
}
return breakpoint != NULL;
}
else
{
return YES;
}
}
@end

View File

@ -56,22 +56,14 @@
- (NSSize)maximumFrameSize {
debug_view_xy max;
device_t *curcpu = debug_cpu_get_visible_cpu(*machine);
debug_view_source const *source = view->source_for_device(curcpu);
max.x = max.y = 0;
for (const debug_view_source *source = view->source_list().first();
source != NULL;
source = source->next())
debug_view_xy max(0, 0);
debug_view_source const *source = view->source();
for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next())
{
debug_view_xy current;
view->set_source(*source);
current = view->total_size();
if (current.x > max.x)
max.x = current.x;
if (current.y > max.y)
max.y = current.y;
debug_view_xy const current = view->total_size();
max.x = MAX(max.x, current.x);
max.y = MAX(max.y, current.y);
}
view->set_source(*source);
return NSMakeSize(max.x * fontWidth, max.y * fontHeight);