Results 1 to 7 of 7

Thread: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

  1. #1
    Join Date
    Oct 2009
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    Hello,
    The Qt doc (http://doc.trolltech.com/4.5/debug.html) says that to debug the Qt libraries I need to set DYLD_IMAGE_SUFFIX=_debug. The examples show I need to basically invoke gdb from the command line adding this environment variable in front of the invocation to get it to work.

    Is there any way to do this so that I can debug from Creator without starting a terminal session of gdb?

    I tried creating a gdb startup script and putting:

    shell DYLD_IMAGE_SUFFIX=_debug

    into it but this didn't work. Seems like this is a good candidate for a checkbox in the Creator debugger prefs? Or am I missing something here?

    Thanks,
    Brett

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    You can set the variable while invoking creator or you can make a bash script that you will set as debugger executable. In the script invoke gdb while setting the environment variable you need.

    bash Code:
    1. #!/bin/bash
    2.  
    3. DYLD_IMAGE_SUFFIX=_debug /usr/bin/gdb $@
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2009
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    Thanks for your reply.

    If I make a bash script as you suggest, how do I set it as the debugger executable?

    Thanks,
    Brett

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    Quote Originally Posted by bibbinator View Post
    If I make a bash script as you suggest, how do I set it as the debugger executable?
    What do you mean? There are settings in QtCreator for that...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2009
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    I'm not sure which/where you mean though. Are you saying I change the field "Gdb location" in the debugging preferences that point to the script you mentioned? Or is there somewhere else to specify it?

    Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    Yes, that's exactly what I mean.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    bibbinator (19th October 2009)

  8. #7
    Join Date
    Oct 2009
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to set DYLD_IMAGE_SUFFIX=_debug in Mac?

    Thanks again for your continued help wysota, I managed to get it working. Some step-by-step info in case other people end up here with the same question.

    1. Create a script with the lines from wysota:

    #!/bin/bash
    DYLD_IMAGE_SUFFIX=_debug /usr/bin/gdb $@

    2. Save the file. Can be named anything, but the Mac OS X convention seems to be using ".command" as the file extension to have it show up as a terminal script. So I called mine GdbWithQtDebug.command for example.

    3. Open terminal and navigate to the same directory as the file. Type "ls" (without quotes) to see where you are now, and use "cd <directory name you want to switch>" (without quotes and <>) to move to a sub-directory.

    4. Once you're in the right directory, type "chmod 755 <your script name>" (without quotes and <>) to make it executable. If you don't do this, you will get errors that it can't be run.

    5. Launch QtCreator and open the preferences dialog. Expand the debugger section and click on the "Gdb" entry. In the right pane, where it says "Gdb location:" click the Choose... button and choose the script you just created. Click OK to save the changes.

    6. Go to the Build menu and under Set Build Configuration you should choose Debug so that you can debug both your code and Qt.

    7. Rebuild if needed and then debug.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.