~ubuntu-branches/ubuntu/vivid/projectcenter.app/vivid

« back to all changes in this revision

Viewing changes to Modules/Debuggers/ProjectCenter/PCDebugger.m

  • Committer: Bazaar Package Importer
  • Author(s): Yavor Doganov
  • Date: 2010-06-03 16:04:52 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100603160452-dcsmkjwdtwxuitdo
Tags: 0.5.3~20100601-1
* New upstream release.
* debian/compat: Set to 7.
* debian/control (Section): Change to `gnustep'.
  (Build-Depends): Require debhelper >= 7, remove version constraints
  for libgnustep-gui-dev (obsolete).
  (Depends): Add ${gnustep:Depends}.
  (Standards-Version): Compliant with 3.8.4 as of this release.
  (Vcs-Arch): New field.
  (Description): Do not praise NextStep.
* debian/rules: Export GNUSTEP_MAKEFILES and get rid of gs_make.
  (OPTFLAG): No longer define; rework noopt handling to be compatible
  with gnustep-make/2.4.x (Closes: #581976).
  (build-stamp): Pass GDB=/usr/bin/gdb for the PCDefaultDebugger
  define.
  (install): Replace dh_clean -k with dh_prep.
  (binary-arch): Adjust dh_installchangelogs' argument.  Rework the
  FHS_ME_HARDER snippet; PC's supporting executables are no longer
  installed as Bundles.
* debian/patches/05_link-libs.dpatch: Update; the fix was merged
  upstream, but now -lm is required as well.
* debian/patches/10_bundles-install-dir.dpatch: Remove; obsolete with
  the new way of FHS-compliance handling.
* debian/links: Delete; no longer needed.
* debian/menu: Adjust command.
* debian/source/format:
* debian/README.source:
* debian/preinst: New file.
* debian/copyright: Bump copyright years, add more upstream authors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
**  PCDebugger
 
3
**
 
4
**  Copyright (c) 2008
 
5
**
 
6
**  Author: Gregory Casamento <greg_casamento@yahoo.com>
 
7
**
 
8
**  This program is free software; you can redistribute it and/or modify
 
9
**  it under the terms of the GNU General Public License as published by
 
10
**  the Free Software Foundation; either version 2 of the License, or
 
11
**  (at your option) any later version.
 
12
**
 
13
**  This program is distributed in the hope that it will be useful,
 
14
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
**  GNU General Public License for more details.
 
17
**
 
18
**  You should have received a copy of the GNU General Public License
 
19
**  along with this program; if not, write to the Free Software
 
20
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
21
*/
 
22
 
 
23
#import <AppKit/AppKit.h>
 
24
#import "PCDebugger.h"
 
25
#import "PCDebuggerView.h"
 
26
 
 
27
#ifndef NOTIFICATION_CENTER
 
28
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
 
29
#endif
 
30
 
 
31
static NSImage  *goImage = nil;
 
32
static NSImage  *pauseImage = nil;
 
33
static NSImage  *continueImage = nil;
 
34
static NSImage  *restartImage = nil;
 
35
static NSImage  *nextImage = nil;
 
36
static NSImage  *stepInImage = nil;
 
37
static NSImage  *stepOutImage = nil;
 
38
static NSImage  *upImage = nil;
 
39
static NSImage  *downImage = nil;
 
40
 
 
41
@implementation PCDebugger
 
42
+ (void) initialize
 
43
{
 
44
  if (self == [PCDebugger class])
 
45
    {
 
46
      NSBundle  *bundle;
 
47
      NSString  *path;
 
48
 
 
49
      bundle = [NSBundle bundleForClass: self];
 
50
      path = [bundle pathForImageResource: @"go_button"];
 
51
      if (path != nil)
 
52
        {
 
53
          goImage = [[NSImage alloc] initWithContentsOfFile: path];
 
54
        }
 
55
      path = [bundle pathForImageResource: @"pause_button"];
 
56
      if (path != nil)
 
57
        {
 
58
          pauseImage = [[NSImage alloc] initWithContentsOfFile: path];
 
59
        }
 
60
      path = [bundle pathForImageResource: @"continue_button"];
 
61
      if (path != nil)
 
62
        {
 
63
          continueImage = [[NSImage alloc] initWithContentsOfFile: path];
 
64
        }
 
65
      path = [bundle pathForImageResource: @"restart_button"];
 
66
      if (path != nil)
 
67
        {
 
68
          restartImage = [[NSImage alloc] initWithContentsOfFile: path];
 
69
        }
 
70
      path = [bundle pathForImageResource: @"next_button"];
 
71
      if (path != nil)
 
72
        {
 
73
          nextImage = [[NSImage alloc] initWithContentsOfFile: path];
 
74
        }
 
75
      path = [bundle pathForImageResource: @"stepin_button"];
 
76
      if (path != nil)
 
77
        {
 
78
          stepInImage = [[NSImage alloc] initWithContentsOfFile: path];
 
79
        }
 
80
      path = [bundle pathForImageResource: @"stepout_button"];
 
81
      if (path != nil)
 
82
        {
 
83
          stepOutImage = [[NSImage alloc] initWithContentsOfFile: path];
 
84
        }
 
85
      path = [bundle pathForImageResource: @"up_button"];
 
86
      if (path != nil)
 
87
        {
 
88
          upImage = [[NSImage alloc] initWithContentsOfFile: path];
 
89
        }
 
90
      path = [bundle pathForImageResource: @"down_button"];
 
91
      if (path != nil)
 
92
        {
 
93
          downImage = [[NSImage alloc] initWithContentsOfFile: path];
 
94
        }
 
95
    }
 
96
}
 
97
 
 
98
- (id) init
 
99
{
 
100
  if((self = [super init]) != nil)
 
101
    {
 
102
      // initialization here...
 
103
      if([NSBundle loadNibNamed: @"PCDebugger" owner: self] == NO)
 
104
        {
 
105
          return nil;
 
106
        }
 
107
 
 
108
      [(PCDebuggerView *)debuggerView setDebugger:self];
 
109
    }
 
110
  return self;
 
111
}
 
112
 
 
113
-(void) debugExecutableAtPath: (NSString *)filePath
 
114
                 withDebugger: (NSString *)debugger
 
115
{
 
116
  ASSIGN(path,filePath);
 
117
  ASSIGN(debuggerPath,debugger);
 
118
  [debuggerWindow setTitle: [NSString stringWithFormat: @"Debugger (%@)",filePath]];
 
119
  [self show];
 
120
}
 
121
 
 
122
- (void) show
 
123
{
 
124
  [debuggerWindow makeKeyAndOrderFront: self];
 
125
  [self startDebugger];
 
126
}
 
127
 
 
128
- (void) startDebugger
 
129
{
 
130
  [debuggerView runProgram: debuggerPath
 
131
                inCurrentDirectory: [path stringByDeletingLastPathComponent]
 
132
                withArguments: [[NSArray alloc] initWithObjects: @"-f", path, nil]
 
133
                logStandardError: YES];
 
134
}   
 
135
 
 
136
- (void) awakeFromNib
 
137
{
 
138
  NSToolbar *toolbar = [(NSToolbar *)[NSToolbar alloc] initWithIdentifier: @"PCDebuggerToolbar"];
 
139
  [toolbar setAllowsUserCustomization: NO];
 
140
  [toolbar setDelegate: self];
 
141
  [debuggerWindow setToolbar: toolbar];
 
142
  RELEASE(toolbar);
 
143
 
 
144
  [debuggerView setFont: [NSFont userFixedPitchFontOfSize: 0]];
 
145
  [debuggerWindow setFrameAutosaveName: @"PCDebuggerWindow"];
 
146
  [self setStatus: @"Idle."];
 
147
}
 
148
 
 
149
- (NSWindow *)debuggerWindow
 
150
{
 
151
  return debuggerWindow;
 
152
}
 
153
 
 
154
- (void)setDebuggerWindow: (NSWindow *)window
 
155
{
 
156
  debuggerWindow = window;
 
157
}
 
158
 
 
159
- (NSView *)debuggerView
 
160
{
 
161
  return debuggerView;
 
162
}
 
163
 
 
164
- (void)setDebuggerView: (id)view
 
165
{
 
166
  debuggerView = view;
 
167
}
 
168
 
 
169
- (NSString *)path
 
170
{
 
171
  return path;
 
172
}
 
173
 
 
174
- (void)setPath:(NSString *)p
 
175
{
 
176
  ASSIGN(path,p);
 
177
}
 
178
 
 
179
// action methods for toolbar...
 
180
- (void) go: (id) sender
 
181
{
 
182
  [self setStatus: @"Running..."];
 
183
  [debuggerView putString: @"run\n"];
 
184
}
 
185
 
 
186
- (void) pause: (id) sender
 
187
{
 
188
  [self setStatus: @"Stopped."];
 
189
  [debuggerView interrupt];
 
190
}
 
191
 
 
192
- (void) continue: (id) sender
 
193
{
 
194
  [self setStatus: @"Continue..."];
 
195
  [debuggerView putString: @"continue\n"];
 
196
}
 
197
 
 
198
- (void) restart: (id) sender
 
199
{
 
200
  [self setStatus: @"Restarting..."];
 
201
  [debuggerView interrupt];
 
202
  [debuggerView putString: @"run\n"];
 
203
  [self setStatus: @"Running..."];
 
204
}
 
205
 
 
206
- (void) next: (id) sender
 
207
{
 
208
  [self setStatus: @"Going to next line."];
 
209
  [debuggerView putString: @"next\n"];
 
210
}
 
211
 
 
212
- (void) stepInto: (id) sender
 
213
{
 
214
  [self setStatus: @"Stepping into method."];
 
215
  [debuggerView putString: @"step\n"];  
 
216
}
 
217
 
 
218
- (void) stepOut: (id) sender
 
219
{
 
220
  [self setStatus: @"Finishing method."];
 
221
  [debuggerView putString: @"finish\n"];  
 
222
}
 
223
 
 
224
- (void) up: (id) sender
 
225
{
 
226
  [self setStatus: @"Up to calling method."];
 
227
  [debuggerView putString: @"up\n"];  
 
228
}
 
229
 
 
230
- (void) down: (id) sender
 
231
{
 
232
  [self setStatus: @"Down to called method."];
 
233
  [debuggerView putString: @"down\n"];  
 
234
}
 
235
 
 
236
// Status..
 
237
- (void) setStatus: (NSString *) status
 
238
{
 
239
  [statusField setStringValue: status];
 
240
}
 
241
 
 
242
- (NSString *) status
 
243
{
 
244
  return [statusField stringValue];
 
245
}
 
246
 
 
247
- (void) dealloc
 
248
{
 
249
  [debuggerWindow close];
 
250
  [super dealloc];
 
251
}
 
252
@end
 
253
 
 
254
@implementation PCDebugger (NSToolbarDelegate)
 
255
 
 
256
- (NSToolbarItem*)toolbar: (NSToolbar*)toolbar
 
257
    itemForItemIdentifier: (NSString*)itemIdentifier
 
258
willBeInsertedIntoToolbar: (BOOL)flag
 
259
{
 
260
  NSToolbarItem *toolbarItem = AUTORELEASE([[NSToolbarItem alloc]
 
261
                                             initWithItemIdentifier: itemIdentifier]);
 
262
 
 
263
  if([itemIdentifier isEqual: @"GoItem"])
 
264
    {
 
265
      [toolbarItem setLabel: @"Go"];
 
266
      [toolbarItem setImage: goImage];
 
267
      [toolbarItem setTarget: self];
 
268
      [toolbarItem setAction: @selector(go:)];     
 
269
      [toolbarItem setTag: 0];
 
270
    }
 
271
  else if([itemIdentifier isEqual: @"PauseItem"])
 
272
    {
 
273
      [toolbarItem setLabel: @"Pause"];
 
274
      [toolbarItem setImage: pauseImage];
 
275
      [toolbarItem setTarget: self];
 
276
      [toolbarItem setAction: @selector(pause:)];     
 
277
      [toolbarItem setTag: 1];
 
278
    }
 
279
  else if([itemIdentifier isEqual: @"ContinueItem"])
 
280
    {
 
281
      [toolbarItem setLabel: @"Continue"];
 
282
      [toolbarItem setImage: continueImage];
 
283
      [toolbarItem setTarget: self];
 
284
      [toolbarItem setAction: @selector(continue:)];     
 
285
      [toolbarItem setTag: 1];
 
286
    }
 
287
  else if([itemIdentifier isEqual: @"RestartItem"])
 
288
    {
 
289
      [toolbarItem setLabel: @"Restart"];
 
290
      [toolbarItem setImage: restartImage];
 
291
      [toolbarItem setTarget: self];
 
292
      [toolbarItem setAction: @selector(restart:)];     
 
293
      [toolbarItem setTag: 2];
 
294
    }
 
295
  else if([itemIdentifier isEqual: @"NextItem"])
 
296
    {
 
297
      [toolbarItem setLabel: @"Next"];
 
298
      [toolbarItem setImage: nextImage];
 
299
      [toolbarItem setTarget: self];
 
300
      [toolbarItem setAction: @selector(next:)];     
 
301
      [toolbarItem setTag: 3];
 
302
    }
 
303
  else if([itemIdentifier isEqual: @"StepIntoItem"])
 
304
    {
 
305
      [toolbarItem setLabel: @"Step Into"];
 
306
      [toolbarItem setImage: stepInImage];
 
307
      [toolbarItem setTarget: self];
 
308
      [toolbarItem setAction: @selector(stepInto:)];     
 
309
      [toolbarItem setTag: 4];
 
310
    }
 
311
  else if([itemIdentifier isEqual: @"StepOutItem"])
 
312
    {
 
313
      [toolbarItem setLabel: @"Step Out"];
 
314
      [toolbarItem setImage: stepOutImage];
 
315
      [toolbarItem setTarget: self];
 
316
      [toolbarItem setAction: @selector(stepOut:)];     
 
317
      [toolbarItem setTag: 5];
 
318
    }
 
319
  else if([itemIdentifier isEqual: @"UpItem"])
 
320
    {
 
321
      [toolbarItem setLabel: @"Up"];
 
322
      [toolbarItem setImage: upImage];
 
323
      [toolbarItem setTarget: self];
 
324
      [toolbarItem setAction: @selector(up:)];     
 
325
      [toolbarItem setTag: 6];
 
326
    }
 
327
  else if([itemIdentifier isEqual: @"DownItem"])
 
328
    {
 
329
      [toolbarItem setLabel: @"Down"];
 
330
      [toolbarItem setImage: downImage];
 
331
      [toolbarItem setTarget: self];
 
332
      [toolbarItem setAction: @selector(down:)];     
 
333
      [toolbarItem setTag: 7];
 
334
    }
 
335
 
 
336
  return toolbarItem;
 
337
}
 
338
 
 
339
- (NSArray*) toolbarAllowedItemIdentifiers: (NSToolbar*)toolbar
 
340
{
 
341
  return [NSArray arrayWithObjects: @"GoItem", 
 
342
                  @"PauseItem", 
 
343
                  @"ContinueItem", 
 
344
                  @"RestartItem", 
 
345
                  @"NextItem", 
 
346
                  @"StepIntoItem", 
 
347
                  @"StepOutItem", 
 
348
                  @"UpItem", 
 
349
                  @"DownItem", 
 
350
                  nil];
 
351
}
 
352
 
 
353
- (NSArray*) toolbarDefaultItemIdentifiers: (NSToolbar*)toolbar
 
354
 
355
  return [NSArray arrayWithObjects: @"GoItem", 
 
356
                  @"PauseItem", 
 
357
                  @"ContinueItem", 
 
358
                  @"RestartItem", 
 
359
                  @"NextItem", 
 
360
                  @"StepIntoItem", 
 
361
                  @"StepOutItem", 
 
362
                  @"UpItem", 
 
363
                  @"DownItem", 
 
364
                  nil];
 
365
}
 
366
 
 
367
- (NSArray*) toolbarSelectableItemIdentifiers: (NSToolbar*)toolbar
 
368
 
369
  return [NSArray arrayWithObjects: @"GoItem", 
 
370
                  @"PauseItem", 
 
371
                  @"ContinueItem", 
 
372
                  @"RestartItem", 
 
373
                  @"NextItem", 
 
374
                  @"StepIntoItem", 
 
375
                  @"StepOutItem", 
 
376
                  @"UpItem", 
 
377
                  @"DownItem", 
 
378
                  nil];
 
379
}
 
380
@end