Experiences in Testing Android’s gdb Client

This article, which is a sequel from previous one, will describe post compilation testing, and how to resolve issues found during testing session.

After activating the gdbserver in the emulator, I’ve found a rather cryptic error (Malformed packet(b) (missing colon)) from gdb client as follow:


Cryptic or not, the fact is the compiled gdb client failed miserably on very first attempt. Seems that the server is of higher version than the client, as evident from the version query as follow:


In my D:\Projects\Android\toolchain\gdb toolchain, there’s a newer version called gdb-7.7, so let’s try to compile this version instead. Since compiling the gdb using NDK is a rather tedious and time consuming, why not perform direct compilation in the toolchain directory as follow:


Without any incidence, the makefile is created in D:\Projects\Android\toolchain\gdb\gdb-7.7. So, let’s execute make:


So, it fails at configuring stage and complains that expat is missing. Let’s perform compilation of expat lib as follow:


After configure is finished, run the make program, and libexpat.a will be found in the .libs directory. But the above problem still exist. By checking into the config.log file inside D:\Projects\Android\toolchain\gdb\gdb-7.7\gdb:


Based on failed program info provided by config.log, let’s creates the c file and re-run the compiler. This time, let’s also activates procmon.exe to provide info of where the compiler try to search the header file:


So, let’s copy the header files from expat toolchain to c:\mingw\include and recompile. We have:


Again, based on procmon.exe info, it tries to find libexpat.a, so let’s copy the compiled libexpat.a from toolchain to c:\mingw\lib. This time, the compile is a success. Let’s run the make program again:


Copy the compiled libbfd.lib to the bfd directory and rename it to libbfd.a, we have:


After this, there are no more incidents, and gdb.exe is now exist. At my machine, it is rather large, about 30 MB:


Now, let’s test for symbol file feature, which is crucial in a debugging session:


This stops by showing Reading symbols from hello…I’m sorry, Dave, I can’t do that error message. Seems there are some flaws at compiling phase, so let’s consult the config.log file for presence of flaw:


This is a similar issue with libexpat, so let’s repeat the above procedure for libbfd library and repeat configure and make. For repeat to be a success, delete first the config.cache and makefile file, also generated *.o and *.exe inside gdb directory. Since if those files exist, it will use cache, instead of newer one. After compilation is finished, let’s try again the symbol feature:


At last, this program is ready for some real world usage 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: