More functionality, including (break|watch)points view

This commit is contained in:
Vas Crabb 2015-02-14 22:51:10 +11:00
parent 6519c9fee9
commit 8918376d56
15 changed files with 379 additions and 45 deletions

View File

@ -0,0 +1,26 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// debugosxbreakpointsview.h - MacOS X Cocoa debug window handling
//
// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
//============================================================
#import "debugosx.h"
#import "debugosxdebugview.h"
#include "emu.h"
#import <Cocoa/Cocoa.h>
@interface MAMEBreakpointsView : MAMEDebugView
{
}
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m;
@end

View File

@ -0,0 +1,30 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// debugosxbreakpointsview.m - MacOS X Cocoa debug window handling
//
// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
//============================================================
#import "debugosxbreakpointsview.h"
#include "debug/debugvw.h"
@implementation MAMEBreakpointsView
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
if (!(self = [super initWithFrame:f type:DVT_BREAK_POINTS machine:m]))
return nil;
return self;
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -39,6 +39,7 @@
- (IBAction)debugNewMemoryWindow:(id)sender;
- (IBAction)debugNewDisassemblyWindow:(id)sender;
- (IBAction)debugNewErrorLogWindow:(id)sender;
- (IBAction)debugNewPointsWindow:(id)sender;
- (void)showDebugger:(NSNotification *)notification;
- (void)auxiliaryWindowWillClose:(NSNotification *)notification;

View File

@ -18,6 +18,7 @@
#import "debugosxdisassemblyviewer.h"
#import "debugosxerrorlogviewer.h"
#import "debugosxmemoryviewer.h"
#import "debugosxpointsviewer.h"
#import "debugosxregistersview.h"
#include "debug/debugcon.h"
@ -252,6 +253,14 @@
}
- (IBAction)debugNewPointsWindow:(id)sender{
MAMEPointsViewer *win = [[MAMEPointsViewer alloc] initWithMachine:*machine console:self];
[auxiliaryWindows addObject:win];
[win release];
[win activate];
}
- (void)showDebugger:(NSNotification *)notification {
device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue];
if (&device->machine() == machine) {

View File

@ -187,12 +187,17 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
}
totalWidth = totalHeight = 0;
originLeft = originTop = 0;
[self setFont:[[self class] defaultFont]];
text = [[NSTextStorage alloc] init];
textContainer = [[NSTextContainer alloc] init];
layoutManager = [[NSLayoutManager alloc] init];
[layoutManager addTextContainer:textContainer];
[textContainer release];
[text addLayoutManager:layoutManager];
[layoutManager release];
[self setFont:[[self class] defaultFont]];
return self;
}
@ -201,8 +206,6 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
[[NSNotificationCenter defaultCenter] removeObserver:self];
if (font != nil) [font release];
if (text != nil) [text release];
if (textContainer != nil) [textContainer release];
if (layoutManager != nil) [layoutManager release];
[super dealloc];
}

View File

@ -71,6 +71,7 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification;
- (IBAction)debugNewMemoryWindow:(id)sender;
- (IBAction)debugNewDisassemblyWindow:(id)sender;
- (IBAction)debugNewErrorLogWindow:(id)sender;
- (IBAction)debugNewPointsWindow:(id)sender;
- (void)windowWillClose:(NSNotification *)notification;

View File

@ -105,6 +105,9 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
[newMenu addItemWithTitle:@"Error Log Window"
action:@selector(debugNewErrorLogWindow:)
keyEquivalent:@"l"];
[newMenu addItemWithTitle:@"(Break|Watch)points Window"
action:@selector(debugNewPointsWindow:)
keyEquivalent:@"b"];
}
[menu addItem:[NSMenuItem separatorItem]];
[menu addItemWithTitle:@"Close Window" action:@selector(performClose:) keyEquivalent:@"w"];
@ -287,6 +290,11 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
}
- (IBAction)debugNewPointsWindow:(id)sender {
[console debugNewPointsWindow:sender];
}
- (void)windowWillClose:(NSNotification *)notification {
[[NSNotificationCenter defaultCenter] postNotificationName:MAMEAuxiliaryDebugWindowWillCloseNotification
object:self];

View File

@ -37,6 +37,7 @@
- (IBAction)showPhysicalAddresses:(id)sender;
- (IBAction)showReverseView:(id)sender;
- (IBAction)showReverseViewToggle:(id)sender;
- (IBAction)changeBytesPerLine:(id)sender;
- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index;
- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index;

View File

@ -148,44 +148,64 @@
}
- (IBAction)changeBytesPerLine:(id)sender {
debug_view_memory *const memView = downcast<debug_view_memory *>(view);
memView->set_chunks_per_row(memView->chunks_per_row() + [sender tag]);
}
- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index {
{
NSInteger tag;
for (tag = 1; tag <= 8; tag <<= 1) {
NSString *title = [NSString stringWithFormat:@"%ld-byte Chunks", (long)tag];
NSMenuItem *chunkItem = [menu insertItemWithTitle:title
action:@selector(showChunkSize:)
keyEquivalent:[NSString stringWithFormat:@"%ld", (long)tag]
atIndex:index++];
[chunkItem setTarget:self];
[chunkItem setTag:tag];
}
NSInteger tag;
for (tag = 1; tag <= 8; tag <<= 1) {
NSString *title = [NSString stringWithFormat:@"%ld-byte Chunks", (long)tag];
NSMenuItem *chunkItem = [menu insertItemWithTitle:title
action:@selector(showChunkSize:)
keyEquivalent:[NSString stringWithFormat:@"%ld", (long)tag]
atIndex:index++];
[chunkItem setTarget:self];
[chunkItem setTag:tag];
}
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
{
NSMenuItem *logicalItem = [menu insertItemWithTitle:@"Logical Addresses"
action:@selector(showPhysicalAddresses:)
keyEquivalent:@"v"
atIndex:index++];
[logicalItem setTarget:self];
[logicalItem setTag:FALSE];
}
{
NSMenuItem *physicalItem = [menu insertItemWithTitle:@"Physical Addresses"
action:@selector(showPhysicalAddresses:)
keyEquivalent:@"y"
atIndex:index++];
[physicalItem setTarget:self];
[physicalItem setTag:TRUE];
}
NSMenuItem *logicalItem = [menu insertItemWithTitle:@"Logical Addresses"
action:@selector(showPhysicalAddresses:)
keyEquivalent:@"v"
atIndex:index++];
[logicalItem setTarget:self];
[logicalItem setTag:FALSE];
NSMenuItem *physicalItem = [menu insertItemWithTitle:@"Physical Addresses"
action:@selector(showPhysicalAddresses:)
keyEquivalent:@"y"
atIndex:index++];
[physicalItem setTarget:self];
[physicalItem setTag:TRUE];
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
{
NSMenuItem *reverseItem = [menu insertItemWithTitle:@"Reverse View"
action:@selector(showReverseViewToggle:)
keyEquivalent:@"r"
atIndex:index++];
[reverseItem setTarget:self];
}
NSMenuItem *reverseItem = [menu insertItemWithTitle:@"Reverse View"
action:@selector(showReverseViewToggle:)
keyEquivalent:@"r"
atIndex:index++];
[reverseItem setTarget:self];
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
NSMenuItem *increaseItem = [menu insertItemWithTitle:@"Increase Bytes Per Line"
action:@selector(changeBytesPerLine:)
keyEquivalent:@"p"
atIndex:index++];
[increaseItem setTarget:self];
[increaseItem setTag:1];
NSMenuItem *decreaseItem = [menu insertItemWithTitle:@"Decrease Bytes Per Line"
action:@selector(changeBytesPerLine:)
keyEquivalent:@"o"
atIndex:index++];
[decreaseItem setTarget:self];
[decreaseItem setTag:-1];
if (index < [menu numberOfItems])
[menu insertItem:[NSMenuItem separatorItem] atIndex:index++];
}

View File

@ -106,13 +106,11 @@
[window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]];
// calculate the optimal size for everything
{
NSSize desired = [NSScrollView frameSizeForContentSize:[memoryView maximumFrameSize]
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[memoryScroll borderType]];
[self cascadeWindowWithDesiredSize:desired forView:memoryScroll];
}
NSSize const desired = [NSScrollView frameSizeForContentSize:[memoryView maximumFrameSize]
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[memoryScroll borderType]];
[self cascadeWindowWithDesiredSize:desired forView:memoryScroll];
// don't forget the result
return self;

