09-09-2013, 06:09 PM | #1 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
using gdb on a PocketBook device
I figured out how to partially debug an application on a PocketBook device, so I thought I'd outline the steps here in case others find it useful.
Firstly, I tried running gdb on the device within a utelnetd session, but was unable to pass commands to it. gdb uses ncurses to handle input, and I suspect that that just doesn't work without a proper terminal. So, I went with using gdbserver on the device, and then doing the debugging on another machine over WiFi. The following are the steps required to get that working: 1) You need a computer that can run and debug ARM binaries. I used LoneTech's old qemu disk image and ran it on my desktop. The link is available within an old message here: https://www.mobileread.com/forums/sho...18&postcount=1. Alternatively, you can install a fresh Debian Lenny armel system within qemu, and then install the PocketBook arm-none-linux-gnueabi libraries within it. 2) Install gdb and libreadline5 within the ARM system. I just grabbed the packages from the Debian Lenny armel website and installed them with dpkg. 3) Copy /usr/bin/gdbserver from the ARM system to the PocketBook device. If you have networking enabled within the ARM system, you can scp the file to your desktop, and then copy it to the PocketBook device from there. In my case, my ARM system is setup to only talk to the host via the bridging network. The default setup for that is that the host is at address 10.0.2.2. Within my LAN, my host has the address 192.168.1.20, and the PocketBook device is at 192.168.1.160. As an example, I'm going to describe debugging the pbterm program. The pbterm.app and pbterm.cfg files need to be copied to the ereader in /mnt/ext1/applications/. The source code and debuggable version of pbterm should be copied to the ARM system, as well. 4) Get a shell on the ereader (I use utelnetd) and run gdbserver on it, specifying the IP address of the machine that will be allowed to access it, as well as the port number. Because my ARM system is running under bridged networking, I specify the IP address of my host: > cd /mnt/ext1/applications/ > /mnt/ext1/bin/gdbserver 192.168.1.20:1234 ./pbterm.app 5) Within the ARM system, you need to run the pbterm.app executable within gdb. You'll probably have to add the location of the PocketBook libraries to your LD_LIBRARY_PATH environmental variable if they aren't in one of the default system locations. Within LoneTech's image, they are at /root/pbroot/ebrmain/lib/. The pbterm sources and executable are within the pbterm-1.2.1-debug.tar.gz file: > tar zxf pbterm-1.2.1-debug.tar.gz > cd pbterm-1.2.1-debug > export LD_LIBRARY_PATH=/root/pbroot/ebrmain/lib 6) Check that the application can see the pocketbook libraries: > ldd ./pbterm.app should show no missing dynamic libraries in the list. 7) Within gdb, you need to set the location of the pbterm source files, and also the location of the remote gdbserver. For pbterm, the source files are in the src/ directory: > gdb pbterm.app gdb> dir src gdb> target remote 192.168.1.160:1234 gdb> continue The application will then run on the ereader, and the results can be seen on the ARM system. You can set breakpoints before the continue statement. For example, gdb> break Term::get_shell_output I hope this information helps some debug their applications. |
04-08-2014, 01:30 PM | #2 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
I just discovered today that gdb runs fine within the pbterm application. So, if you can use pbterm as your commandline interface, then you don't need to do remote debugging via gdb.
You need to install gdb, libncurses.so.5 and libreadline.so.5 from the debian lenny armel distribution. Install gdb to /mnt/ext1/system/bin. Install the two libraries to /mnt/ext1/system/lib. Then within pbterm on the device: export LD_LIBRARY_PATH=/mnt/ext1/system/lib export PATH=/mnt/ext1/system/bin:$PATH gdb <program-path> You can use the multi-task menu on the device to switch between pbterm and the application if necessary. I've provided the gdb binary and the two libraries that I copied from the debian lenny armel distribution as an attachment. Sources for those are available in the debian archives. |
Advert | |
|
04-13-2015, 05:17 PM | #3 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
One last tidbit: if you want to use gdb with the utelnetd or sshd terminals to just get a simple stack trace at a crash, you can redirect the commands to gdb rather than trying to type them at the prompt (which doesn't work). For example, using a here document (i.e. "<<"):
Code:
gdb <program-name> <<EOD run [arguments-to-program] where quit EOD You can also copy the gdb commands into a file, say gdb.txt, and then redirect those to gdb through standard input: Code:
gdb <program-name> <gdb.txt |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PocketBook 902 as external device | csint | PocketBook Developer's Corner | 1 | 10-21-2012 05:33 AM |
calibre 0.8.2 Linux - PocketBook 701 and Android device not detected | HelliH | Devices | 6 | 05-25-2011 01:59 PM |
PocketBook announces Mirasol display ebook reader/device | Dulin's Books | News | 0 | 11-24-2010 10:47 AM |
quality doubts about device & service Pocketbook Germany | franklekens | PocketBook | 37 | 09-08-2010 03:05 AM |
iLiad Gdb in Irex Iliad | cesarlr | iRex Developer's Corner | 0 | 02-16-2010 05:25 AM |