This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
RFA: Reliably restore result_ptr in gdbtk_load_asm
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: RFA: Reliably restore result_ptr in gdbtk_load_asm
- From: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Date: Sat, 1 Apr 2000 18:29:55 -0500 (EST)
2000-04-01 Jim Blandy <jimb@redhat.com>
* gdbtk-hooks.c (gdbtk_restore_result_ptr): New function.
* gdbtk.h (gdbtk_restore_result_ptr): Declare it.
* gdbtk-cmds.c (gdbtk_load_asm): Use it to restore the old value
of result_ptr, in case we get errors while disassembling things.
Index: gdb/gdbtk/generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.5
diff -c -r1.5 gdbtk-cmds.c
*** gdb/gdbtk/generic/gdbtk-cmds.c 2000/03/28 23:04:02 1.5
--- gdb/gdbtk/generic/gdbtk-cmds.c 2000/04/01 23:19:21
***************
*** 2751,2756 ****
--- 2751,2757 ----
}
+
static CORE_ADDR
gdbtk_load_asm (clientData, pc, di)
ClientData clientData;
***************
*** 2761,2767 ****
= (struct disassembly_client_data *) clientData;
char **text_argv;
int i, pc_to_line_len, line_to_pc_len;
! gdbtk_result new_result, *old_result_ptr;
pc_to_line_len = Tcl_DStringLength (&client_data->pc_to_line_prefix);
line_to_pc_len = Tcl_DStringLength (&client_data->line_to_pc_prefix);
--- 2762,2769 ----
= (struct disassembly_client_data *) clientData;
char **text_argv;
int i, pc_to_line_len, line_to_pc_len;
! gdbtk_result new_result;
! struct cleanup *old_chain = NULL;
pc_to_line_len = Tcl_DStringLength (&client_data->pc_to_line_prefix);
line_to_pc_len = Tcl_DStringLength (&client_data->line_to_pc_prefix);
***************
*** 2771,2777 ****
/* Preserve the current Tcl result object, print out what we need, and then
suck it out of the result, and replace... */
! old_result_ptr = result_ptr;
result_ptr = &new_result;
result_ptr->obj_ptr = client_data->result_obj[0];
result_ptr->flags = GDBTK_TO_RESULT;
--- 2773,2779 ----
/* Preserve the current Tcl result object, print out what we need, and then
suck it out of the result, and replace... */
! old_chain = make_cleanup (gdbtk_restore_result_ptr, (void *) result_ptr);
result_ptr = &new_result;
result_ptr->obj_ptr = client_data->result_obj[0];
result_ptr->flags = GDBTK_TO_RESULT;
***************
*** 2833,2839 ****
}
! result_ptr = old_result_ptr;
return pc;
}
--- 2835,2841 ----
}
! do_cleanups (old_chain);
return pc;
}
Index: gdb/gdbtk/generic/gdbtk-hooks.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v
retrieving revision 1.2
diff -c -r1.2 gdbtk-hooks.c
*** gdb/gdbtk/generic/gdbtk-hooks.c 2000/02/24 03:11:47 1.2
--- gdb/gdbtk/generic/gdbtk-hooks.c 2000/04/01 23:19:21
***************
*** 183,188 ****
--- 183,198 ----
*/
gdbtk_result *result_ptr = NULL;
+
+ /* If you want to restore an old value of result_ptr whenever cleanups
+ are run, pass this function to make_cleanup, along with the value
+ of result_ptr you'd like to reinstate. */
+ void
+ gdbtk_restore_result_ptr (void *old_result_ptr)
+ {
+ result_ptr = (gdbtk_result *) old_result_ptr;
+ }
+
/* This allows you to Tcl_Eval a tcl command which takes
Index: gdb/gdbtk/generic/gdbtk.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 gdbtk.h
*** gdb/gdbtk/generic/gdbtk.h 2000/02/07 00:19:42 1.1.1.1
--- gdb/gdbtk/generic/gdbtk.h 2000/04/01 23:19:21
***************
*** 133,138 ****
--- 133,143 ----
extern gdbtk_result *result_ptr;
+ /* If you want to restore an old value of result_ptr whenever cleanups
+ are run, pass this function to make_cleanup, along with the value
+ of result_ptr you'd like to reinstate. */
+ extern void gdbtk_restore_result_ptr (void *);
+
/* GDB context identifier */
extern int gdb_context;