Category Archives: Debug

Compiling GDB Debugger in Windows

Here are the steps:

  1. Download 7-zip, if you do not have one.
  2. Install MinGW, please read MinGW’s Getting Started wiki. I choose manual installation:

    Download at least the following (or newer) packages from the MinGW download page:

    • binutils
    • gcc-core
    • mingw-runtime
    • w32api
    • expat

    Unpack them directly to D:\mingw

    GDB can use the Expat XML parsing library. This library may be included with your operating system distribution; if it is not, you can get the latest version from
    The `configure' script will search for this library in several standard locations; if it is installed in an unusual path, you can use the `–with-libexpat-prefix’ option to specify its location.

    Expat is used for:

    To download expat for MinGW, please visit here.

    For more about expat, please visit

  3. Install MinGW’s MSYS:
    • Install MSYS DTK 1.0 in D:\mingw\1.0
    • Install MSYS Core 1.0.11. It is an archive. Unpack it in D:\mingw\1.0
  4. Setting PATH and HOME environment, and run D:\mingw\1.0\msys.bat
  5. Download GDB debugger sources. I use the latest repository snapshot. And upack them to D:\mingw\1.0\home
  6. ./configure & make

You should have gdb.exe in D:\mingw\1.0\home\gdb-#.#.#\gdb\ in about 30 minutes.

To port GDB debugger to a new architecture, you should not miss the detailed guide ” Howto: Porting the GNU Debugger — Practical Experience with the OpenRISC 1000 Architecture “.


To compile GDB Insight 6.8 under MSYS environment, you should make a patch :

Index: gdb/ChangeLog
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.9174.2.20
diff -u -r1.9174.2.20 ChangeLog
— ChangeLog 31 Mar 2008 03:40:42 -0000 1.9174.2.20
+++ ChangeLog 11 Apr 2008 09:10:13 -0000
@@ -1,3 +1,8 @@
+2008-04-11 Hans Kester
+ * Added configdir for MinGW.
+ * configure: Added configdir for MinGW.
2008-03-30 Daniel Jacobowitz

* ia64-tdep.c (examine_prologue): Correct array access.

Index: gdb/
RCS file: /cvs/src/src/gdb/,v
retrieving revision 1.64
diff -u -r1.64
— 13 Jan 2008 12:23:05 -0000 1.64
+++ 11 Apr 2008 09:02:13 -0000
@@ -1445,7 +1445,7 @@

case “${host}” in
+*-*-cygwin* | *-*-mingw*)

Index: gdb/configure
RCS file: /cvs/src/src/gdb/configure,v
retrieving revision 1.242
diff -u -r1.242 configure
— configure 13 Jan 2008 12:23:04 -0000 1.242
+++ configure 11 Apr 2008 09:05:54 -0000
@@ -23080,7 +23080,7 @@

case “${host}” in
+*-*-cygwin* | *-*-mingw*)

Posted in C++, Debug | Tagged , , | 3 Comments

Debug into rt.jar

If you ever use Eclipse trying to debug into Java’s system APIs, such as java.lang.String or java.math.BigInteger, you may find that even you can step over or step in, or have the correct source file open and the correct line of codes highlighted, you still could not see the local variables’ value and method’s parameters are shown in pattern of “arg0”, “arg1” and so on.

Yes, you are already using JDK instead of JRE. But you still have the above problem. What’s wrong? It’s not a bug of Eclipse. It is all about the rt.jar along with the JDK (1.5 or 1.6). In Sun’s official JDK release, debug symbols are already packed into the rt.jar. But local variables’ debug information is not packed. Sun may consider that it is not OK to includes those local variables’ debugging information. That is the source of problem.

To solve this problem, you may need to upgrade to JDK 1.6. Download DEBUG jar file from
Double click it to install a new JDK. And configure your Eclipse to use the new JDK.

For JDK 1.5, recompiling rt.jar by yourself, or other information, please visit
for a detailed discussion.

Posted in Debug, Java | Comments Off on Debug into rt.jar