Building GDB 7.3.92 with MinGW

asmwarrior asmwarrior@gmail.com
Wed Jan 11 00:37:00 GMT 2012


On 2012-1-11 5:23, Doug Evans wrote:
> For one, remembering to pass -data-directory is a pain.

This parameter does not work correctly under MinGW in the case that I would like gdb to automatically run the python script when it startup.

Normally, my gdb is put in MinGW/bin, and the gdb's own python script is under:
MinGW\share\gdb\python\gdb\*.py

I need to hard-code the code in gdb/main.c to set the data-directory value. (Because gdb is build from MSYS+MinGW, but it run normally on Windows shell without MSYS)

Here are some hard-code modify to the main.c file, if you do not change this, there is no way to load gdb's own python scripts.

diff --git a/gdb/main.c b/gdb/main.c
index 8b45c25..46b11a8 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -42,6 +42,10 @@
  #include "python/python.h"
  #include "objfiles.h"
  
+#ifdef _WIN32
+extern int get_app_fullpath(char *location, int length);
+#endif
+
  /* The selected interpreter.  This will be used as a set command
     variable, so it should always be malloc'ed - since
     do_setshow_command will free it.  */
@@ -355,8 +359,27 @@ captured_main (void *data)
    debug_file_directory = relocate_gdb_directory (DEBUGDIR,
  						 DEBUGDIR_RELOCATABLE);
  
+
+#ifdef _WIN32
+  {
+    char location[500];
+    int len= get_app_fullpath(location, sizeof (location));
+    if (len == 0 || len > 500 - 1)
+      gdb_datadir = relocate_gdb_directory (GDB_DATADIR,GDB_DATADIR_RELOCATABLE);
+    else
+    {
+        char *p_slash =strrchr(location,'\\');
+        *p_slash = '\000';
+        p_slash =strrchr(location,'\\'); /* remove the bin folder*/
+        *p_slash = '\000';
+        strcat(location,"\\share\\gdb");
+        gdb_datadir = xstrdup (location);
+    }
+  }
+#else
    gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
-					GDB_DATADIR_RELOCATABLE);
+					GDB_DATADIR_RELOCATABLE);
+#endif
  
  #ifdef WITH_PYTHON_PATH
    {

If I remember correctly, I have post it some months ago.

asmwarrior
ollydbg from codeblocks' forum



More information about the Gdb-patches mailing list