From 284d63e404b7db3be3004c4539f84b509caac411 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 2 Apr 2008 17:26:36 -0400 Subject: [PATCH] Adding support to actually set breakpoints on the debuger side * Source/Breakpoint.h: New debuggerId ivar to keep track of the engine's tracking ID * Source/Breakpoint.m: Synthesize ivar * Source/DebuggerConnection.m/h: ([DebuggerConnection addBreakpoint:]): New method ([DebuggerConnection removeBreakpoint:]): New method * Source/DebuggerWindowController.m: ([DebuggerWindowController gutterClickedAtLine:forFile:]): When adding a breakpoint, tell the engine to set it --- Source/Breakpoint.h | 2 ++ Source/Breakpoint.m | 2 +- Source/DebuggerConnection.h | 3 +++ Source/DebuggerConnection.m | 24 ++++++++++++++++++++++++ Source/DebuggerWindowController.m | 4 +++- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Source/Breakpoint.h b/Source/Breakpoint.h index 8ebceb1..3422155 100644 --- a/Source/Breakpoint.h +++ b/Source/Breakpoint.h @@ -21,10 +21,12 @@ { NSString *file; int line; + int debuggerId; } @property(readonly) NSString *file; @property(readonly) int line; +@property(readwrite, assign) int debuggerId; - (id)initWithLine:(int)l inFile:(NSString *)f; diff --git a/Source/Breakpoint.m b/Source/Breakpoint.m index 4073d21..26f5f8e 100644 --- a/Source/Breakpoint.m +++ b/Source/Breakpoint.m @@ -19,7 +19,7 @@ @implementation Breakpoint -@synthesize file, line; +@synthesize file, line, debuggerId; /** * Initializes a breakpoint with a file and line diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index 506d350..d28d8fb 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -17,6 +17,7 @@ #import #import "DebuggerWindowController.h" #import "SocketWrapper.h" +#import "Breakpoint.h" @interface DebuggerConnection : NSObject { @@ -47,6 +48,8 @@ - (void)stepIn; - (void)stepOut; - (void)stepOver; +- (void)addBreakpoint:(Breakpoint *)bp; +- (void)removeBreakpoint:(Breakpoint *)bp; - (void)refreshStatus; - (void)updateStackTraceAndRegisters; diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 6b00c3a..e1a9c0c 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -234,6 +234,30 @@ [windowController addChildren:children toNode:node]; } +#pragma mark Breakpoints + +/** + * Send an add breakpoint command + */ +- (void)addBreakpoint:(Breakpoint *)bp +{ + NSString *cmd = [self createCommand:[NSString stringWithFormat:@"breakpoint_set -t line -f %@ -n %i", [bp file], [bp line]]]; + [socket send:cmd]; + NSXMLDocument *info = [self processData:[socket receive]]; + [bp setDebuggerId:[[[[info rootElement] attributeForName:@"id"] stringValue] intValue]]; +} + +/** + * Removes a breakpoint + */ +- (void)removeBreakpoint:(Breakpoint *)bp +{ + [socket send:[self createCommand:[NSString stringWithFormat:@"breakpoint_remove -d %i", [bp debuggerId]]]]; + [socket receive]; +} + +#pragma mark Private + /** * Helper method to create a string command with the -i automatically tacked on */ diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index 11d160a..376b672 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -281,7 +281,9 @@ } else { - [mngr addBreakpoint:[[Breakpoint alloc] initWithLine:line inFile:file]]; + Breakpoint *bp = [[Breakpoint alloc] initWithLine:line inFile:file]; + [mngr addBreakpoint:bp]; + [connection addBreakpoint:bp]; } [[sourceViewer numberView] setMarkers:[mngr breakpointsForFile:file]]; -- 2.22.5