Saturday, April 4, 2009

Tips for debugging mediaserver

1. Add symbol file for dynamically loaded so, e.g.
(1) Find where the module was loaded:
#cat /proc/<pid>/maps
a7c26000-a7c52000 r-xp 00000000 1f:06 1060 /system/lib/libopencore_asfloca
a7c52000-a7c54000 rw-p 0002c000 1f:06 1060 /system/lib/libopencore_asfloca

(2) Get the text section's offset within the module:
$objdump --section-headers out/target/product/generic/symbols/system/lib/ |grep text
6 .text 0001679c 0000e3c8 0000e3c8 0000e3c8 2**3

(3) Add this offset to the load address of the module to obtain the relocation address for the module's code: (0xa7c26000+0x0000e3c8 = 0xa7c343c8)
(gdb)add-symbol-file out/target/product/generic/symbols/system/lib/ 0xa7c343c8

2. Switch between threads inside mediaserver process
(gdb) info threads
(gdb) thread <id>

[1]Debugging with GDB
[2]Debugging Loadable Modules Using GDB
[3]Debugging programs with multiple threads

No comments: