gdb question(s)


Results 1 to 12 of 12

Thread: gdb question(s)

  1. #1
    Join Date
    Mar 2004
    Posts
    23

    gdb question(s)

    I'm trying to start programing, any tutorial sites (C, C++, I already 'know' BASIC) would be greatly appreciated, and I just found out about gdb, I was trying to figure out how to use it to debug mplayer or xmms but I think mplayer is in ELF format (at the begining of the file it has ELF), but I know it is compiled, because the vast majority is shown as garbage in emacs
    Code:
    ^@ELF^A^B^@^@^@^A^B
    Anyways, I couldn't seem to be able to figure out how to get gdb to run mplayer or xmms. So if someone could tell me how to do that I'd be really greatful.
    P.S. Not that this matters(?) but the error msg I'm getting is a 'Segmentation fault' and that's all that is displayed...
    Code:
    # /usr/bin/mplayer
    Segmentation fault
    #
    Ask Questions the Smart Way
    Gentoo is my life and gentoos are kinda cute....I want a penguin...
    ***Warning you are about to unleash the Penguin!****
    Do you wish to continue?
    Code:
     emerge life
    Error : user does not conform to "Social Standards"
    O.o ....

  2. #2
    Join Date
    Aug 2002
    Location
    Delaware
    Posts
    4,285
    gdb mplayer
    (gdb) bt
    irc.freenode.net #justlinux The Not So Official JL IRC Channel.
    ¤ Debian ¤ Apt-Get ¤

  3. #3
    Join Date
    Nov 2003
    Posts
    90
    first off, for gdb to work, the code has to be compiled with symbols in the code

    for C -
    Code:
    gcc -g myprog.c -o myprog
    gdb myprog
    Most production code is not compiled debug, so trying use gdb on mplayer, for example, may not work.

    If you go go www.gnu.org and www.sourceforge.net you will find source code for most of the programs, utilities etc., that are part of linux, or are used in the unix environment. All of the source is free.

  4. #4
    Join Date
    Jan 2004
    Posts
    407
    jim is right, you'll want to compile xmms/mplayer w/ -g in your CFLAGS and LDFLAGS if you want to see source code instead of asm when running in gdb.

    'ulimit -c unlimited' will make it so you get core dumps if something segfaults

    to check what happened in an already crashed app you would do

    gdb <app> <corefile> (the core file is prolly just 'core')

    then bt for a backtrace, gdb can do a _lot_ more then that though, check google for gdb tutorials, and check gnu's site, they have some good documentation IIRC.

    also 'help' in gdb is quite useful as a reference, but definitaly not to learn gdb in the beginning, it assumes you already know a bit about debugging, and gdb for that instance

    if you want to just run something from inside gdb, you can

    gdb <the_program>
    r

    EDIT:

    i just noticed you mentioned emacs, gdb integrates w/ emacs very well from what i have read, so you may wanna check up on that too
    DISCLAIMER: sometimes i use a text browser, so I may not see any emoticons directed at me.

    Brandon Niemczyk <bniemczyk@snprogramming.com>
    http://bniemczyk.is-a-geek.com

  5. #5
    Join Date
    Mar 2004
    Posts
    23

    make debuging

    I don't know how to really use gcc, however the readme for mplayer says to use make and make install, and I get a long list of errors when I run
    Code:
    # gcc -g ./mplayer.c -o mplayer
    So I looked at the man page for make, the gnu.org documentation for make and I seem to be missing the option to pass -g to gcc...if that can even be done using make?
    Ask Questions the Smart Way
    Gentoo is my life and gentoos are kinda cute....I want a penguin...
    ***Warning you are about to unleash the Penguin!****
    Do you wish to continue?
    Code:
     emerge life
    Error : user does not conform to "Social Standards"
    O.o ....

  6. #6
    Join Date
    Apr 2002
    Posts
    259
    There may be a switch to enable debugging from the configure script, try `./configure --help' and see if you see anything.

    Or, configure should pickup the CFLAGS variable, so do the following before running configure.

    export CFLAGS="$CFLAGS -g"
    OggVorbis gets mobile...
    http://www.gentoo.org
    Is that a penquin in your pocket or are you just happy to see me?

  7. #7
    Join Date
    Mar 2004
    Posts
    23

    Thanks to all

    Thank you, thank you all! x_Ray you were right about there being a switch to enable debuging from ./configure
    Don't know if this'll solve my problems yet, I fell back to mplayer-0.92 since the security threat isn't present in anything <=0.92, however the seg fault still happened. I'm begining to think about falling back to an older version of gcc to see if that's the real problem...I think I'll be able to figure things out from here though.
    Again thanks to all who helped.
    [EDIT]I'm not sure, but I think the seg fault may be linked to linux-gate.so.1 or ld-linux.so.2 Because
    Code:
    $ ldd /usr/bin/mplayer
            linux-gate.so.1 =>  (0xffffe000)
            libgtk-1.2.so.0 => /usr/lib/libgtk-1.2.so.0 (0x403aa000)
           /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    those two things are the closest to the 0x00000000 that gdb says it segfaults at.
    Code:
    Program received signal SIGSEGV, Segmentation fault.
    0x00000000 in ?? ()
    (gdb) bt
    #0  0x00000000 in ?? ()
    #1  0x407984e5 in ?? ()
    #2  0x00004ca3 in ?? ()
    #3  0x410b9440 in ?? ()
    #4  0x406d31fa in ?? ()
    #5  0x406fc138 in ?? ()
    #6  0x406d3478 in ?? ()
    #7  0x00000000 in ?? ()
    #8  0x406f1720 in ?? ()
    #9  0x406d346e in ?? ()
    #10 0x410b9440 in ?? ()
    #11 0x00004ca3 in ?? ()
    #12 0x4001455c in ?? ()
    #13 0x40591778 in ?? ()
    #14 0x40014790 in ?? ()
    #15 0xbffff2e4 in ?? ()
    #16 0x40a698cc in ?? ()
    #17 0x4000b330 in ?? ()
    #18 0x00000002 in ?? ()
    #19 0xbffff334 in ?? ()
    #20 0xbffff340 in ?? ()
    #21 0x00000000 in ?? ()
    #22 0x00000000 in ?? ()
    Last edited by DAudioLink@Sch; 06-11-2004 at 10:31 AM.
    Ask Questions the Smart Way
    Gentoo is my life and gentoos are kinda cute....I want a penguin...
    ***Warning you are about to unleash the Penguin!****
    Do you wish to continue?
    Code:
     emerge life
    Error : user does not conform to "Social Standards"
    O.o ....

  8. #8
    Join Date
    Jan 2004
    Posts
    407
    it's calling some (undefined?) function. That doesn't look like it was built w/ debugging symbols, but there are a few routes that could cause a backtrace like that. One of which is calling a function pointer that is still NULL.

    make sure you have -g in LDFLAGS as well as CFLAGS, and if it uses any C++ CXXFLAGS. Then check a backtrace and goto the latest function that it calls successfully and start looking from there.
    DISCLAIMER: sometimes i use a text browser, so I may not see any emoticons directed at me.

    Brandon Niemczyk <bniemczyk@snprogramming.com>
    http://bniemczyk.is-a-geek.com

  9. #9
    Join Date
    Nov 2003
    Posts
    90
    I could also be a NULL pointer to some variable, but it looks like a function pointer is aimed nowhere.

    In either case, this is likely to be a plain old-fashioned bug. It probably has very little to do with how things are compiled, it might remotely be a link problem.

  10. #10
    Join Date
    Mar 2004
    Posts
    23

    Think I've got it

    Don't hold me to these words, but I think I might have it figured out. I came to this conclusion after I realized all of my GUI games that used OpenGL had seg faults, I tested it,
    Code:
     $ ldd mplayer > ./Desktop/ldd.txt && ldd xmms > ./Desktop/ldd1.txt && \
    ldd /usr/games/bin/gl-117 > ./Desktop/ldd2.txt
     $ diff3 ./Desktop/ldd.txt ./Desktop/ldd1.txt ./Desktop/ldd2.txt | grep GL
    I saw nothing. So I'm thinking that this has something to do with opengl, I don't know what exactly, but right before I started running into these problems I changed the xfree drivers for my nVidia card from "nvidia" to "nv". I'm going to either [list=1][*]Change the driver back to "nvidia"[*]emerge the mplayer and xmms again with out opengl support.[/list=1]
    I'll figure out how to get my games back if I'm still forced to use the "nv" driver for X to work.
    Thanks for the help, once more, possibly not the last time either...
    Ask Questions the Smart Way
    Gentoo is my life and gentoos are kinda cute....I want a penguin...
    ***Warning you are about to unleash the Penguin!****
    Do you wish to continue?
    Code:
     emerge life
    Error : user does not conform to "Social Standards"
    O.o ....

  11. #11
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    If you still get segfaults in the OpenGL library after changing back, there is a section in the nVidia README (in the FAQ) about that issue.

  12. #12
    Join Date
    Mar 2004
    Posts
    23

    fixed, but not fixed...

    Okay, mplayer works with the "vesa" driver for X, but the games don't. I am not very happy...but I don't need to be playing games anyways, gotta work on a tan for workcamp and band camp...and I could use some exersice anyways...
    Thread Closed
    (or would be if I could close it....)
    Ask Questions the Smart Way
    Gentoo is my life and gentoos are kinda cute....I want a penguin...
    ***Warning you are about to unleash the Penguin!****
    Do you wish to continue?
    Code:
     emerge life
    Error : user does not conform to "Social Standards"
    O.o ....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •