PDA

View Full Version : Is Something Wrong with My Program?




shusseina
Mar 21, 2009, 01:10 PM
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:

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)



garethlewis2
Mar 21, 2009, 02:49 PM
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.

shusseina
Mar 21, 2009, 08:58 PM
Fair enough. :)

The where command produced the following output:

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.

eddietr
Mar 21, 2009, 09:04 PM
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.

MrFusion
Mar 22, 2009, 08:15 AM
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.

eddietr
Mar 22, 2009, 02:23 PM
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.