Results 1 to 5 of 5

Thread: How to determine build configuration?

  1. #1
    Join Date
    Jan 2006
    Location
    Sofia, Bulgaria
    Posts
    24
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default How to determine build configuration?

    Hi there,
    I am wondering is there any way to determine if "CONFIG+=DEBUG" was specified in qmke-generated makefile?
    Here's the problem:
    when I compile an application in Debug mode, i want to print stack trace under some circumstances, but when compiling in release, those stacktraces are useless and only bloat the output. Is there any way to make the following code working w/o defining N_DEBUG?
    Qt Code:
    1. void bt_sighandler(int sig, siginfo_t *info,
    2. void *secret)
    3. {
    4.  
    5. #ifdef N_DEBUG
    6. void *trace[ trace_max_size ];
    7. char **messages = (char **)NULL;
    8. int i, trace_size = 0;
    9. ucontext_t *uc = (ucontext_t *)secret;
    10.  
    11. // Do something useful with siginfo_t
    12. if (sig == SIGSEGV)
    13. printf("******* SEGMENTATION FAULT *******, faulty address is %p, "
    14. "from %p\n", info->si_addr,
    15. uc->uc_mcontext.gregs[REG_EIP]);
    16.  
    17. trace_size = backtrace(trace, trace_max_size );
    18. // overwrite sigaction with caller's address
    19. trace[1] = (void *) uc->uc_mcontext.gregs[REG_EIP];
    20.  
    21. messages = backtrace_symbols(trace, trace_size);
    22. // skip first stack frame (points here)
    23. printf("[***] Execution path:\n");
    24. for (i=1; i<trace_size; ++i)
    25. printf("[%3d] %s\n", trace_size - i, messages[i]);
    26. free( messages );
    27. #else
    28. printf( "[***] Backtrace not supported when compiled without N_DEBUG defined\n" );
    29. #endif
    30. }
    To copy to clipboard, switch view to plain text mode 

  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 determine build configuration?

    Add such entry to your .pro file:

    debug{
    DEFINES+=MY_DEBUG
    }
    release{
    DEFINES+=MY_RELEASE
    }
    This will define MY_DEBUG for a debug build and MY_RELEASE for a release one. I'm sure Qt has its own define somewhere, you can look for it in a place where qDebug() is defined, as Qt only uses qDebug when in debug mode.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to determine build configuration?

    I have a related problem, Qt4.1.0 GPL, winxp, mingw, Dev-C++:
    I built qt witih debug libs.
    I made sure no QT_NO_DEBUG_OUTPUT is lurking in my makefile or pro file.
    My pro file produces both realse and debug build of my prooject.
    However, no output to the console seen, any idea what I can check in addition to the above?
    Here is my test porgram, none of the output lines are seen on the console:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. MainDlg *mainDlg = new MainDlg;
    5. mainDlg->show();
    6. std::cout<<"cout test"<<std::endl;
    7. printf("printf test");
    8. qDebug("qdebug test"); //none of the output lines shows on the console
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    and I am sure the build is a "fresh" one, accourding to the file dates, and also by the fact that I see the changes on the GUI, so its not a case of "changes not updated".
    Last edited by high_flyer; 1st February 2006 at 12:57.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to determine build configuration?

    Try adding "CONFIG += console" to your .pro file.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to determine build configuration?

    Thanks, that was it!

Similar Threads

  1. Qt + Linux + Eclipse - debug using debug build?
    By will49 in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2012, 06:27
  2. QWT fails in debug build
    By steg90 in forum Qwt
    Replies: 1
    Last Post: 11th November 2011, 06:53
  3. Build error on mac Platform::WaitMouseMoved
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2007, 13:18

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.