From 46e8d8d561658ba8b69bd18ba7e104d8576b8f58 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 30 Mar 2010 01:10:00 -0400 Subject: [PATCH] * Do not allow editing of the log table. * Move the transaction checks from |-handleResponse:| to |-readStreamHasData|. * Record log entries AFTER sending and receiving so that the transaction IDs make more sense. --- English.lproj/Log.xib | 100 +++++++++++++----------------------- Source/DebuggerConnection.m | 62 +++++++++++----------- 2 files changed, 68 insertions(+), 94 deletions(-) diff --git a/English.lproj/Log.xib b/English.lproj/Log.xib index b889944..99249cf 100644 --- a/English.lproj/Log.xib +++ b/English.lproj/Log.xib @@ -12,7 +12,7 @@ YES - + YES @@ -47,6 +47,7 @@ NSWindow {1.79769e+308, 1.79769e+308} + {663, 487} 256 @@ -144,7 +145,6 @@ 3 YES - YES @@ -173,7 +173,6 @@ 3 YES - YES @@ -199,7 +198,6 @@ 3 YES - YES @@ -225,7 +223,6 @@ 3 YES - YES @@ -251,7 +248,6 @@ 3 YES - YES @@ -341,7 +337,7 @@ 268 - {{92, 286}, {249, 17}} + {{92, 287}, {249, 17}} YES @@ -366,7 +362,7 @@ 265 - {{553, 287}, {18, 17}} + {{553, 288}, {18, 17}} YES @@ -382,7 +378,7 @@ 265 - {{579, 286}, {67, 17}} + {{579, 287}, {67, 17}} YES @@ -431,30 +427,7 @@ 2322 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - public.url - - - {606, 28} + {606, 15} @@ -476,7 +449,7 @@ 1 - 12263 + 12257 0 @@ -528,12 +501,12 @@ 6 - {606, 1e+07} - {223, 27} + {1229, 1e+07} + {223, 0} - {{1, 1}, {606, 195}} + {{1, 1}, {606, 196}} @@ -547,11 +520,10 @@ 256 - {{607, 1}, {15, 195}} + {{607, 1}, {15, 196}} _doScroller: - 0.9642857142857143 0.85256409645080566 @@ -566,7 +538,7 @@ 0.94565218687057495 - {{20, 81}, {623, 197}} + {{20, 81}, {623, 198}} 18 @@ -577,7 +549,7 @@ 265 - {{476, 286}, {67, 17}} + {{476, 287}, {67, 17}} YES @@ -593,7 +565,7 @@ 265 - {{343, 286}, {131, 17}} + {{343, 287}, {131, 17}} YES @@ -613,7 +585,7 @@ 268 - {{17, 286}, {73, 17}} + {{17, 287}, {73, 17}} YES @@ -627,20 +599,21 @@ - {{0, 181}, {665, 307}} + {{0, 180}, {665, 308}} NSView {{-1, 0}, {665, 488}} - 3 + ConnectionSplitView {663, 487} {{0, 0}, {1680, 1028}} + {663, 509} {1.79769e+308, 1.79769e+308} ConnectionLog @@ -653,7 +626,6 @@ contents error directionName - fontColor LogEntry YES @@ -865,22 +837,6 @@ 96 - - - textColor: selection.fontColor - - - - - - textColor: selection.fontColor - textColor - selection.fontColor - 2 - - - 105 - @@ -1205,11 +1161,14 @@ 1.NSWindowTemplate.visibleAtLaunch 1.WindowOrigin 1.editorWindowContentRectSynchronizationRect + 1.windowTemplate.hasMinSize + 1.windowTemplate.minSize 10.IBPluginDependency 11.IBPluginDependency 2.IBPluginDependency 23.IBPluginDependency 3.IBPluginDependency + 37.CustomClassName 38.IBPluginDependency 39.IBPluginDependency 4.IBPluginDependency @@ -1238,18 +1197,21 @@ YES - {{435, 323}, {663, 487}} + {{403, 154}, {663, 487}} com.apple.InterfaceBuilder.CocoaPlugin - {{435, 323}, {663, 487}} + {{403, 154}, {663, 487}} {196, 240} {{202, 428}, {480, 270}} + + {663, 487} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + BSSplitView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1293,11 +1255,19 @@ - 105 + 106 YES + + BSSplitView + NSSplitView + + IBProjectSource + Source/BSSplitView.h + + LoggingController NSWindowController diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index a884af0..f628079 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -501,20 +501,9 @@ void SocketAcceptCallback(CFSocketRef socket, NSError* error = nil; NSXMLDocument* xmlTest = [[NSXMLDocument alloc] initWithXMLString:currentPacket_ options:NSXMLDocumentTidyXML error:&error]; - // Log this receive event. - LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController]; - LogEntry* log = [logger recordReceive:currentPacket_]; - log.error = error; - log.lastWrittenTransactionID = lastWrittenTransaction_; - log.lastReadTransactionID = lastReadTransaction_; - // Try to recover if we encountered an error. if (error) { - NSLog(@"Could not parse XML? --- %@", error); - NSLog(@"Error UserInfo: %@", [error userInfo]); - NSLog(@"This is the XML Document: %@", currentPacket_); - // We do not want to starve the write queue, so manually parse out the // transaction ID. NSRange location = [currentPacket_ rangeOfString:@"transaction_id"]; @@ -564,7 +553,32 @@ void SocketAcceptCallback(CFSocketRef socket, // Otherwise, assume +1 and hope it works. ++lastReadTransaction_; return; - } + } + else + { + // See if the transaction can be parsed out. + NSInteger transaction = [self transactionIDFromResponse:xmlTest]; + if (transaction < lastReadTransaction_ || transaction != lastWrittenTransaction_) + { + NSLog(@"tx = %d vs %d", transaction, lastReadTransaction_); + NSLog(@"out of date transaction %@", xmlTest); + return; + } + + if (transaction != lastWrittenTransaction_) + NSLog(@"txn doesn't match last written %@", xmlTest); + + lastReadTransaction_ = transaction; + } + + // Log this receive event. + LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController]; + LogEntry* log = [logger recordReceive:currentPacket_]; + log.error = error; + log.lastWrittenTransactionID = lastWrittenTransaction_; + log.lastReadTransactionID = lastReadTransaction_; + + // Finally, dispatch the handler for this response. [self handleResponse:[xmlTest autorelease]]; } } @@ -594,12 +608,6 @@ void SocketAcceptCallback(CFSocketRef socket, char* string = (char*)[command UTF8String]; int stringLength = strlen(string); - // Log this trancation. - LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController]; - LogEntry* log = [logger recordSend:command]; - log.lastWrittenTransactionID = lastWrittenTransaction_; - log.lastReadTransactionID = lastReadTransaction_; - // Busy wait while writing. BAADD. Should background this operation. while (!done) { @@ -634,6 +642,12 @@ void SocketAcceptCallback(CFSocketRef socket, } } } + + // Log this trancation. + LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController]; + LogEntry* log = [logger recordSend:command]; + log.lastWrittenTransactionID = lastWrittenTransaction_; + log.lastReadTransactionID = lastReadTransaction_; } - (void)handleResponse:(NSXMLDocument*)response @@ -645,17 +659,7 @@ void SocketAcceptCallback(CFSocketRef socket, NSLog(@"Xdebug error: %@", error); [delegate errorEncountered:[[[[error objectAtIndex:0] children] objectAtIndex:0] stringValue]]; } - - // Get the name of the command from the engine's response. - NSInteger transaction = [self transactionIDFromResponse:response]; - if (transaction < lastReadTransaction_) - NSLog(@"out of date transaction %@", response); - - if (transaction != lastWrittenTransaction_) - NSLog(@"txn doesn't match last written %@", response); - - lastReadTransaction_ = transaction; - + if ([[[response rootElement] name] isEqualToString:@"init"]) { [self initReceived:response]; -- 2.43.5