From 7c4ee702e070f2b8051bd440c9fd86bb7550e57d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 18 Aug 2016 12:06:33 -0300 Subject: [PATCH] eeshow/main.c: run under gdb if argv[1] is "gdb" I.e., instead of eeshow foo bar invoke with eeshow gdb foo bar --- eeshow/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/eeshow/main.c b/eeshow/main.c index c654d08..15fa8e7 100644 --- a/eeshow/main.c +++ b/eeshow/main.c @@ -50,6 +50,7 @@ void usage(const char *name) " %*s[-- driver_spec]\n" " %s [-v ...] -C [rev:]file\n" " %s [-v ...] -H path_into_repo\n" +" %s gdb ...\n" "\n" " rev git revision\n" " -r recurse into sub-sheets\n" @@ -57,6 +58,7 @@ void usage(const char *name) " -C 'cat' the file to standard output\n" " -H show history of repository on standard output\n" " -N n limit history to n revisions (unlimited if omitted or 0)\n" +" gdb run eeshow under gdb\n" "\n" "No driver spec: enter GUI\n" "\n" @@ -81,7 +83,7 @@ void usage(const char *name) " diff [-o output.pdf] [-s scale] [file.lib ...] file.sch\n" "\n" " see PNG\n" - , name, name, (int) strlen(name) + 1, "", name, name); + , name, name, (int) strlen(name) + 1, "", name, name, name); exit(1); } @@ -103,6 +105,19 @@ int main(int argc, char **argv) char **gfx_argv; const struct gfx_ops **ops = ops_list; + if (argc > 1 && !strcmp(argv[1], "gdb")) { + char **args; + + args = alloc_type_n(char *, argc + 2); + args[0] = "gdb"; + args[1] = "--args"; + args[2] = *argv; + memcpy(args + 3, argv + 2, sizeof(char *) * (argc - 1)); + execvp("gdb", args); + perror(*argv); + return 1; + } + for (dashdash = 1; dashdash != argc; dashdash++) if (!strcmp(argv[dashdash], "--")) { have_dashdash = 1;