View File

@ -0,0 +1,31 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// debugosxpointsviewer.h - MacOS X Cocoa debug window handling
//
// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
//============================================================
#import "debugosx.h"
#import "debugosxdebugwindowhandler.h"
#include "emu.h"
#import <Cocoa/Cocoa.h>
@class MAMEDebugConsole;
@interface MAMEPointsViewer : MAMEAuxiliaryDebugWindowHandler
{
NSTabView *tabs;
}
- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c;
- (IBAction)changeSubview:(id)sender;
@end

View File

@ -0,0 +1,147 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// debugosxpointsviewer.m - MacOS X Cocoa debug window handling
//
// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
//============================================================
#import "debugosxpointsviewer.h"
#import "debugosxbreakpointsview.h"
#import "debugosxwatchpointsview.h"
@implementation MAMEPointsViewer
- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c {
MAMEDebugView *breakView, *watchView;
NSScrollView *breakScroll, *watchScroll;
NSTabViewItem *breakTab, *watchTab;
NSPopUpButton *actionButton, *subviewButton;
NSRect contentBounds;
if (!(self = [super initWithMachine:m title:@"(Break|Watch)points" console:c]))
return nil;
contentBounds = [[window contentView] bounds];
// create the subview popup
subviewButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(19,
contentBounds.size.height - 19,
contentBounds.size.width - 19,
19)];
[subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
[subviewButton setBezelStyle:NSShadowlessSquareBezelStyle];
[subviewButton setFocusRingType:NSFocusRingTypeNone];
[subviewButton setFont:[[MAMEDebugView class] defaultFont]];
[subviewButton setTarget:self];
[subviewButton setAction:@selector(changeSubview:)];
[[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom];
[[[subviewButton menu] addItemWithTitle:@"All Breakpoints"
action:NULL
keyEquivalent:@""] setTag:0];
[[[subviewButton menu] addItemWithTitle:@"All Watchpoints"
action:NULL
keyEquivalent:@""] setTag:1];
[[window contentView] addSubview:subviewButton];
[subviewButton release];
// create the action popup
actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0,
contentBounds.size.height - 19,
19,
19)];
[actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
[[window contentView] addSubview:actionButton];
[actionButton release];
// create the breakpoints view
breakView = [[MAMEBreakpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
machine:*machine];
breakScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,
0,
contentBounds.size.width,
contentBounds.size.height - 19)];
[breakScroll setDrawsBackground:YES];
[breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[breakScroll setHasHorizontalScroller:YES];
[breakScroll setHasVerticalScroller:YES];
[breakScroll setAutohidesScrollers:YES];
[breakScroll setBorderType:NSNoBorder];
[breakScroll setDocumentView:breakView];
[breakView release];
breakTab = [[NSTabViewItem alloc] initWithIdentifier:nil];
[breakTab setView:breakScroll];
[breakScroll release];
// create the breakpoints view
watchView = [[MAMEWatchpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
machine:*machine];
watchScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,
0,
contentBounds.size.width,
contentBounds.size.height - 19)];
[watchScroll setDrawsBackground:YES];
[watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[watchScroll setHasHorizontalScroller:YES];
[watchScroll setHasVerticalScroller:YES];
[watchScroll setAutohidesScrollers:YES];
[watchScroll setBorderType:NSNoBorder];
[watchScroll setDocumentView:watchView];
[watchView release];
watchTab = [[NSTabViewItem alloc] initWithIdentifier:nil];
[watchTab setView:watchScroll];
[watchScroll release];
// create a tabless tabview for the two subviews
tabs = [[NSTabView alloc] initWithFrame:NSMakeRect(0,
0,
contentBounds.size.width,
contentBounds.size.height - 19)];
[tabs setTabViewType:NSNoTabsNoBorder];
[tabs setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[tabs addTabViewItem:breakTab];
[breakTab release];
[tabs addTabViewItem:watchTab];
[watchTab release];
[[window contentView] addSubview:tabs];
[tabs release];
// set default state
[subviewButton selectItemAtIndex:0];
[tabs selectFirstTabViewItem:self];
[window makeFirstResponder:subviewButton];
[window setTitle:[[subviewButton selectedItem] title]];
// calculate the optimal size for everything
NSSize const breakDesired = [NSScrollView frameSizeForContentSize:[breakView maximumFrameSize]
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[breakScroll borderType]];
NSSize const watchDesired = [NSScrollView frameSizeForContentSize:[watchView maximumFrameSize]
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[watchScroll borderType]];
NSSize const desired = NSMakeSize(MAX(breakDesired.width, watchDesired.width),
MAX(breakDesired.height, watchDesired.height));
[self cascadeWindowWithDesiredSize:desired forView:tabs];
// don't forget the result
return self;
}
- (void)dealloc {
[super dealloc];
}
- (IBAction)changeSubview:(id)sender {
[tabs selectTabViewItemAtIndex:[[sender selectedItem] tag]];
[window setTitle:[[sender selectedItem] title]];
}
@end

View File

@ -0,0 +1,26 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// debugosxwatchpointsview.h - MacOS X Cocoa debug window handling
//
// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
//============================================================
#import "debugosx.h"
#import "debugosxdebugview.h"
#include "emu.h"
#import <Cocoa/Cocoa.h>
@interface MAMEWatchpointsView : MAMEDebugView
{
}
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m;
@end

View File

@ -0,0 +1,30 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// debugosxwatchpointsview.m - MacOS X Cocoa debug window handling
//
// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
//============================================================
#import "debugosxwatchpointsview.h"
#include "debug/debugvw.h"
@implementation MAMEWatchpointsView
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
if (!(self = [super initWithFrame:f type:DVT_WATCH_POINTS machine:m]))
return nil;
return self;
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -289,6 +289,7 @@ OBJDIRS += $(OSDOBJ)/modules/debugger/osx
DEBUGOBJS = \
$(OSDOBJ)/modules/debugger/debugosx.o \
$(OSDOBJ)/modules/debugger/osx/debugosxbreakpointsview.o \
$(OSDOBJ)/modules/debugger/osx/debugosxconsoleview.o \
$(OSDOBJ)/modules/debugger/osx/debugosxdebugcommandhistory.o \
$(OSDOBJ)/modules/debugger/osx/debugosxdebugconsole.o \
@ -300,7 +301,9 @@ DEBUGOBJS = \
$(OSDOBJ)/modules/debugger/osx/debugosxerrorlogviewer.o \
$(OSDOBJ)/modules/debugger/osx/debugosxmemoryview.o \
$(OSDOBJ)/modules/debugger/osx/debugosxmemoryviewer.o \
$(OSDOBJ)/modules/debugger/osx/debugosxregistersview.o
$(OSDOBJ)/modules/debugger/osx/debugosxpointsviewer.o \
$(OSDOBJ)/modules/debugger/osx/debugosxregistersview.o \
$(OSDOBJ)/modules/debugger/osx/debugosxwatchpointsview.o
endif