[PATCH] Add new function to access gdb_program_name.

Andrew Burgess aburgess@broadcom.com
Fri Sep 6 12:37:00 GMT 2013


The deprecated_init_ui_hook is used from gdbtk just to get hold
of gdb's argv[0].

We currently hold this in the variable gdb_program_name within
main.c, so adding a read only accessor function does not feel
unreasonable to me, and would allow gdbtk to stop using
deprecated_init_ui_hook.

What do you think?

Thanks,
Andrew

gdb/ChangeLog

2013-09-06  Andrew Burgess  <aburgess@broadcom.com>

	* main.h (get_gdb_program_name): Add declaration.
	* main.c (get_gdb_program_name): Add definition.

diff --git a/gdb/main.c b/gdb/main.c
index 11f4b03..3e0e1fe 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -98,6 +98,13 @@ int return_child_result_value = -1;
 /* GDB as it has been invoked from the command line (i.e. argv[0]).  */
 static char *gdb_program_name;
 
+/* Return read only pointer to GDB_PROGRAM_NAME.  */
+const char *
+get_gdb_program_name (void)
+{
+  return gdb_program_name;
+}
+
 static void print_gdb_help (struct ui_file *);
 
 /* Relocate a file or directory.  PROGNAME is the name by which gdb
diff --git a/gdb/main.h b/gdb/main.h
index a5260b1..a846d9f 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -42,4 +42,10 @@ extern int batch_flag;
    return value is in malloc'ed storage.  */
 extern char *windows_get_absolute_argv0 (const char *argv0);
 
+/* Return read only pointer to the name of gdb as it was invoked.  This
+   might have been expanded to an absolute path if required by the
+   platform.  Could return NULL if called before gdb has had a chance to
+   parse the argv array.  */
+extern const char * get_gdb_program_name (void);
+
 #endif



More information about the Gdb-patches mailing list