Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Single-executable patch
       [not found]   ` <446B6AE7.7030200@redhat.com>
@ 2006-05-17 19:03     ` Mikhail Teterin
  2006-05-17 19:28       ` Daniel Jacobowitz
  2006-05-17 21:35       ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Mikhail Teterin @ 2006-05-17 19:03 UTC (permalink / raw)
  To: insight, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

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

[-- Attachment #2: patch-unified --]
[-- Type: text/x-diff, Size: 661 bytes --]

--- 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);
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Single-executable patch
  2006-05-17 19:03     ` Single-executable patch Mikhail Teterin
@ 2006-05-17 19:28       ` Daniel Jacobowitz
  2006-05-17 19:35         ` Mikhail Teterin
  2006-05-17 21:35       ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2006-05-17 19:28 UTC (permalink / raw)
  To: Mikhail Teterin; +Cc: insight, gdb-patches

On Wed, May 17, 2006 at 03:02:18PM -0400, Mikhail Teterin wrote:
> 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.

This has been a world of trouble for other programs in the past, and I
do not recommend it; we switched to the separate main programs
deliberately IIRC.

If this is all you want, here's a simple implementation:

/usr/bin/gdbtui:
#!/usr/bin/gdb -i=tui

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Single-executable patch
  2006-05-17 19:28       ` Daniel Jacobowitz
@ 2006-05-17 19:35         ` Mikhail Teterin
  2006-05-17 20:23           ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Mikhail Teterin @ 2006-05-17 19:35 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: insight, gdb-patches

ц⌠ц┘ц▓ц┘ц└ц│ 17 ц■ц▓ц│ц≈ц┘ц▌ц≤ 2006 15:07, Daniel Jacobowitz ц▌ц│ц░ц┴ц⌠ц│ц≈:
> This has been a world of trouble for other programs in the past,

I wonder, what kind of trouble?

> and I do not recommend it; we switched to the separate main programs
> deliberately IIRC.

The current main() functions are almost "too simple" now -- may it be, that 
something like my patch is *no longer* troublesome?

> If this is all you want, here's a simple implementation:
>
> /usr/bin/gdbtui:
> #!/usr/bin/gdb -i=tui

Cool! I wonder, why even bother linking other executables... It would make 
sense to do it, if, for example, the gdb was not linking with Tcl and 
friends, but it does anyway...

Thanks!

	-mi


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Single-executable patch
  2006-05-17 19:35         ` Mikhail Teterin
@ 2006-05-17 20:23           ` Daniel Jacobowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2006-05-17 20:23 UTC (permalink / raw)
  To: Mikhail Teterin; +Cc: insight, gdb-patches

On Wed, May 17, 2006 at 03:27:35PM -0400, Mikhail Teterin wrote:
> ?????? 17 ??????? 2006 15:07, Daniel Jacobowitz ???????:
> > This has been a world of trouble for other programs in the past,
> 
> I wonder, what kind of trouble?

Portability.  There are many other platforms out there and many of them
are very strange...

> > If this is all you want, here's a simple implementation:
> >
> > /usr/bin/gdbtui:
> > #!/usr/bin/gdb -i=tui
> 
> Cool! I wonder, why even bother linking other executables... It would make 
> sense to do it, if, for example, the gdb was not linking with Tcl and 
> friends, but it does anyway...

It's easier if you only want one of them, and if you aren't installing
in fixed paths.  Portably locating the invoked shell script is also a
bit tricky.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Single-executable patch
  2006-05-17 19:03     ` Single-executable patch Mikhail Teterin
  2006-05-17 19:28       ` Daniel Jacobowitz
@ 2006-05-17 21:35       ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2006-05-17 21:35 UTC (permalink / raw)
  To: Mikhail Teterin; +Cc: insight, gdb-patches

> From: Mikhail Teterin <mi+mx@aldan.algebra.com>
> Date: Wed, 17 May 2006 15:02:18 -0400
> 
> 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 is against the GNU coding standards.  From standards.info:

    Please don't make the behavior of a utility depend on the name used to
    invoke it.  It is useful sometimes to make a link to a utility with a
    different name, and that should not change what it does.

       Instead, use a run time option or a compilation switch or both to
    select among the alternate behaviors.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-17 20:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200605162201.33772.mi+mx@aldan.algebra.com>
     [not found] ` <200605171415.24053.mi+mx@aldan.algebra.com>
     [not found]   ` <446B6AE7.7030200@redhat.com>
2006-05-17 19:03     ` Single-executable patch Mikhail Teterin
2006-05-17 19:28       ` Daniel Jacobowitz
2006-05-17 19:35         ` Mikhail Teterin
2006-05-17 20:23           ` Daniel Jacobowitz
2006-05-17 21:35       ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox