On 03/14/12 06:37, Dave Anderson wrote:
Possible? Thanks ! Regards, Bruce
Definitely sounds possible. Maybe create a new "gdb" environment
variable that can be flipped with "set gdb on/off" commands. Then
check for the mode in process_command_line() and exec_input_file()
and insert/shift the "gdb" string into args[0].
I did the patch as a "flags2" flag bit.
"gdb_cmd()" already leaves the first bytes of the command alone,
but I found it difficult to leave it alone. I eliminated the
extra copy....
diff --git a/cmdline.c b/cmdline.c
index f5fd133..ae7edb5 100755
--- a/cmdline.c
+++ b/cmdline.c
@@ -131,7 +131,6 @@ process_command_line(void)
check_special_handling(pc->command_line);
} else {
- fflush(fp);
if (fgets(pc->command_line, BUFSIZE-1, stdin) == NULL)
clean_exit(1);
strcpy(pc->orig_line, pc->command_line);
diff --git a/defs.h b/defs.h
index bddf2bc..10c62c2 100755
--- a/defs.h
+++ b/defs.h
@@ -438,11 +438,12 @@ struct program_context {
char *runtime_ifile_cmd; /* runtime command using input file */
char *kvmdump_mapfile; /* storage of physical to file offsets */
ulonglong flags2; /* flags overrun */
-#define FLAT (0x1ULL)
-#define ELF_NOTES (0x2ULL)
-#define GET_OSRELEASE (0x4ULL)
-#define REMOTE_DAEMON (0x8ULL)
+#define FLAT (0x01ULL)
+#define ELF_NOTES (0x02ULL)
+#define GET_OSRELEASE (0x04ULL)
+#define REMOTE_DAEMON (0x08ULL)
#define ERASEINFO_DATA (0x10ULL)
+#define GDB_CMD_MODE (0x20ULL)
#define FLAT_FORMAT() (pc->flags2 & FLAT)
#define ELF_NOTES_VALID() (pc->flags2 & ELF_NOTES)
char *cleanup;
diff --git a/gdb_interface.c b/gdb_interface.c
index fa642bb..eb2865a 100755
--- a/gdb_interface.c
+++ b/gdb_interface.c
@@ -16,6 +16,7 @@
*/
#include "defs.h"
+#include <ctype.h>
static void exit_after_gdb_info(void);
static int is_restricted_command(char *, ulong);
@@ -751,8 +752,24 @@ cmd_gdb(void)
{
char buf[BUFSIZE];
- if (!args[optind])
- cmd_usage(pc->curcmd, SYNOPSIS);
+ /*
+ * In GDB command mode, look for a command saying "crash".
+ * Take us out of GDB command mode in that case.
+ */
+ if (pc->flags2 & GDB_CMD_MODE) {
+ if (!args[optind])
+ cmd_usage(pc->curcmd, SYNOPSIS);
+ else if (args[1] && ! args[2] && STREQ(args[1], "crash")) {
+ pc->flags2 &= ~GDB_CMD_MODE;
+ return;
+ }
+ } else {
+ /*
+ * "gdb" by itself means "go into GDB command mode".
+ */
+ if (!args[optind])
+ pc->flags2 |= GDB_CMD_MODE;
+ }
/*
* Intercept set commands in case something has to be done here.
@@ -767,11 +784,11 @@ cmd_gdb(void)
* If the command is not restricted, pass it on.
*/
if (!is_restricted_command(args[1], FAULT_ON_ERROR)) {
- if (STREQ(pc->command_line, "gdb")) {
- strcpy(buf, &pc->orig_line[3]);
- strip_beginning_whitespace(buf);
- } else
- strcpy(buf, pc->orig_line);
+ char * p = pc->orig_line;
+ if (STREQ(pc->command_line, "gdb"))
+ p += 3;
+ while (isspace((int)*p)) p++;
+ strcpy(buf, p);
if (pc->redirect & (REDIRECT_TO_FILE|REDIRECT_TO_PIPE))
strip_redirection(buf);
@@ -934,6 +951,12 @@ get_frame_offset(ulong pc)
return (error(FATAL,
"get_frame_offset: invalid request for non-alpha systems!\n"));
}
-#endif /* !ALPHA */
-
-
+#endif /* !ALPHA */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "k&r"
+ * indent-tabs-mode: nil
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/main.c b/main.c
index 043f9f0..ff1ca2c 100755
--- a/main.c
+++ b/main.c
@@ -798,7 +798,10 @@ get_command_table_entry(char *name)
{
struct command_table_entry *cp;
struct extension_table *ext;
-
+
+ if (pc->flags2 & GDB_CMD_MODE)
+ name = "gdb";
+
if ((pc->flags & MINIMAL_MODE) && !minimal_functions(name))
return NULL;
@@ -1721,3 +1724,11 @@ get_osrelease(char *dumpfile)
clean_exit(retval);
}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "k&r"
+ * indent-tabs-mode: nil
+ * c-basic-offset: 8
+ * End:
+ */
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility