trunk/src/osd/modules/debugger/osx/disassemblyview.m
| r243597 | r243598 | |
| 19 | 19 | |
| 20 | 20 | @implementation MAMEDisassemblyView |
| 21 | 21 | |
| 22 | | - (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address inAddressSpace:(address_space &)space { |
| 23 | | device_debug *cpuinfo = space.device().debug(); |
| 22 | - (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device { |
| 23 | device_debug *cpuinfo = device.debug(); |
| 24 | 24 | device_debug::breakpoint *bp; |
| 25 | | for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) {} |
| 25 | for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) { } |
| 26 | 26 | return bp; |
| 27 | 27 | } |
| 28 | 28 | |
| r243597 | r243598 | |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | - (BOOL)validateMenuItem:(NSMenuItem *)item { |
| 93 | | SEL action = [item action]; |
| 94 | | BOOL inContextMenu = ([item menu] == [self menu]); |
| 95 | | BOOL haveCursor = NO, isCurrent = NO; |
| 96 | | device_debug::breakpoint *breakpoint = NULL; |
| 93 | 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 | 97 | |
| 98 | | if (view->cursor_visible()) { |
| 99 | | if (debug_cpu_get_visible_cpu(*machine) == view->source()->device()) { |
| 100 | | isCurrent = YES; |
| 101 | | if (!useConsole || isCurrent) { |
| 102 | | offs_t address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 103 | | haveCursor = YES; |
| 104 | | breakpoint = [self findBreakpointAtAddress:address inAddressSpace:downcast<const debug_view_disasm_source *>(view->source())->space()]; |
| 105 | | } |
| 106 | | } |
| 98 | device_debug::breakpoint *breakpoint = NULL; |
| 99 | if (haveCursor) |
| 100 | { |
| 101 | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 102 | breakpoint = [self findBreakpointAtAddress:address forDevice:[self source]->device()]; |
| 107 | 103 | } |
| 108 | 104 | |
| 109 | | if (action == @selector(debugToggleBreakpoint:)) { |
| 110 | | if (haveCursor) { |
| 111 | | if (breakpoint != NULL) { |
| 105 | if (action == @selector(debugToggleBreakpoint:)) |
| 106 | { |
| 107 | if (haveCursor) |
| 108 | { |
| 109 | if (breakpoint != NULL) |
| 110 | { |
| 112 | 111 | if (inContextMenu) |
| 113 | 112 | [item setTitle:@"Clear Breakpoint"]; |
| 114 | 113 | else |
| 115 | 114 | [item setTitle:@"Clear Breakpoint at Cursor"]; |
| 116 | | } else { |
| 115 | } |
| 116 | else |
| 117 | { |
| 117 | 118 | if (inContextMenu) |
| 118 | 119 | [item setTitle:@"Set Breakpoint"]; |
| 119 | 120 | else |
| 120 | 121 | [item setTitle:@"Set Breakpoint at Cursor"]; |
| 121 | 122 | } |
| 122 | | } else { |
| 123 | } |
| 124 | else |
| 125 | { |
| 123 | 126 | if (inContextMenu) |
| 124 | 127 | [item setTitle:@"Toggle Breakpoint"]; |
| 125 | 128 | else |
| 126 | 129 | [item setTitle:@"Toggle Breakpoint at Cursor"]; |
| 127 | 130 | } |
| 128 | | return haveCursor; |
| 129 | | } else if (action == @selector(debugToggleBreakpointEnable:)) { |
| 130 | | if ((breakpoint != NULL) && !breakpoint->enabled()) { |
| 131 | return haveCursor && (!useConsole || isCurrent); |
| 132 | } |
| 133 | else if (action == @selector(debugToggleBreakpointEnable:)) |
| 134 | { |
| 135 | if ((breakpoint != NULL) && !breakpoint->enabled()) |
| 136 | { |
| 131 | 137 | if (inContextMenu) |
| 132 | 138 | [item setTitle:@"Enable Breakpoint"]; |
| 133 | 139 | else |
| 134 | 140 | [item setTitle:@"Enable Breakpoint at Cursor"]; |
| 135 | | } else { |
| 141 | } |
| 142 | else |
| 143 | { |
| 136 | 144 | if (inContextMenu) |
| 137 | 145 | [item setTitle:@"Disable Breakpoint"]; |
| 138 | 146 | else |
| 139 | 147 | [item setTitle:@"Disable Breakpoint at Cursor"]; |
| 140 | 148 | } |
| 141 | | return (breakpoint != NULL); |
| 142 | | } else if (action == @selector(debugRunToCursor:)) { |
| 143 | | return isCurrent; |
| 144 | | } else if (action == @selector(showRightColumn:)) { |
| 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 | { |
| 145 | 157 | [item setState:((downcast<debug_view_disasm *>(view)->right_column() == [item tag]) ? NSOnState : NSOffState)]; |
| 146 | 158 | return YES; |
| 147 | | } else { |
| 159 | } |
| 160 | else |
| 161 | { |
| 148 | 162 | return YES; |
| 149 | 163 | } |
| 150 | 164 | } |
| 151 | 165 | |
| 152 | 166 | |
| 153 | 167 | - (NSSize)maximumFrameSize { |
| 154 | | debug_view_xy max; |
| 155 | | device_t *curcpu = debug_cpu_get_visible_cpu(*machine); |
| 156 | | const debug_view_source *source = view->source_for_device(curcpu); |
| 168 | debug_view_xy max(0, 0); |
| 169 | const debug_view_source *source = view->source(); |
| 157 | 170 | |
| 158 | | max.x = max.y = 0; |
| 159 | 171 | for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) |
| 160 | 172 | { |
| 161 | | debug_view_xy current; |
| 173 | debug_view_xy current; |
| 162 | 174 | view->set_source(*source); |
| 163 | 175 | current = view->total_size(); |
| 164 | 176 | if (current.x > max.x) |
| r243597 | r243598 | |
| 258 | 270 | - (IBAction)debugToggleBreakpoint:(id)sender { |
| 259 | 271 | if (view->cursor_visible()) |
| 260 | 272 | { |
| 261 | | address_space &space = downcast<const debug_view_disasm_source *>(view->source())->space(); |
| 262 | | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) |
| 273 | device_t &device = [self source]->device(); |
| 274 | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 263 | 275 | { |
| 264 | 276 | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 265 | | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; |
| 277 | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device]; |
| 266 | 278 | |
| 267 | 279 | // if it doesn't exist, add a new one |
| 268 | 280 | if (useConsole) |
| r243597 | r243598 | |
| 278 | 290 | { |
| 279 | 291 | if (bp == NULL) |
| 280 | 292 | { |
| 281 | | UINT32 const bpnum = space.device().debug()->breakpoint_set(address, NULL, NULL); |
| 293 | UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL); |
| 282 | 294 | debug_console_printf(*machine, "Breakpoint %X set\n", bpnum); |
| 283 | 295 | } |
| 284 | 296 | else |
| 285 | 297 | { |
| 286 | 298 | int const bpnum = bp->index(); |
| 287 | | space.device().debug()->breakpoint_clear(bpnum); |
| 299 | device.debug()->breakpoint_clear(bpnum); |
| 288 | 300 | debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum); |
| 289 | 301 | } |
| 290 | 302 | } |
| r243597 | r243598 | |
| 300 | 312 | - (IBAction)debugToggleBreakpointEnable:(id)sender { |
| 301 | 313 | if (view->cursor_visible()) |
| 302 | 314 | { |
| 303 | | address_space &space = downcast<const debug_view_disasm_source *>(view->source())->space(); |
| 304 | | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) |
| 315 | device_t &device = [self source]->device(); |
| 316 | if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) |
| 305 | 317 | { |
| 306 | 318 | offs_t const address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 307 | | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; |
| 319 | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device]; |
| 308 | 320 | if (bp != NULL) |
| 309 | 321 | { |
| 310 | 322 | if (useConsole) |
| r243597 | r243598 | |
| 318 | 330 | } |
| 319 | 331 | else |
| 320 | 332 | { |
| 321 | | space.device().debug()->breakpoint_enable(bp->index(), !bp->enabled()); |
| 333 | device.debug()->breakpoint_enable(bp->index(), !bp->enabled()); |
| 322 | 334 | debug_console_printf(*machine, |
| 323 | 335 | "Breakpoint %X %s\n", |
| 324 | 336 | (UINT32)bp->index(), |
| r243597 | r243598 | |
| 333 | 345 | |
| 334 | 346 | |
| 335 | 347 | - (IBAction)debugRunToCursor:(id)sender { |
| 336 | | if (view->cursor_visible()) { |
| 337 | | address_space &space = downcast<const debug_view_disasm_source *>(view->source())->space(); |
| 338 | | if (debug_cpu_get_visible_cpu(*machine) == &space.device()) { |
| 339 | | offs_t address = downcast<debug_view_disasm *>(view)->selected_address(); |
| 340 | | if (useConsole) { |
| 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 | { |
| 341 | 356 | NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)address]; |
| 342 | 357 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 343 | | } else { |
| 344 | | debug_cpu_get_visible_cpu(*machine)->debug()->go(address); |
| 345 | 358 | } |
| 359 | else |
| 360 | { |
| 361 | device.debug()->go(address); |
| 362 | } |
| 346 | 363 | } |
| 347 | 364 | } |
| 348 | 365 | } |