trunk/src/osd/modules/debugger/osx/debugconsole.m
| r243615 | r243616 | |
| 53 | 53 | [regView release]; |
| 54 | 54 | |
| 55 | 55 | // create the disassembly view |
| 56 | | dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) |
| 57 | | machine:*machine |
| 58 | | useConsole:YES]; |
| 56 | dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; |
| 59 | 57 | [dasmView setExpression:@"curpc"]; |
| 60 | 58 | dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; |
| 61 | 59 | [dasmScroll setDrawsBackground:YES]; |
| r243615 | r243616 | |
| 215 | 213 | |
| 216 | 214 | - (IBAction)doCommand:(id)sender { |
| 217 | 215 | NSString *command = [sender stringValue]; |
| 218 | | if ([command length] == 0) { |
| 216 | if ([command length] == 0) |
| 217 | { |
| 219 | 218 | debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); |
| 220 | 219 | [history reset]; |
| 221 | | } else { |
| 220 | } |
| 221 | else |
| 222 | { |
| 222 | 223 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 223 | 224 | [history add:command]; |
| 224 | 225 | [history edit]; |
| r243615 | r243616 | |
| 227 | 228 | } |
| 228 | 229 | |
| 229 | 230 | |
| 231 | - (IBAction)debugToggleBreakpoint:(id)sender { |
| 232 | device_t &device = [dasmView source]->device(); |
| 233 | if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 234 | { |
| 235 | offs_t const address = [dasmView selectedAddress]; |
| 236 | device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address |
| 237 | forDevice:device]; |
| 238 | |
| 239 | // if it doesn't exist, add a new one |
| 240 | NSString *command; |
| 241 | if (bp == NULL) |
| 242 | command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address]; |
| 243 | else |
| 244 | command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()]; |
| 245 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | |
| 250 | - (IBAction)debugToggleBreakpointEnable:(id)sender { |
| 251 | device_t &device = [dasmView source]->device(); |
| 252 | if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 253 | { |
| 254 | device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] |
| 255 | forDevice:device]; |
| 256 | if (bp != NULL) |
| 257 | { |
| 258 | NSString *command; |
| 259 | if (bp->enabled()) |
| 260 | command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()]; |
| 261 | else |
| 262 | command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()]; |
| 263 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | |
| 269 | - (IBAction)debugRunToCursor:(id)sender { |
| 270 | device_t &device = [dasmView source]->device(); |
| 271 | if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 272 | { |
| 273 | NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)[dasmView selectedAddress]]; |
| 274 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | |
| 230 | 279 | - (IBAction)debugNewMemoryWindow:(id)sender { |
| 231 | 280 | MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self]; |
| 232 | 281 | [auxiliaryWindows addObject:win]; |
| r243615 | r243616 | |
| 419 | 468 | [[[sender subviews] objectAtIndex:1] setFrame:second]; |
| 420 | 469 | } |
| 421 | 470 | |
| 471 | |
| 472 | - (BOOL)validateMenuItem:(NSMenuItem *)item { |
| 473 | SEL const action = [item action]; |
| 474 | BOOL const inContextMenu = ([item menu] == [dasmView menu]); |
| 475 | BOOL const haveCursor = [dasmView cursorVisible]; |
| 476 | BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == &[dasmView source]->device()); |
| 477 | |
| 478 | device_debug::breakpoint *breakpoint = NULL; |
| 479 | if (haveCursor) |
| 480 | { |
| 481 | breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] |
| 482 | forDevice:[dasmView source]->device()]; |
| 483 | } |
| 484 | |
| 485 | if (action == @selector(debugToggleBreakpoint:)) |
| 486 | { |
| 487 | if (haveCursor) |
| 488 | { |
| 489 | if (breakpoint != NULL) |
| 490 | { |
| 491 | if (inContextMenu) |
| 492 | [item setTitle:@"Clear Breakpoint"]; |
| 493 | else |
| 494 | [item setTitle:@"Clear Breakpoint at Cursor"]; |
| 495 | } |
| 496 | else |
| 497 | { |
| 498 | if (inContextMenu) |
| 499 | [item setTitle:@"Set Breakpoint"]; |
| 500 | else |
| 501 | [item setTitle:@"Set Breakpoint at Cursor"]; |
| 502 | } |
| 503 | } |
| 504 | else |
| 505 | { |
| 506 | if (inContextMenu) |
| 507 | [item setTitle:@"Toggle Breakpoint"]; |
| 508 | else |
| 509 | [item setTitle:@"Toggle Breakpoint at Cursor"]; |
| 510 | } |
| 511 | return haveCursor && isCurrent; |
| 512 | } |
| 513 | else if (action == @selector(debugToggleBreakpointEnable:)) |
| 514 | { |
| 515 | if ((breakpoint != NULL) && !breakpoint->enabled()) |
| 516 | { |
| 517 | if (inContextMenu) |
| 518 | [item setTitle:@"Enable Breakpoint"]; |
| 519 | else |
| 520 | [item setTitle:@"Enable Breakpoint at Cursor"]; |
| 521 | } |
| 522 | else |
| 523 | { |
| 524 | if (inContextMenu) |
| 525 | [item setTitle:@"Disable Breakpoint"]; |
| 526 | else |
| 527 | [item setTitle:@"Disable Breakpoint at Cursor"]; |
| 528 | } |
| 529 | return (breakpoint != NULL) && isCurrent; |
| 530 | } |
| 531 | else if (action == @selector(debugRunToCursor:)) |
| 532 | { |
| 533 | return isCurrent; |
| 534 | } |
| 535 | else |
| 536 | { |
| 537 | return YES; |
| 538 | } |
| 539 | } |
| 540 | |
| 422 | 541 | @end |
trunk/src/osd/modules/debugger/osx/disassemblyview.m
| r243615 | r243616 | |
| 11 | 11 | |
| 12 | 12 | #import "disassemblyview.h" |
| 13 | 13 | |
| 14 | | #include "debugger.h" |
| 15 | | #include "debug/debugcon.h" |
| 16 | | #include "debug/debugcpu.h" |
| 17 | 14 | #include "debug/debugvw.h" |
| 18 | 15 | |
| 19 | 16 | |
| 20 | 17 | @implementation MAMEDisassemblyView |
| 21 | 18 | |
| 22 | | - (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device { |
| 23 | | device_debug *cpuinfo = device.debug(); |
| 24 | | device_debug::breakpoint *bp; |
| 25 | | for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) { } |
| 26 | | return bp; |
| 27 | | } |
| 28 | | |
| 29 | 19 | - (void)createContextMenu { |
| 30 | 20 | NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"]; |
| 31 | 21 | NSMenuItem *item; |
| r243615 | r243616 | |
| 34 | 24 | action:@selector(debugToggleBreakpoint:) |
| 35 | 25 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; |
| 36 | 26 | [item setKeyEquivalentModifierMask:0]; |
| 37 | | [item setTarget:self]; |
| 38 | 27 | |
| 39 | 28 | item = [contextMenu addItemWithTitle:@"Disable Breakpoint" |
| 40 | 29 | action:@selector(debugToggleBreakpointEnable:) |
| 41 | 30 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; |
| 42 | 31 | [item setKeyEquivalentModifierMask:NSShiftKeyMask]; |
| 43 | | [item setTarget:self]; |
| 44 | 32 | |
| 45 | 33 | [contextMenu addItem:[NSMenuItem separatorItem]]; |
| 46 | 34 | |
| r243615 | r243616 | |
| 48 | 36 | action:@selector(debugRunToCursor:) |
| 49 | 37 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; |
| 50 | 38 | [item setKeyEquivalentModifierMask:0]; |
| 51 | | [item setTarget:self]; |
| 52 | 39 | |
| 53 | 40 | [contextMenu addItem:[NSMenuItem separatorItem]]; |
| 54 | 41 | |
| r243615 | r243616 | |
| 75 | 62 | } |
| 76 | 63 | |
| 77 | 64 | |
| 78 | | - (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc { |
| 65 | - (id)initWithFrame:(NSRect)f machine:(running_machine &)m { |
| 79 | 66 | if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m])) |
| 80 | 67 | return nil; |
| 81 | | useConsole = uc; |
| 82 | 68 | [self createContextMenu]; |
| 83 | 69 | return self; |
| 84 | 70 | } |
| r243615 | r243616 | |
| 91 | 77 | |
| 92 | 78 | - (BOOL)validateMenuItem:(NSMenuItem *)item { |
| 93 | 79 | SEL const action = [item action]; |
| 94 | | BOOL const inContextMenu = ([item menu] == [self menu]); |
| 95 | | BOOL haveCursor = view->cursor_visible(); |
| 96 | | BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == view->source()->device()); |
| 97 | 80 | |
| 98 | | device_debug::breakpoint *breakpoint = NULL; |
| 99 | | if (haveCursor) |
| 81 | if (action == @selector(showRightColumn:)) |
| 100 | 82 | { |
| 101 | | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 102 | | breakpoint = [self findBreakpointAtAddress:address forDevice:[self source]->device()]; |
| 103 | | } |
| 104 | | |
| 105 | | if (action == @selector(debugToggleBreakpoint:)) |
| 106 | | { |
| 107 | | if (haveCursor) |
| 108 | | { |
| 109 | | if (breakpoint != NULL) |
| 110 | | { |
| 111 | | if (inContextMenu) |
| 112 | | [item setTitle:@"Clear Breakpoint"]; |
| 113 | | else |
| 114 | | [item setTitle:@"Clear Breakpoint at Cursor"]; |
| 115 | | } |
| 116 | | else |
| 117 | | { |
| 118 | | if (inContextMenu) |
| 119 | | [item setTitle:@"Set Breakpoint"]; |
| 120 | | else |
| 121 | | [item setTitle:@"Set Breakpoint at Cursor"]; |
| 122 | | } |
| 123 | | } |
| 124 | | else |
| 125 | | { |
| 126 | | if (inContextMenu) |
| 127 | | [item setTitle:@"Toggle Breakpoint"]; |
| 128 | | else |
| 129 | | [item setTitle:@"Toggle Breakpoint at Cursor"]; |
| 130 | | } |
| 131 | | return haveCursor && (!useConsole || isCurrent); |
| 132 | | } |
| 133 | | else if (action == @selector(debugToggleBreakpointEnable:)) |
| 134 | | { |
| 135 | | if ((breakpoint != NULL) && !breakpoint->enabled()) |
| 136 | | { |
| 137 | | if (inContextMenu) |
| 138 | | [item setTitle:@"Enable Breakpoint"]; |
| 139 | | else |
| 140 | | [item setTitle:@"Enable Breakpoint at Cursor"]; |
| 141 | | } |
| 142 | | else |
| 143 | | { |
| 144 | | if (inContextMenu) |
| 145 | | [item setTitle:@"Disable Breakpoint"]; |
| 146 | | else |
| 147 | | [item setTitle:@"Disable Breakpoint at Cursor"]; |
| 148 | | } |
| 149 | | return (breakpoint != NULL) && (!useConsole || isCurrent); |
| 150 | | } |
| 151 | | else if (action == @selector(debugRunToCursor:)) |
| 152 | | { |
| 153 | | return !useConsole || isCurrent; |
| 154 | | } |
| 155 | | else if (action == @selector(showRightColumn:)) |
| 156 | | { |
| 157 | 83 | [item setState:((downcast<debug_view_disasm *>(view)->right_column() == [item tag]) ? NSOnState : NSOffState)]; |
| 158 | 84 | return YES; |
| 159 | 85 | } |
| r243615 | r243616 | |
| 166 | 92 | |
| 167 | 93 | - (NSSize)maximumFrameSize { |
| 168 | 94 | debug_view_xy max(0, 0); |
| 169 | | const debug_view_source *source = view->source(); |
| 170 | | |
| 171 | | for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) |
| 95 | debug_view_source const *source = view->source(); |
| 96 | for (debug_view_source const *source = view->first_source(); source != NULL; source = source->next()) |
| 172 | 97 | { |
| 173 | | debug_view_xy current; |
| 174 | 98 | view->set_source(*source); |
| 175 | | current = view->total_size(); |
| 176 | | if (current.x > max.x) |
| 177 | | max.x = current.x; |
| 178 | | if (current.y > max.y) |
| 179 | | max.y = current.y; |
| 99 | debug_view_xy const current = view->total_size(); |
| 100 | max.x = MAX(max.x, current.x); |
| 101 | max.y = MAX(max.y, current.y); |
| 180 | 102 | } |
| 181 | 103 | view->set_source(*source); |
| 182 | 104 | return NSMakeSize(max.x * fontWidth, max.y * fontHeight); |
| r243615 | r243616 | |
| 267 | 189 | } |
| 268 | 190 | |
| 269 | 191 | |
| 270 | | - (IBAction)debugToggleBreakpoint:(id)sender { |
| 271 | | if (view->cursor_visible()) |
| 272 | | { |
| 273 | | device_t &device = [self source]->device(); |
| 274 | | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 275 | | { |
| 276 | | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 277 | | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device]; |
| 192 | - (offs_t)selectedAddress { |
| 193 | return downcast<debug_view_disasm *>(view)->selected_address(); |
| 194 | } |
| 278 | 195 | |
| 279 | | // if it doesn't exist, add a new one |
| 280 | | if (useConsole) |
| 281 | | { |
| 282 | | NSString *command; |
| 283 | | if (bp == NULL) |
| 284 | | command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address]; |
| 285 | | else |
| 286 | | command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()]; |
| 287 | | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 288 | | } |
| 289 | | else |
| 290 | | { |
| 291 | | if (bp == NULL) |
| 292 | | { |
| 293 | | UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL); |
| 294 | | debug_console_printf(*machine, "Breakpoint %X set\n", bpnum); |
| 295 | | } |
| 296 | | else |
| 297 | | { |
| 298 | | int const bpnum = bp->index(); |
| 299 | | device.debug()->breakpoint_clear(bpnum); |
| 300 | | debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum); |
| 301 | | } |
| 302 | | } |
| 303 | 196 | |
| 304 | | // fail to do this and the display doesn't update |
| 305 | | machine->debug_view().update_all(); |
| 306 | | debugger_refresh_display(*machine); |
| 307 | | } |
| 308 | | } |
| 197 | - (IBAction)showRightColumn:(id)sender { |
| 198 | downcast<debug_view_disasm *>(view)->set_right_column((disasm_right_column) [sender tag]); |
| 309 | 199 | } |
| 310 | 200 | |
| 311 | 201 | |
| 312 | | - (IBAction)debugToggleBreakpointEnable:(id)sender { |
| 313 | | if (view->cursor_visible()) |
| 314 | | { |
| 315 | | device_t &device = [self source]->device(); |
| 316 | | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 317 | | { |
| 318 | | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 319 | | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device]; |
| 320 | | if (bp != NULL) |
| 321 | | { |
| 322 | | if (useConsole) |
| 323 | | { |
| 324 | | NSString *command; |
| 325 | | if (bp->enabled()) |
| 326 | | command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()]; |
| 327 | | else |
| 328 | | command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()]; |
| 329 | | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 330 | | } |
| 331 | | else |
| 332 | | { |
| 333 | | device.debug()->breakpoint_enable(bp->index(), !bp->enabled()); |
| 334 | | debug_console_printf(*machine, |
| 335 | | "Breakpoint %X %s\n", |
| 336 | | (UINT32)bp->index(), |
| 337 | | bp->enabled() ? "enabled" : "disabled"); |
| 338 | | } |
| 339 | | machine->debug_view().update_all(); |
| 340 | | debugger_refresh_display(*machine); |
| 341 | | } |
| 342 | | } |
| 343 | | } |
| 344 | | } |
| 202 | - (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { |
| 203 | NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor" |
| 204 | action:@selector(debugToggleBreakpoint:) |
| 205 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] |
| 206 | atIndex:index++]; |
| 207 | [breakItem setKeyEquivalentModifierMask:0]; |
| 345 | 208 | |
| 209 | NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor" |
| 210 | action:@selector(debugToggleBreakpointEnable:) |
| 211 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] |
| 212 | atIndex:index++]; |
| 213 | [disableItem setKeyEquivalentModifierMask:NSShiftKeyMask]; |
| 346 | 214 | |
| 347 | | - (IBAction)debugRunToCursor:(id)sender { |
| 348 | | if (view->cursor_visible()) |
| 349 | | { |
| 350 | | device_t &device = [self source]->device(); |
| 351 | | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 352 | | { |
| 353 | | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 354 | | if (useConsole) |
| 355 | | { |
| 356 | | NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)address]; |
| 357 | | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 358 | | } |
| 359 | | else |
| 360 | | { |
| 361 | | device.debug()->go(address); |
| 362 | | } |
| 363 | | } |
| 215 | NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu]; |
| 216 | NSMenuItem *runItem; |
| 217 | if (runMenu != nil) { |
| 218 | runItem = [runMenu addItemWithTitle:@"to Cursor" |
| 219 | action:@selector(debugRunToCursor:) |
| 220 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; |
| 221 | } else { |
| 222 | runItem = [menu insertItemWithTitle:@"Run to Cursor" |
| 223 | action:@selector(debugRunToCursor:) |
| 224 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey] |
| 225 | atIndex:index++]; |
| 364 | 226 | } |
| 365 | | } |
| 227 | [runItem setKeyEquivalentModifierMask:0]; |
| 366 | 228 | |
| 229 | [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; |
| 367 | 230 | |
| 368 | | - (IBAction)showRightColumn:(id)sender { |
| 369 | | downcast<debug_view_disasm *>(view)->set_right_column((disasm_right_column) [sender tag]); |
| 370 | | } |
| 231 | NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes" |
| 232 | action:@selector(showRightColumn:) |
| 233 | keyEquivalent:@"r" |
| 234 | atIndex:index++]; |
| 235 | [rawItem setTarget:self]; |
| 236 | [rawItem setTag:DASM_RIGHTCOL_RAW]; |
| 371 | 237 | |
| 238 | NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes" |
| 239 | action:@selector(showRightColumn:) |
| 240 | keyEquivalent:@"e" |
| 241 | atIndex:index++]; |
| 242 | [encItem setTarget:self]; |
| 243 | [encItem setTag:DASM_RIGHTCOL_ENCRYPTED]; |
| 372 | 244 | |
| 373 | | - (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { |
| 374 | | { |
| 375 | | NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor" |
| 376 | | action:@selector(debugToggleBreakpoint:) |
| 377 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] |
| 378 | | atIndex:index++]; |
| 379 | | [breakItem setKeyEquivalentModifierMask:0]; |
| 380 | | [breakItem setTarget:self]; |
| 381 | | } |
| 382 | | { |
| 383 | | NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor" |
| 384 | | action:@selector(debugToggleBreakpointEnable:) |
| 385 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] |
| 386 | | atIndex:index++]; |
| 387 | | [disableItem setKeyEquivalentModifierMask:NSShiftKeyMask]; |
| 388 | | [disableItem setAlternate:YES]; |
| 389 | | [disableItem setTarget:self]; |
| 390 | | } |
| 391 | | { |
| 392 | | NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu]; |
| 393 | | NSMenuItem *runItem; |
| 394 | | if (runMenu != nil) { |
| 395 | | runItem = [runMenu addItemWithTitle:@"to Cursor" |
| 396 | | action:@selector(debugRunToCursor:) |
| 397 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; |
| 398 | | } else { |
| 399 | | runItem = [menu insertItemWithTitle:@"Run to Cursor" |
| 400 | | action:@selector(debugRunToCursor:) |
| 401 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey] |
| 402 | | atIndex:index++]; |
| 403 | | } |
| 404 | | [runItem setKeyEquivalentModifierMask:0]; |
| 405 | | [runItem setTarget:self]; |
| 406 | | } |
| 407 | | [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; |
| 408 | | { |
| 409 | | NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes" |
| 410 | | action:@selector(showRightColumn:) |
| 411 | | keyEquivalent:@"r" |
| 412 | | atIndex:index++]; |
| 413 | | [rawItem setTarget:self]; |
| 414 | | [rawItem setTag:DASM_RIGHTCOL_RAW]; |
| 415 | | } |
| 416 | | { |
| 417 | | NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes" |
| 418 | | action:@selector(showRightColumn:) |
| 419 | | keyEquivalent:@"e" |
| 420 | | atIndex:index++]; |
| 421 | | [encItem setTarget:self]; |
| 422 | | [encItem setTag:DASM_RIGHTCOL_ENCRYPTED]; |
| 423 | | } |
| 424 | | { |
| 425 | | NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments" |
| 426 | | action:@selector(showRightColumn:) |
| 427 | | keyEquivalent:@"n" |
| 428 | | atIndex:index++]; |
| 429 | | [commentsItem setTarget:self]; |
| 430 | | [commentsItem setTag:DASM_RIGHTCOL_COMMENTS]; |
| 431 | | } |
| 245 | NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments" |
| 246 | action:@selector(showRightColumn:) |
| 247 | keyEquivalent:@"n" |
| 248 | atIndex:index++]; |
| 249 | [commentsItem setTarget:self]; |
| 250 | [commentsItem setTag:DASM_RIGHTCOL_COMMENTS]; |
| 251 | |
| 432 | 252 | if (index < [menu numberOfItems]) |
| 433 | 253 | [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; |
| 434 | 254 | } |
trunk/src/osd/modules/debugger/osx/disassemblyviewer.m
| r243615 | r243616 | |
| 15 | 15 | #import "debugview.h" |
| 16 | 16 | #import "disassemblyview.h" |
| 17 | 17 | |
| 18 | #include "debugger.h" |
| 19 | #include "debug/debugcon.h" |
| 18 | 20 | #include "debug/debugcpu.h" |
| 19 | 21 | |
| 20 | 22 | |
| r243615 | r243616 | |
| 69 | 71 | [expressionContainer release]; |
| 70 | 72 | |
| 71 | 73 | // create the disassembly view |
| 72 | | dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) |
| 73 | | machine:*machine |
| 74 | | useConsole:NO]; |
| 74 | dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; |
| 75 | 75 | [dasmView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0]; |
| 76 | 76 | dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, |
| 77 | 77 | 0, |
| r243615 | r243616 | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | |
| 164 | - (IBAction)debugToggleBreakpoint:(id)sender { |
| 165 | if ([dasmView cursorVisible]) |
| 166 | { |
| 167 | device_t &device = [dasmView source]->device(); |
| 168 | offs_t const address = [dasmView selectedAddress]; |
| 169 | device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device]; |
| 170 | |
| 171 | // if it doesn't exist, add a new one |
| 172 | if (bp == NULL) |
| 173 | { |
| 174 | UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL); |
| 175 | debug_console_printf(*machine, "Breakpoint %X set\n", bpnum); |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | int const bpnum = bp->index(); |
| 180 | device.debug()->breakpoint_clear(bpnum); |
| 181 | debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum); |
| 182 | } |
| 183 | |
| 184 | // fail to do this and the display doesn't update |
| 185 | machine->debug_view().update_all(); |
| 186 | debugger_refresh_display(*machine); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | |
| 191 | - (IBAction)debugToggleBreakpointEnable:(id)sender { |
| 192 | if ([dasmView cursorVisible]) |
| 193 | { |
| 194 | device_t &device = [dasmView source]->device(); |
| 195 | offs_t const address = [dasmView selectedAddress]; |
| 196 | device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device]; |
| 197 | if (bp != NULL) |
| 198 | { |
| 199 | device.debug()->breakpoint_enable(bp->index(), !bp->enabled()); |
| 200 | debug_console_printf(*machine, |
| 201 | "Breakpoint %X %s\n", |
| 202 | (UINT32)bp->index(), |
| 203 | bp->enabled() ? "enabled" : "disabled"); |
| 204 | machine->debug_view().update_all(); |
| 205 | debugger_refresh_display(*machine); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | |
| 211 | - (IBAction)debugRunToCursor:(id)sender { |
| 212 | if ([dasmView cursorVisible]) |
| 213 | [dasmView source]->device().debug()->go([dasmView selectedAddress]); |
| 214 | } |
| 215 | |
| 216 | |
| 164 | 217 | - (IBAction)changeSubview:(id)sender { |
| 165 | 218 | [dasmView selectSubviewAtIndex:[[sender selectedItem] tag]]; |
| 166 | 219 | [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; |
| 167 | 220 | } |
| 168 | 221 | |
| 222 | |
| 223 | - (BOOL)validateMenuItem:(NSMenuItem *)item { |
| 224 | SEL const action = [item action]; |
| 225 | BOOL const inContextMenu = ([item menu] == [dasmView menu]); |
| 226 | BOOL const haveCursor = [dasmView cursorVisible]; |
| 227 | |
| 228 | device_debug::breakpoint *breakpoint = NULL; |
| 229 | if (haveCursor) |
| 230 | { |
| 231 | breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress] |
| 232 | forDevice:[dasmView source]->device()]; |
| 233 | } |
| 234 | |
| 235 | if (action == @selector(debugToggleBreakpoint:)) |
| 236 | { |
| 237 | if (haveCursor) |
| 238 | { |
| 239 | if (breakpoint != NULL) |
| 240 | { |
| 241 | if (inContextMenu) |
| 242 | [item setTitle:@"Clear Breakpoint"]; |
| 243 | else |
| 244 | [item setTitle:@"Clear Breakpoint at Cursor"]; |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | if (inContextMenu) |
| 249 | [item setTitle:@"Set Breakpoint"]; |
| 250 | else |
| 251 | [item setTitle:@"Set Breakpoint at Cursor"]; |
| 252 | } |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | if (inContextMenu) |
| 257 | [item setTitle:@"Toggle Breakpoint"]; |
| 258 | else |
| 259 | [item setTitle:@"Toggle Breakpoint at Cursor"]; |
| 260 | } |
| 261 | return haveCursor; |
| 262 | } |
| 263 | else if (action == @selector(debugToggleBreakpointEnable:)) |
| 264 | { |
| 265 | if ((breakpoint != NULL) && !breakpoint->enabled()) |
| 266 | { |
| 267 | if (inContextMenu) |
| 268 | [item setTitle:@"Enable Breakpoint"]; |
| 269 | else |
| 270 | [item setTitle:@"Enable Breakpoint at Cursor"]; |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | if (inContextMenu) |
| 275 | [item setTitle:@"Disable Breakpoint"]; |
| 276 | else |
| 277 | [item setTitle:@"Disable Breakpoint at Cursor"]; |
| 278 | } |
| 279 | return breakpoint != NULL; |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | return YES; |
| 284 | } |
| 285 | } |
| 286 | |
| 169 | 287 | @end |