Results 1 to 20 of 26

Thread: How to debug with dbg in this case?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to debug with dbg in this case?

    Quote Originally Posted by vql View Post
    How to break at the line which output this warning?
    Search where the warning comes from and set a breakpoint there. break <filename:linenum> or break <filename:function>... Refer to the manual of gdb for more info.
    J-P Nurmi

  2. #2
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to debug with dbg in this case?

    Sorry, the warning output from file Coin library in Linux (.o), not in source .cpp. Please help me.

  3. #3
    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 debug with dbg in this case?

    Quote Originally Posted by vql View Post
    Sorry, the warning output from file Coin library in Linux (.o), not in source .cpp. Please help me.
    Could you post the exact error message?

  4. #4
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to debug with dbg in this case?

    Ok. Because my program is very big, I can't manage errors from my program.
    I'm programming with Coin.
    I declare a SbBox2f (a, b). Because there are problems about computing, so a & b can negative. If I use this SbBox2f, class SbBox2f (of Coin library) output warning : "Coin warning in SbBox2f::setBounds(): The bound will give the box negative area."

    This warning is very dangerous, it cause my program will not run exactly.
    Do you know in my program, there are alot places where I declare SbBox2f as above?

    How to I know, I have the problem at which line?
    Thanks.

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

    Default Re: How to debug with dbg in this case?

    Set a breakpoint on SbBox2f::setBounds in the debugger and check each call for negative values. When you encounter them, simply display the backtrace and you'll know where it happens.

  6. #6
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to debug with dbg in this case?

    I have problem about command break (set breakpoint) of gdb.

    If I have functions:
    void MyClass::test1(QString){ //... }
    void MyClass::test2(const QString&){ //... }

    When I set breakpoint on test1: break MyClass::test1(QString), it effect.
    But when I set breakpoint on test2: break MyClass::test2(const QString&), it doesn't effect.

    Thanks.

  7. #7
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to debug with dbg in this case?

    I tried to break on QString ( const QString & other ).
    Qt Code:
    1. gdb ./myapp
    2. break QString::QString (const QString &)
    3. run
    To copy to clipboard, switch view to plain text mode 
    It can't break on this function (specially on functions have parameter contain keyword const).

    Please help me. Thanks.

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

    Default Re: How to debug with dbg in this case?

    How about just "break QString::QString"? Or "break QString::QString(const QString&)" (without the space) ?

    You can enter "break QString::" and press the tab key to get a list of all methods defined for QString. You can then find the one you seek.
    Last edited by wysota; 8th February 2007 at 12:05.

  9. #9
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to debug with dbg in this case?

    How to gdb know functions of QString because QString in Qt's library? So I think in this case, if press Tab, it can't list of all methods defined for QString.

    Why do you try to break on QString::QString(const QString&) in examples?

    Try it & help me.

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

    Default Re: How to debug with dbg in this case?

    Quote Originally Posted by vql View Post
    How to gdb know functions of QString because QString in Qt's library?
    GDB knows how to resolve symbols from the binary it controls and its dependencies.

    So I think in this case, if press Tab, it can't list of all methods defined for QString.
    You can list methods which are actually seen (used) by your application.

    Why do you try to break on QString::QString(const QString&) in examples?
    I think the question is why do you try to do it...

  11. #11
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to debug with dbg in this case?

    You answered:
    Set a breakpoint on SbBox2f::setBounds in the debugger and check each call for negative values. When you encounter them, simply display the backtrace and you'll know where it happens.
    I tried break on SbBox2f::setBound(const SbVec2f&, const SbVec2f&) but it not effect.

    Because I think Coin or Qt, they're the same. So I tried on Qt' library with QString.
    I tried on QString::QString(QChar), it have effect.
    But I tried on QString::QString(const QString&), it don't have effect.

    Can you answer this question, wysota??? Please try on your computer before anwer. Thanks.

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

    Default Re: How to debug with dbg in this case?

    Quote Originally Posted by vql View Post
    I tried break on SbBox2f::setBound(const SbVec2f&, const SbVec2f&) but it not effect.
    Do you use that method in your app? If not (which means that it is used internally), do you have a debug version of libraries you use compiled? You have to compile in debug mode and link with debug libraries to have access to all symbols from within the debugger.

    I tried on QString::QString(QChar), it have effect.
    But I tried on QString::QString(const QString&), it don't have effect.

    Can you answer this question, wysota??? Please try on your computer before anwer. Thanks.
    As I already said, you don't have access to QString::QString(const QString&) because you don't use it in your application.

    Try debugging this one:
    Qt Code:
    1. #include <QString>
    2. int main(){
    3. QString x ="xxx";
    4. QString y(x); // here the copy constructor is used
    5. return 0;
    6. }
    To copy to clipboard, switch view to plain text mode 

    You'll notice that QString::QString(const QString &) will be among symbols available (remember to compile your app in debug mode). If you don't have a debug version of Qt compiled (and linked to the application), you'll only receive symbols defined for your executable and used by it.
    Qt Code:
    1. (gdb) break QString<tab>
    2. QString QString::QString(char const*)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. qmake and debug output
    By mattie in forum Qt Programming
    Replies: 7
    Last Post: 18th September 2006, 22:33
  2. Unable to execute in Debug Mode
    By Kapil in forum Installation and Deployment
    Replies: 38
    Last Post: 5th April 2006, 07:27
  3. Replies: 11
    Last Post: 22nd March 2006, 19:06
  4. QTextCursor - setTextColor()
    By Dalamar in forum Newbie
    Replies: 0
    Last Post: 20th February 2006, 18:34
  5. TIP: If Qt4.1 debug compile doesn't work...
    By pthomas in forum Newbie
    Replies: 3
    Last Post: 13th January 2006, 14:36

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
  •  
Qt is a trademark of The Qt Company.