Hello, guest. We have noticed that you are not registered at this bug tracker. Your experience will be greatly enhanced if you log in. To do so, you first must register by clicking on the Register tab at the top. If you are already registered, you can login at the Login tab.
Syndicate Syndicate Listing Display Search Login/Register
Bug Id ?
147
Reporter ?
MacGDBp / 1.1.1
Status ?
Closed
Severity ?
Enhancement
Duplicate Of ?
- none -
Fixed in Revision ?
master/0228bbe
Mstone ?
Summary ?
Patch to show context based registers (ie superglobals)
Report Time ?
January 4, 2009 04:54 AM
Assignment ?
Resolution ?
Fixed
Priority ?
Normal
Dependencies ?
- none -
Mstone (old) ?


Attachments
Votes
For: 0 (0%)
Against: 0 (0%)
Total: 0

January 4, 2009 04:54 AM Nicola Ferruzzi
Hello,

I wrote a short patch to show Superglobals registers and Class, not only Locals. It gets an array of remote contexts and then it generates an array of variables used to update the window using setRegister. I tried to keep the code clean, but this is almost my second time using ObjC so .. sorry for any memory leak :)

I don't see how to attach a file, the patch is pasted below.

diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h
index 59ae3f2..0384c45 100644
--- a/Source/DebuggerController.h
+++ b/Source/DebuggerController.h
@@ -50,7 +50,7 @@
- (void)setStatus:(NSString *)aStatus;
- (void)setError:(NSString *)anError;
- (void)setStack:(NSArray *)node;
-- (void)setRegister:(NSXMLDocument *)reg;
+- (void)setRegister:(NSArray *)reg;

- (IBAction)run:(id)sender;
- (IBAction)stepIn:(id)sender;
diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m
index 417291c..fb1e520 100644
--- a/Source/DebuggerController.m
+++ b/Source/DebuggerController.m
@@ -160,7 +160,7 @@
/**
* Sets the stack root element so that the NSOutlineView can display it
*/
-- (void)setRegister:(NSXMLDocument *)elm
+- (void)setRegister:(NSArray *)elm
{
// XXX: Doing anything short of this will cause bindings to crash spectacularly for no reason whatsoever, and
// in seemingly arbitrary places. The class that crashes is _NSKeyValueObservationInfoCreateByRemoving.
@@ -170,7 +170,7 @@
// was the inspiration for this fix (below) but the author says that inserting does not work too well, but
// that's okay for us as we just need to replace the entire thing.
[registerController setContent:nil];
- [registerController setContent:[[elm rootElement] children]];
+ [registerController setContent:elm];

for (int i = 0; i < [registerView numberOfRows]; i++)
{
diff --git a/Source/GDBpConnection.m b/Source/GDBpConnection.m
index 10fa28a..4fda93d 100644
--- a/Source/GDBpConnection.m
+++ b/Source/GDBpConnection.m
@@ -20,6 +20,7 @@
@interface GDBpConnection (Private)
- (NSString *)createCommand:(NSString *)cmd;
- (NSXMLDocument *)processData:(NSString *)data;
+- (NSMutableArray *)fromDocToArrayOfDict:(NSXMLDocument *)doc;
@end

@implementation GDBpConnection
@@ -206,25 +207,22 @@
{
// do the stack
[socket send:[self createCommand:@"stack_get"]];
- NSXMLDocument *doc = [self processData:[socket receive]];
- NSArray *children = [[doc rootElement] children];
- NSMutableArray *stack = [NSMutableArray array];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- for (int i = 0; i < [children count]; i++)
- {
- NSArray *attrs = [[children objectAtIndex:i] attributes];
- for (int j = 0; j < [attrs count]; j++)
- {
- [dict setValue:[[attrs objectAtIndex:j] stringValue] forKey:[[attrs objectAtIndex:j] name]];
- }
- [stack addObject:dict];
- dict = [NSMutableDictionary dictionary];
- }
+ NSMutableArray *stack = [self fromDocToArrayOfDict: [self processData:[socket receive]]];
[windowController setStack:stack];

- // do the registers
- [socket send:[self createCommand:@"context_get"]];
- [windowController setRegister:[self processData:[socket receive]]];
+ // get the contexts
+ [socket send:[self createCommand:@"context_names"]];
+ NSMutableArray *contexts = [self fromDocToArrayOfDict: [self processData:[socket receive]]];
+
+ // get and merge the registers from the contexts
+ NSMutableArray *content = [NSMutableArray array];
+ for (int i = 0; i < [contexts count]; ++i)
+ {
+ NSMutableDictionary *context = [contexts objectAtIndex:i];
+ [socket send:[self createCommand:[NSString stringWithFormat:@"context_get -c %@", [context valueForKey:@"id"]]]];
+ [content addObjectsFromArray: [[[self processData:[socket receive]] rootElement] children]];
+ }
+ [windowController setRegister:content];
}

/**
@@ -320,4 +318,27 @@
return [doc autorelease];
}

+/**
+ * Helper function to split the NSXMLDocument into an NSMutableArray of NSMutableDictionary
+ */
+- (NSMutableArray *)fromDocToArrayOfDict:(NSXMLDocument *)doc
+{
+ NSArray *children = [[doc rootElement] children];
+ NSMutableArray *array = [NSMutableArray array];
+ NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+ for (int i = 0; i < [children count]; i++)
+ {
+ NSArray *attrs = [[children objectAtIndex:i] attributes];
+ for (int j = 0; j < [attrs count]; j++)
+ {
+ [dict setValue:[[attrs objectAtIndex:j] stringValue] forKey:[[attrs objectAtIndex:j] name]];
+ }
+ [array addObject:dict];
+ dict = [NSMutableDictionary dictionary];
+ }
+
+ return array;
+}
+
+
@end


February 5, 2009 06:46 PM Robert
Thanks for the patch! I had to do some rebasing because I've refactored a bit, but your logic is still at the core of this patch.

--------------- AUTOMATIC RESPONSE ---------------
Thank you for your bug report. This issue has been closed and fixed in git. This change will be available in a future release, but you can download the change at any time from the git repository, found at http://www.bluestatic.org/git/.

On February 5, 2009 06:46 PM, Robert changed: