Page 1 of 1

lightsoff in gdb

PostPosted: Sep 18th, '11, 12:12
by marja
I don't yet manage to see how I can run lightsoff inside gdb. I only want to, because I want to learn more about how to get backtraces.
(It's a known bug https://bugs.mageia.org/show_bug.cgi?id=1078 and AL13N is already working on a patch)

Is the information I need in this line from lightsoff.strace:
Code: Select all
6447  execve("/usr/bin/env", ["/usr/bin/env", "seed", "/usr/share/gnome-games/lightsoff"...], [/* 80 vars */]) = 0
? 6447 was a child PID and the one that segfaulted. If this is the needed info, how do I use it with gdb?

Or was this information I need already in here:
Code: Select all
[marja@DenkBlok2 ~]$ lightsoff
/usr/bin/lightsoff: regel 4: 10694 Segmentatiefout         /usr/bin/env seed /usr/share/gnome-games/lightsoff/main.js
[marja@DenkBlok2 ~]$


BTW, I did install gnomes-games-debug

Code: Select all
[marja@DenkBlok2 ~]$ rpm -qf --qf "%{SOURCERPM}\n" /usr/bin/lightsoff | sed 's/-[^-]*-[^-]*$/-debug/'
gnome-games-debug
[marja@DenkBlok2 ~]$

Re: lightsoff in gdb

PostPosted: Sep 18th, '11, 12:31
by dubigrasu
I would try something like:
Code: Select all
gdb lightsoff
or eventually in the same directory where the executable is located:
Code: Select all
gdb ./lightsoff


at the gdb prompt type:
Code: Select all
run

and after the segfault type:
Code: Select all
backtrace full

Re: lightsoff in gdb

PostPosted: Sep 18th, '11, 15:36
by marja
Thx for answering, but I tried that before and that doesn't work:

Code: Select all
[marja@DenkBlok2 ~]$ gdb lightsoff
GNU gdb (GDB) 7.1-6.mga1 (Mageia release 1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-mageia-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
"/usr/bin/lightsoff": not in executable format: File format not recognized
(gdb) Quit


/usr/bin/lightsoff is a shellscript:
Code: Select all
#!/usr/bin/env sh

export LD_LIBRARY_PATH="/usr/lib64/gnome-games${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
/usr/bin/env seed /usr/share/gnome-games/lightsoff/main.js


and when you look in the folder /usr/share/gnome-games/lightsoff/ you see a lot of javascript files.

Re: lightsoff in gdb

PostPosted: Sep 18th, '11, 18:19
by doktor5000
Well lightsoff, as you have experienced, is no good start to learn using GDB :(

BTW: If you experience errors, and want to provide the error messages to someone else
trying to help you, it's generally best to run every command prefixed by LC_ALL=C.
This sets C locale, so every output will not be localised in you systems current locale (language)
but in english, which is easier or more helpful to developers.

Re: lightsoff in gdb

PostPosted: Sep 18th, '11, 19:57
by marja
2x thanks

I'm often not aware that it's better to stop trying something, so thanks for concluding that lightsoff isn't a good start to learn to use GDB. You're right!
And I wasn't aware that the code was partially in Dutch, I even had to edit another post twice today, because two seperate lines that I had written turned out to be in Dutch :o
I guess I was too much in a party mood because of Mageia's first birthday :lol:

Re: lightsoff in gdb

PostPosted: Sep 18th, '11, 20:54
by doktor5000
No problem for me :)

Re: lightsoff in gdb

PostPosted: Sep 19th, '11, 14:36
by doktor5000
Because i needed to use gdb myself now, actually for the first time, here's a good step-by-step guide to do this:
http://www.thegeekstuff.com/2010/03/deb ... using-gdb/
*hint* Look for the middle part of the headline of that page, see what i mean ;)

Re: lightsoff in gdb

PostPosted: Sep 20th, '11, 09:57
by marja
C Program

Apparently, the best way to start to know GDB, is try it on a program written in C

Here http://www.gnu.org/software/gdb/download/ANNOUNCEMENT I read GDB is a source-level debugger for Ada, C, C++, Objective-C,
Pascal and many other languages.

If it would be both possible and easy to use it on Java Script, I guess Java Script would be in the list.

Re: lightsoff in gdb

PostPosted: Sep 20th, '11, 10:25
by doktor5000
Exactly.
Maybe you want to try valgrind?

Re: lightsoff in gdb

PostPosted: Sep 20th, '11, 13:15
by marja
doktor5000 wrote:Maybe you want to try valgrind?


Good idea. Of course, I shouldn't start trying it with lightsoff, but I did anyway. At first I got this weird message
Code: Select all
valgrind Warning: Can't execute setuid/setgid executable:
that disappeared after I had changed the permissions for /usr/bin/lightsoff from 555 (that should have been enough permission, shouldn't it?) to 777. Later, when I changed them back to 555, the message didn't come back, Valgrind just kept working. It gives an enormous amount of output, though, so I couldn't scroll back to the beginning. Putting
Code: Select all
| less
behind the command string didn't work: the output disappeared the moment I tried to scroll through it.

And when I try
Code: Select all
valgrind -v --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --trace-children=yes ./lightsoff | tee /home/marja/valgrindlightsoff.txt
or
Code: Select all
valgrind -v --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --trace-children=yes ./lightsoff > /home/marja/valgrindlightsoff2.txt
I only create empty textfiles. :(

Re: lightsoff in gdb

PostPosted: Sep 20th, '11, 13:20
by marja
But putting 2 before > works!

Re: lightsoff in gdb

PostPosted: Sep 20th, '11, 13:23
by marja
Code: Select all
[marja@DenkBlok2 bin]$ valgrind -v --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --trace-children=yes ./lightsoff 2> /home/marja/valgrindlightsoff3.txt
[marja@DenkBlok2 bin]$


Now the file isn't empty anymore, but contains 84,516 lines of text :D