Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: necrostaz on August 17, 2009, 08:22:03 AM

Title: Debugging Rockbox with GDB and UI Simulator
Post by: necrostaz on August 17, 2009, 08:22:03 AM
Hi. I'm a newbie in debugging with GDB. Please explain me how to debug Rockbox code with GDB for some steps. I've tried to load rockboxui in gdb, but it was stopped. And i tried attach  to simulator process and set up break points, but gdb can't proceed my breaks(I think because target libraries was not loaded in that time) Thanks/
Title: Re: Debugging Rockbox with GDB and UI Simulator
Post by: dreamlayers on August 17, 2009, 10:29:41 AM
For me, GDB simply works in Cygwin.  I just run "gdb rockboxui.exe", set up breakpoints if necessary and then "run".  GDB has been very helpful when investigating some bugs.

If I try to set a breakpoint at a symbol that's not currently loaded, I am asked if I want to make it pending on shared library load.  I simply answer yes.  This can be used to create breakpoints in codecs and plugins.

Here's an example:
Code: [Select]
Boris@Vortex ~/rockbox-svn-trunk/5sim
$ gdb rockboxui.exe
GNU gdb (cygwin-special)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
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 "i686-pc-cygwin"...
(gdb) b flac_init
Function "flac_init" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (flac_init) pending.
(gdb) run
Starting program: /home/Boris/rockbox-svn-trunk/5sim/rockboxui.exe
[New thread 14916.0x2dcc]
[New thread 14916.0x3290]
[New thread 14916.0x2270]
[New thread 14916.0x14c4]
[New thread 14916.0x1874]
[New thread 14916.0x1340]
[New thread 14916.0x31d4]
[New thread 14916.0x21c0]
[New thread 14916.0x3b00]
[New thread 14916.0x9fc]
[New thread 14916.0x638]
[New thread 14916.0x2d88]
[New thread 14916.0x2bb0]
[New thread 14916.0x295c]
[New thread 14916.0x2548]
[New thread 14916.0x348c]
[New thread 14916.0x2f4]
[New thread 14916.0x1720]
[New thread 14916.0x3444]
[Switching to thread 14916.0x2bb0]

Breakpoint 1, flac_init (fc=0x75efca0, first_frame_offset=0)
    at /home/Boris/rockbox-svn-trunk/apps/codecs/flac.c:77
77          bool found_streaminfo=false;
(gdb) l
72      static size_t buff_size;
74      static bool flac_init(FLACContext* fc, int first_frame_offset)
75      {
76          unsigned char buf[255];
77          bool found_streaminfo=false;
78          uint32_t seekpoint_hi,seekpoint_lo;
79          uint32_t offset_hi,offset_lo;
80          uint16_t blocksize;
81          int endofmetadata=0;
(gdb) n
81          int endofmetadata=0;
84          ci->memset(fc,0,sizeof(FLACContext));
85          nseekpoints=0;
Title: Re: Debugging Rockbox with GDB and UI Simulator
Post by: necrostaz on August 17, 2009, 11:14:07 AM
Thanks a lot.   :) It works for me if i attach to process, but i can't run gbd run statically, because it exits. But no matter  :)