Re: "gdb" by itself ought to put crash into a "gdb" mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/14/12 06:37, Dave Anderson wrote:

Sorry.  I polished the patch, but it still fails here:

$7 = (struct _IO_FILE *) 0x7ffff750f7e0
(gdb) n
1001                    pc->stdpipe = NULL;
(gdb)
1002                    if (pc->stdpipe_pid && PID_ALIVE(pc->stdpipe_pid)) {
(gdb)
1003                            while (!waitpid(pc->stdpipe_pid, &waitstatus, WNOHANG))
(gdb) p pc->stdpipe_pid
$8 = 4180
$ ps -f -p 4180
UID        PID  PPID  C STIME TTY          TIME CMD
bkorb     4180  4168  0 10:20 pts/1    00:00:00 /usr/bin/less -E -X -Ps -- MORE -


So there's some magic going on that is expecting gdb to produce some output
or do something that will make more or less stop.  Unless you know, it'll be
for another day.
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..fdd3a62 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);
@@ -750,28 +751,49 @@ void
 cmd_gdb(void)
 {
 	char buf[BUFSIZE];
+        char ** av = &(args[0]);
 
-        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 (av[0] && ! av[1] && STREQ(av[0], "crash")) {
+                        pc->flags2 &= ~GDB_CMD_MODE;
+                        return;
+                }
+
+        } else if ((optind == 1) || (av[1] == NULL)) {
+                /*
+                 *  "gdb" by itself means "go into GDB command mode".
+                 */
+                pc->flags2 |= GDB_CMD_MODE;
+                return;
+
+        } else {
+                av++; /* skip "gdb" initial prefix */
+        }
 
 	/*
 	 *  Intercept set commands in case something has to be done here.
-	 */ 
-	if (STREQ(args[1], "set")) {
-		if (args[2] && args[3] && STREQ(args[2], "output-radix")) {
-			pc->output_radix = stol(args[3], FAULT_ON_ERROR, NULL);
+	 */
+	if (STREQ(av[0], "set")) {
+		if (av[1] && av[2] && STREQ(av[1], "output-radix")) {
+			pc->output_radix = stol(av[2], FAULT_ON_ERROR, NULL);
 		}
 	}
 
 	/*
 	 *  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);
+	if (!is_restricted_command(av[0], FAULT_ON_ERROR)) {
+                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 +956,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

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux