This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Single-executable patch
- From: Mikhail Teterin <mi+mx at aldan dot algebra dot com>
- To: insight at sourceware dot org, gdb-patches at sources dot redhat dot com
- Date: Wed, 17 May 2006 15:02:18 -0400
- Subject: Single-executable patch
- References: <200605162201.33772.mi+mx@aldan.algebra.com> <200605171415.24053.mi+mx@aldan.algebra.com> <446B6AE7.7030200@redhat.com>
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);
}