mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
Move breakpoint control code out of view class - it doesn't really belong there
This commit is contained in:
parent
073e19b89d
commit
69c1475dbf
@ -37,6 +37,10 @@
|
|||||||
|
|
||||||
- (IBAction)doCommand:(id)sender;
|
- (IBAction)doCommand:(id)sender;
|
||||||
|
|
||||||
|
- (IBAction)debugToggleBreakpoint:(id)sender;
|
||||||
|
- (IBAction)debugToggleBreakpointEnable:(id)sender;
|
||||||
|
- (IBAction)debugRunToCursor:(id)sender;
|
||||||
|
|
||||||
- (IBAction)debugNewMemoryWindow:(id)sender;
|
- (IBAction)debugNewMemoryWindow:(id)sender;
|
||||||
- (IBAction)debugNewDisassemblyWindow:(id)sender;
|
- (IBAction)debugNewDisassemblyWindow:(id)sender;
|
||||||
- (IBAction)debugNewErrorLogWindow:(id)sender;
|
- (IBAction)debugNewErrorLogWindow:(id)sender;
|
||||||
|
@ -53,9 +53,7 @@
|
|||||||
[regView release];
|
[regView release];
|
||||||
|
|
||||||
// create the disassembly view
|
// create the disassembly view
|
||||||
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
|
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||||
machine:*machine
|
|
||||||
useConsole:YES];
|
|
||||||
[dasmView setExpression:@"curpc"];
|
[dasmView setExpression:@"curpc"];
|
||||||
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||||
[dasmScroll setDrawsBackground:YES];
|
[dasmScroll setDrawsBackground:YES];
|
||||||
@ -215,10 +213,13 @@
|
|||||||
|
|
||||||
- (IBAction)doCommand:(id)sender {
|
- (IBAction)doCommand:(id)sender {
|
||||||
NSString *command = [sender stringValue];
|
NSString *command = [sender stringValue];
|
||||||
if ([command length] == 0) {
|
if ([command length] == 0)
|
||||||
|
{
|
||||||
debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
|
debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
|
||||||
[history reset];
|
[history reset];
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
debug_console_execute_command(*machine, [command UTF8String], 1);
|
debug_console_execute_command(*machine, [command UTF8String], 1);
|
||||||
[history add:command];
|
[history add:command];
|
||||||
[history edit];
|
[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 {
|
- (IBAction)debugNewMemoryWindow:(id)sender {
|
||||||
MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self];
|
MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self];
|
||||||
[auxiliaryWindows addObject:win];
|
[auxiliaryWindows addObject:win];
|
||||||
@ -419,4 +468,74 @@
|
|||||||
[[[sender subviews] objectAtIndex:1] setFrame:second];
|
[[[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
|
@end
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
- (NSFont *)font;
|
- (NSFont *)font;
|
||||||
- (void)setFont:(NSFont *)f;
|
- (void)setFont:(NSFont *)f;
|
||||||
|
|
||||||
|
- (BOOL)cursorSupported;
|
||||||
|
- (BOOL)cursorVisible;
|
||||||
|
- (debug_view_xy)cursorPosition;
|
||||||
|
|
||||||
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
||||||
- (void)windowDidResignKey:(NSNotification *)notification;
|
- (void)windowDidResignKey:(NSNotification *)notification;
|
||||||
|
|
||||||
|
@ -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 {
|
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
||||||
NSWindow *win = [notification object];
|
NSWindow *win = [notification object];
|
||||||
if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported())
|
if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported())
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#import "debugosx.h"
|
#import "debugosx.h"
|
||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
|
#include "debug/debugcpu.h"
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification;
|
|||||||
+ (void)addCommonActionItems:(NSMenu *)menu;
|
+ (void)addCommonActionItems:(NSMenu *)menu;
|
||||||
+ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame;
|
+ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame;
|
||||||
|
|
||||||
|
+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device;
|
||||||
|
|
||||||
- (id)initWithMachine:(running_machine &)m title:(NSString *)t;
|
- (id)initWithMachine:(running_machine &)m title:(NSString *)t;
|
||||||
|
|
||||||
- (void)activate;
|
- (void)activate;
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
#import "debugcommandhistory.h"
|
#import "debugcommandhistory.h"
|
||||||
#import "debugview.h"
|
#import "debugview.h"
|
||||||
|
|
||||||
#include "debug/debugcpu.h"
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// NOTIFICATIONS
|
// 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 {
|
- (id)initWithMachine:(running_machine &)m title:(NSString *)t {
|
||||||
if (!(self = [super init]))
|
if (!(self = [super init]))
|
||||||
return nil;
|
return nil;
|
||||||
@ -421,4 +427,4 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -21,10 +21,9 @@
|
|||||||
|
|
||||||
@interface MAMEDisassemblyView : MAMEDebugView <MAMEDebugViewSubviewSupport, MAMEDebugViewExpressionSupport>
|
@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;
|
- (NSSize)maximumFrameSize;
|
||||||
|
|
||||||
@ -38,10 +37,7 @@
|
|||||||
- (void)setExpression:(NSString *)exp;
|
- (void)setExpression:(NSString *)exp;
|
||||||
|
|
||||||
- (debug_view_disasm_source const *)source;
|
- (debug_view_disasm_source const *)source;
|
||||||
|
- (offs_t)selectedAddress;
|
||||||
- (IBAction)debugToggleBreakpoint:(id)sender;
|
|
||||||
- (IBAction)debugToggleBreakpointEnable:(id)sender;
|
|
||||||
- (IBAction)debugRunToCursor:(id)sender;
|
|
||||||
|
|
||||||
- (IBAction)showRightColumn:(id)sender;
|
- (IBAction)showRightColumn:(id)sender;
|
||||||
|
|
||||||
|
@ -11,21 +11,11 @@
|
|||||||
|
|
||||||
#import "disassemblyview.h"
|
#import "disassemblyview.h"
|
||||||
|
|
||||||
#include "debugger.h"
|
|
||||||
#include "debug/debugcon.h"
|
|
||||||
#include "debug/debugcpu.h"
|
|
||||||
#include "debug/debugvw.h"
|
#include "debug/debugvw.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation MAMEDisassemblyView
|
@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 {
|
- (void)createContextMenu {
|
||||||
NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"];
|
NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"];
|
||||||
NSMenuItem *item;
|
NSMenuItem *item;
|
||||||
@ -34,13 +24,11 @@
|
|||||||
action:@selector(debugToggleBreakpoint:)
|
action:@selector(debugToggleBreakpoint:)
|
||||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
||||||
[item setKeyEquivalentModifierMask:0];
|
[item setKeyEquivalentModifierMask:0];
|
||||||
[item setTarget:self];
|
|
||||||
|
|
||||||
item = [contextMenu addItemWithTitle:@"Disable Breakpoint"
|
item = [contextMenu addItemWithTitle:@"Disable Breakpoint"
|
||||||
action:@selector(debugToggleBreakpointEnable:)
|
action:@selector(debugToggleBreakpointEnable:)
|
||||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
||||||
[item setKeyEquivalentModifierMask:NSShiftKeyMask];
|
[item setKeyEquivalentModifierMask:NSShiftKeyMask];
|
||||||
[item setTarget:self];
|
|
||||||
|
|
||||||
[contextMenu addItem:[NSMenuItem separatorItem]];
|
[contextMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
@ -48,7 +36,6 @@
|
|||||||
action:@selector(debugRunToCursor:)
|
action:@selector(debugRunToCursor:)
|
||||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
|
||||||
[item setKeyEquivalentModifierMask:0];
|
[item setKeyEquivalentModifierMask:0];
|
||||||
[item setTarget:self];
|
|
||||||
|
|
||||||
[contextMenu addItem:[NSMenuItem separatorItem]];
|
[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]))
|
if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m]))
|
||||||
return nil;
|
return nil;
|
||||||
useConsole = uc;
|
|
||||||
[self createContextMenu];
|
[self createContextMenu];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -91,68 +77,8 @@
|
|||||||
|
|
||||||
- (BOOL)validateMenuItem:(NSMenuItem *)item {
|
- (BOOL)validateMenuItem:(NSMenuItem *)item {
|
||||||
SEL const action = [item action];
|
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 (action == @selector(showRightColumn:))
|
||||||
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:))
|
|
||||||
{
|
{
|
||||||
[item setState:((downcast<debug_view_disasm *>(view)->right_column() == [item tag]) ? NSOnState : NSOffState)];
|
[item setState:((downcast<debug_view_disasm *>(view)->right_column() == [item tag]) ? NSOnState : NSOffState)];
|
||||||
return YES;
|
return YES;
|
||||||
@ -166,17 +92,13 @@
|
|||||||
|
|
||||||
- (NSSize)maximumFrameSize {
|
- (NSSize)maximumFrameSize {
|
||||||
debug_view_xy max(0, 0);
|
debug_view_xy max(0, 0);
|
||||||
const debug_view_source *source = view->source();
|
debug_view_source const *source = view->source();
|
||||||
|
for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next())
|
||||||
for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next())
|
|
||||||
{
|
{
|
||||||
debug_view_xy current;
|
|
||||||
view->set_source(*source);
|
view->set_source(*source);
|
||||||
current = view->total_size();
|
debug_view_xy const current = view->total_size();
|
||||||
if (current.x > max.x)
|
max.x = MAX(max.x, current.x);
|
||||||
max.x = current.x;
|
max.y = MAX(max.y, current.y);
|
||||||
if (current.y > max.y)
|
|
||||||
max.y = current.y;
|
|
||||||
}
|
}
|
||||||
view->set_source(*source);
|
view->set_source(*source);
|
||||||
return NSMakeSize(max.x * fontWidth, max.y * fontHeight);
|
return NSMakeSize(max.x * fontWidth, max.y * fontHeight);
|
||||||
@ -267,101 +189,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (IBAction)debugToggleBreakpoint:(id)sender {
|
- (offs_t)selectedAddress {
|
||||||
if (view->cursor_visible())
|
return downcast<debug_view_disasm *>(view)->selected_address();
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,64 +200,55 @@
|
|||||||
|
|
||||||
|
|
||||||
- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index {
|
- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index {
|
||||||
{
|
NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor"
|
||||||
NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor"
|
action:@selector(debugToggleBreakpoint:)
|
||||||
action:@selector(debugToggleBreakpoint:)
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
|
||||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
|
atIndex:index++];
|
||||||
atIndex:index++];
|
[breakItem setKeyEquivalentModifierMask:0];
|
||||||
[breakItem setKeyEquivalentModifierMask:0];
|
|
||||||
[breakItem setTarget:self];
|
NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor"
|
||||||
}
|
action:@selector(debugToggleBreakpointEnable:)
|
||||||
{
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
|
||||||
NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor"
|
atIndex:index++];
|
||||||
action:@selector(debugToggleBreakpointEnable:)
|
[disableItem setKeyEquivalentModifierMask:NSShiftKeyMask];
|
||||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]
|
|
||||||
atIndex:index++];
|
NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu];
|
||||||
[disableItem setKeyEquivalentModifierMask:NSShiftKeyMask];
|
NSMenuItem *runItem;
|
||||||
[disableItem setAlternate:YES];
|
if (runMenu != nil) {
|
||||||
[disableItem setTarget:self];
|
runItem = [runMenu addItemWithTitle:@"to Cursor"
|
||||||
}
|
action:@selector(debugRunToCursor:)
|
||||||
{
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
|
||||||
NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu];
|
} else {
|
||||||
NSMenuItem *runItem;
|
runItem = [menu insertItemWithTitle:@"Run to Cursor"
|
||||||
if (runMenu != nil) {
|
action:@selector(debugRunToCursor:)
|
||||||
runItem = [runMenu addItemWithTitle:@"to Cursor"
|
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]
|
||||||
action:@selector(debugRunToCursor:)
|
atIndex:index++];
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
|
[runItem setKeyEquivalentModifierMask:0];
|
||||||
|
|
||||||
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
|
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
|
||||||
{
|
|
||||||
NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes"
|
NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes"
|
||||||
action:@selector(showRightColumn:)
|
action:@selector(showRightColumn:)
|
||||||
keyEquivalent:@"r"
|
keyEquivalent:@"r"
|
||||||
atIndex:index++];
|
atIndex:index++];
|
||||||
[rawItem setTarget:self];
|
[rawItem setTarget:self];
|
||||||
[rawItem setTag:DASM_RIGHTCOL_RAW];
|
[rawItem setTag:DASM_RIGHTCOL_RAW];
|
||||||
}
|
|
||||||
{
|
NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes"
|
||||||
NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes"
|
action:@selector(showRightColumn:)
|
||||||
action:@selector(showRightColumn:)
|
keyEquivalent:@"e"
|
||||||
keyEquivalent:@"e"
|
atIndex:index++];
|
||||||
atIndex:index++];
|
[encItem setTarget:self];
|
||||||
[encItem setTarget:self];
|
[encItem setTag:DASM_RIGHTCOL_ENCRYPTED];
|
||||||
[encItem setTag:DASM_RIGHTCOL_ENCRYPTED];
|
|
||||||
}
|
NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments"
|
||||||
{
|
action:@selector(showRightColumn:)
|
||||||
NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments"
|
keyEquivalent:@"n"
|
||||||
action:@selector(showRightColumn:)
|
atIndex:index++];
|
||||||
keyEquivalent:@"n"
|
[commentsItem setTarget:self];
|
||||||
atIndex:index++];
|
[commentsItem setTag:DASM_RIGHTCOL_COMMENTS];
|
||||||
[commentsItem setTarget:self];
|
|
||||||
[commentsItem setTag:DASM_RIGHTCOL_COMMENTS];
|
|
||||||
}
|
|
||||||
if (index < [menu numberOfItems])
|
if (index < [menu numberOfItems])
|
||||||
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
|
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
- (BOOL)selectSubviewForDevice:(device_t *)device;
|
- (BOOL)selectSubviewForDevice:(device_t *)device;
|
||||||
- (BOOL)selectSubviewForSpace:(address_space *)space;
|
- (BOOL)selectSubviewForSpace:(address_space *)space;
|
||||||
|
|
||||||
|
- (IBAction)debugToggleBreakpoint:(id)sender;
|
||||||
|
- (IBAction)debugToggleBreakpointEnable:(id)sender;
|
||||||
|
- (IBAction)debugRunToCursor:(id)sender;
|
||||||
|
|
||||||
- (IBAction)changeSubview:(id)sender;
|
- (IBAction)changeSubview:(id)sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#import "debugview.h"
|
#import "debugview.h"
|
||||||
#import "disassemblyview.h"
|
#import "disassemblyview.h"
|
||||||
|
|
||||||
|
#include "debugger.h"
|
||||||
|
#include "debug/debugcon.h"
|
||||||
#include "debug/debugcpu.h"
|
#include "debug/debugcpu.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,9 +71,7 @@
|
|||||||
[expressionContainer release];
|
[expressionContainer release];
|
||||||
|
|
||||||
// create the disassembly view
|
// create the disassembly view
|
||||||
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
|
dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine];
|
||||||
machine:*machine
|
|
||||||
useConsole:NO];
|
|
||||||
[dasmView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0];
|
[dasmView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0];
|
||||||
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,
|
dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,
|
||||||
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 {
|
- (IBAction)changeSubview:(id)sender {
|
||||||
[dasmView selectSubviewAtIndex:[[sender selectedItem] tag]];
|
[dasmView selectSubviewAtIndex:[[sender selectedItem] tag]];
|
||||||
[window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]];
|
[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
|
@end
|
||||||
|
@ -56,22 +56,14 @@
|
|||||||
|
|
||||||
|
|
||||||
- (NSSize)maximumFrameSize {
|
- (NSSize)maximumFrameSize {
|
||||||
debug_view_xy max;
|
debug_view_xy max(0, 0);
|
||||||
device_t *curcpu = debug_cpu_get_visible_cpu(*machine);
|
debug_view_source const *source = view->source();
|
||||||
debug_view_source const *source = view->source_for_device(curcpu);
|
for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next())
|
||||||
|
|
||||||
max.x = max.y = 0;
|
|
||||||
for (const debug_view_source *source = view->source_list().first();
|
|
||||||
source != NULL;
|
|
||||||
source = source->next())
|
|
||||||
{
|
{
|
||||||
debug_view_xy current;
|
|
||||||
view->set_source(*source);
|
view->set_source(*source);
|
||||||
current = view->total_size();
|
debug_view_xy const current = view->total_size();
|
||||||
if (current.x > max.x)
|
max.x = MAX(max.x, current.x);
|
||||||
max.x = current.x;
|
max.y = MAX(max.y, current.y);
|
||||||
if (current.y > max.y)
|
|
||||||
max.y = current.y;
|
|
||||||
}
|
}
|
||||||
view->set_source(*source);
|
view->set_source(*source);
|
||||||
return NSMakeSize(max.x * fontWidth, max.y * fontHeight);
|
return NSMakeSize(max.x * fontWidth, max.y * fontHeight);
|
||||||
|
Loading…
Reference in New Issue
Block a user