Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 21, 2009, 02:10 PM   #1
shusseina
macrumors newbie
 
Join Date: Feb 2009
Is Something Wrong with My Program?

Hi there

I have an Objective-C program, created in Xcode, which simply writes its output to the console.

There is one line in my program, that if I comment out and run the program the console output ends after exiting the controller object's awakeFromNib method. At which point I hit the Stop button to quit the program.

However, if I uncomment this one line of code and run the program, the console output is the same as before except the debugger is then loaded.

Should I take the debugger loading automatically as a sign that something is wrong with my program? Note, I still need to hit Stop to quit the program.

Below is the extra console output:

Code:
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/steve/mysoftware/projects/Cocoa3 Quran/build/Release/Cocoa3 Quran.app/Contents/MacOS/Cocoa3 Quran', process 15543.
(gdb)
shusseina is offline   0 Reply With Quote
Old Mar 21, 2009, 03:49 PM   #2
garethlewis2
macrumors 6502
 
Join Date: Dec 2006
You need to post the code. Nobody is going to decipher anything from that.

But, yes, your program crashed and XCode launched gdb. If you type either where, or stacktrace into the gdb window, gdb will print out where the program crashed. If you are lucky, it may even have the variables in memory, in which case, type either info locals, or info arguments to see what is in memory.

Post the code if that doesn't help you.
garethlewis2 is offline   0 Reply With Quote
Old Mar 21, 2009, 09:58 PM   #3
shusseina
Thread Starter
macrumors newbie
 
Join Date: Feb 2009
Fair enough.

The where command produced the following output:

Code:
Program received signal:  “EXC_BAD_ACCESS”.
(gdb) where
#0  0x96419688 in objc_msgSend ()
#1  0x900c3e4f in NSPopAutoreleasePool ()
#2  0x922c56ac in loadNib ()
#3  0x922c4fe8 in +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] ()
#4  0x922c4c2b in +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] ()
#5  0x922c4b69 in +[NSBundle(NSNibLoading) loadNibNamed:owner:] ()
#6  0x922c4818 in NSApplicationMain ()
#7  0x000025c2 in start ()
(gdb)
I notice the console output does not report the debugger is starting and immediately goes to the debugger prompt. Not sure if this is because I am running the program via the "Build and Debug" menu option? Also, the console output now reports: Program received signal: “EXC_BAD_ACCESS”.

BTW, what's the difference between "Build and Go (Debug)", "Build and Run" and "Build and Debug"? I know I know, I should be looking this stuff up in the Xcode documentation/help.

The stacktrace command did not work, however the backtrace command had the same effect as the where command.

The info locals and info args commands both reported: No symbol table info available.

Final question. My program is a Cocoa-based application written in Objective-C. Will the fact that my program has no user interface, apart from the default and a reference to my controller class, cause the program to complain? Actually, I guess the answer is no, as if I comment out the problematic line, the program seems to run cleanly. Admittedly, the code behind the one line is very 'raw' and even though it does what it is suppose to, it needs to be reviewed and optimised.

Thanks for your help.
shusseina is offline   0 Reply With Quote
Old Mar 21, 2009, 10:04 PM   #4
eddietr
macrumors 6502a
 
Join Date: Oct 2006
Location: Virginia
It would be really helpful if you posted actual source code. Like, for example, the line that is causing the crash. And some context about what object and method you are trying to use in that line.
eddietr is offline   0 Reply With Quote
Old Mar 22, 2009, 09:15 AM   #5
MrFusion
macrumors 6502a
 
Join Date: Jun 2005
Location: West-Europe
Quote:
Originally Posted by shusseina View Post
Fair enough.

The where command produced the following output:

I notice the console output does not report the debugger is starting and immediately goes to the debugger prompt. Not sure if this is because I am running the program via the "Build and Debug" menu option? Also, the console output now reports: Program received signal: “EXC_BAD_ACCESS”.

BTW, what's the difference between "Build and Go (Debug)", "Build and Run" and "Build and Debug"? I know I know, I should be looking this stuff up in the Xcode documentation/help.

The stacktrace command did not work, however the backtrace command had the same effect as the where command.

The info locals and info args commands both reported: No symbol table info available.

Final question. My program is a Cocoa-based application written in Objective-C. Will the fact that my program has no user interface, apart from the default and a reference to my controller class, cause the program to complain? Actually, I guess the answer is no, as if I comment out the problematic line, the program seems to run cleanly. Admittedly, the code behind the one line is very 'raw' and even though it does what it is suppose to, it needs to be reviewed and optimised.

Thanks for your help.
I am going to be a bit mean here.
"Is Something Wrong with My Program?" Yes, otherwise your program wouldn't crash and you wouldn't post here. Be more specific in your title.

You don't seem to know much about programming. Take a step back, and forget about GUI's. Start with command line tools and learn objective-c syntax first.

"Build and Run" is going to execute to program. Do this when you just want to see how the program behaves.
"Build and Debug" is going to start the debugger and allow you to go through each line of code (provided that you add breakpoints) and inspect the content of the variables. Do this if you know which user actions crashes the program, and step through those linecodes that handle that action to see which line makes the program crash.
MrFusion is offline   0 Reply With Quote
Old Mar 22, 2009, 03:23 PM   #6
eddietr
macrumors 6502a
 
Join Date: Oct 2006
Location: Virginia
To be fair, I'm wondering if the OP may be reluctant to post code because of the political/religious nature of the application he (she?) is working on.

But really, nobody here cares about that stuff. If you just post the code that causing you the issue, I'm sure someone can help you out.

Lots of beginners use this forum to get help. Nothing wrong with that.
eddietr is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
I'm not really sure what went wrong.. aDRock1154 iOS 6 3 Jul 25, 2012 02:17 AM
I think I have something wrong. zeiter MacBook Pro 15 Jun 23, 2012 07:56 PM

Forum Jump

All times are GMT -5. The time now is 10:53 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC