This is the mail archive of the insight@sourceware.org mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Single-executable patch


It seems, all three of the gdb, gdbtui, and insight executables are the same 
except for their (tiny) main() functions.

The attached sample patch allows to install just the gdb and link it to gdbtui 
and insight -- the program will behave differently depending on the name, 
under which it is invoked.

This saves not only the disk space (3.2Mb per executable here on FreeBSD/amd64 
despite using shared -ltcl, -ltk, -litcl, and -litk), but the more precious 
RAM at runtime too -- when different users run different interfaces on a 
shared system, the OS will be able to efficiently share the read-only pages 
between them.

Yours,

	-mi
--- gdb/gdb.c	Thu Feb 13 13:07:24 2003
+++ gdb/gdb.c	Wed May 17 00:24:39 2006
@@ -23,4 +23,5 @@
 #include "gdb_string.h"
 #include "interps.h"
+#include <libgen.h>
 
 int
@@ -31,6 +32,14 @@
   args.argc = argc;
   args.argv = argv;
-  args.use_windows = 0;
-  args.interpreter_p = INTERP_CONSOLE;
+  if (strncmp(basename(argv[0]), "insight", 7) == 0) {
+    args.use_windows = 1;
+    args.interpreter_p = "insight";
+  } else if (strncmp(basename(argv[0]), "gdbtui", 6) == 0) {
+    args.use_windows = 0;
+    args.interpreter_p = INTERP_TUI;
+  } else {
+    args.use_windows = 0;
+    args.interpreter_p = INTERP_CONSOLE;
+  }
   return gdb_main (&args);
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]