Is Something Wrong with My Program?

Discussion in 'Mac Programming' started by shusseina, Mar 21, 2009.

  1. shusseina macrumors newbie

    Feb 23, 2009
    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', process 15543.
  2. garethlewis2 macrumors 6502

    Dec 6, 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.
  3. shusseina thread starter macrumors newbie

    Feb 23, 2009
    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 ()
    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.
  4. eddietr macrumors 6502a

    Oct 29, 2006
    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.
  5. MrFusion macrumors 6502a

    Jun 8, 2005
    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.
  6. eddietr macrumors 6502a

    Oct 29, 2006
    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.

Share This Page