Re: Breakpoint commands in MI mode and "backtrace"

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2017-10-09 03:52 AM, Eli Zaretskii wrote:
>> Date: Mon, 09 Oct 2017 10:27:15 +0300
>> From: Eli Zaretskii <[email protected]>
>> CC: [email protected]
>>
>>> Cc: [email protected]
>>> From: Simon Marchi <[email protected]>
>>> Date: Mon, 9 Oct 2017 00:16:28 -0400
>>>
>>> Hmm, strange.  It is a quite complex function being executed in the hookpost-backtrace.
>>> Do you have any idea what line generates the error?  It would be nice to have a
>>> reproducer without having to build emacs...
>>
>> It's this line in xgetsysm:
>>
>>     set $ptr = ((struct Lisp_Symbol *) ((char *)lispsym + $ptr))
>>
>> where $ptr is a pointer to a Lisp_Symbol object:
>>
>>   (gdb) p $ptr
>>   $2 = (struct Lisp_Symbol *) 0x17c9e38 <dumped_data+267384>
>>
>> and lispsym is an array:
>>
>>   (gdb) ptype lispsym
>>   type = struct {
>>       struct Lisp_Symbol s;
>>   } [1298]
>>
>> Let me know if I can provide more information about this.
> 
> Btw, with the patch, I get the same error if I invoke GDB in CLI mode.
> 
> Thanks.
> 

It's true that my patch seems to change how exceptions are handled, since
safe_execute_command catches and prints exceptions.  However, that expression
does indeed seem erroenous, and I'm surprised GDB doesn't complain about it
currently.  How can you add a char* and a listp_Symbol*?

Anyhow, can you try this patch here?  It changes the uiout manually instead of
going through safe_execute_command.


diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index f1db954a69..b08954132b 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -472,6 +472,8 @@ print_command_trace (const char *cmd)
   printf_filtered ("%s\n", cmd);
 }

+static void restore_interp (void *arg);
+
 enum command_control_type
 execute_control_command (struct command_line *cmd)
 {
@@ -491,8 +493,17 @@ execute_control_command (struct command_line *cmd)
       {
 	/* A simple command, execute it and return.  */
 	std::string new_line = insert_user_defined_cmd_args (cmd->line);
+
+	struct interp *old_interp = interp_set_temp (INTERP_CONSOLE);
+	struct cleanup *old_chain = make_cleanup (restore_interp, old_interp);
+	scoped_restore save_uiout
+	  = make_scoped_restore (&current_uiout,
+		     current_interpreter ()->interp_ui_out ());
+
 	execute_command (&new_line[0], 0);
 	ret = cmd->control_type;
+
+	do_cleanups (old_chain);
 	break;
       }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.