Results 1 to 6 of 6

Thread: GDB and QT : Debugging woes

  1. #1

    Default GDB and QT : Debugging woes

    My Qt program crashes when executing a particular use case. When trying to debug, I encounter the following problem.

    I am receiving a SIGSEGV when calling a function called addContacts which is found in the file ContactsForm.cpp.

    But the GDB bedugger shows that the segfault is happening in this function addContacts but the file listed is c++/bits/char_traits.h.

    I cannot understand why GDB is reporting an erraneous listing.


    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread -1208564032 (LWP 21061)]
    0x0807cb28 in ContactsForm::addContacts (this=0x91d1730)
    at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/char_traits.h:258
    258 { return strlen(__s); }
    (gdb) bt
    #0 0x0807cb28 in ContactsForm::addContacts (this=0x91d1730)
    at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/char_traits.h:258
    #1 0x0807d6e6 in ContactsForm::showEvent (this=0x91d1730, event=0xbfef98d0)
    at Contacts/ContactsForm.cpp:38
    #2 0x00566955 in QWidget::event (this=0x91d1730, event=0xbfef98d0)
    at kernel/qwidget.cpp:8251

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: GDB and QT : Debugging woes

    Looks awfully like you are passing a NULL or otherwise invalid pointer that ends up in the strlen function. Single step your code to see which line is triggering the death.

  3. #3

    Default Re: GDB and QT : Debugging woes

    the problem is that after setting the break point to the addContacts functions, the debugger breaks . and then when i do next in gdb, it does not step through the code in my file (contactsForm.cpp). instead i see code listing of the std_traits.h . the listing that debugger gives when issuing an "l" command also returns code from the std_traits.h file.

  4. #4
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: GDB and QT : Debugging woes

    You should not do a next. You should step into the function and see what is happening.

  5. #5

    Default Re: GDB and QT : Debugging woes

    hi all




    please find the attached png image for more idea on the problem

    when setting a break point to the function showHoldLines, the breakpoint is set in the correct file.

    while setting a break point to the function fn_1, the break point is set in the incorrect file.

    i see this problem in most of the functions that use STL containers.

    anybody knows what is happening.

    thanks and regards.
    B

  6. #6
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: GDB and QT : Debugging woes

    The listing may, in fact, not be erroneous. The functions that you talk about are trivial, with little content. fn_1 doesn't actually do anything - it declares something that isn't used. The compiler may be inlining functions and simplifying the code because it can, even with little or no optimization turned on. Many compilers can and will do this even without the inline keyword. When this happens, the symbol information for the method that gets inlined can be lost - there's nothing left of "your" code. (This is actually a difficult problem for debugger writers - which I was many lifetimes ago.) In these cases, the debugger is showing the sources for the code that remains in the generated stream of instructions that implement your program.

Similar Threads

  1. Replies: 3
    Last Post: 6th September 2010, 23:00
  2. Eclipse woes
    By Petr_Kropotkin in forum Qt-based Software
    Replies: 1
    Last Post: 10th February 2010, 16:40
  3. Layout woes
    By hgiese in forum Qt Programming
    Replies: 2
    Last Post: 3rd September 2009, 20:29
  4. More SQLite Woes and onFocus Woes
    By morraine in forum Newbie
    Replies: 1
    Last Post: 13th August 2008, 13:14
  5. QGridLayout woes
    By para in forum Newbie
    Replies: 3
    Last Post: 16th October 2006, 22:41

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.