This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[RFA] gdbtk/generic/gdbtk-cmds.c: try entry point if no "main"
- To: insight at sources dot redhat dot com
- Subject: [RFA] gdbtk/generic/gdbtk-cmds.c: try entry point if no "main"
- From: Nicholas Duffek <nsd at redhat dot com>
- Date: Tue, 27 Feb 2001 15:42:00 -0500
When Insight starts, it initializes the source window to display one of
the functions in [pref get gdb/main_names], which defaults to { MAIN___
MAIN__ main }. If none of those functions exists, the source window
starts out empty.
The appended patch checks the program's entry point if none of the
gdb/main_names functions are found. This is useful when debugging
assembly-language programs, which often lack a "main" function.
gdbtk/ChangeLog:
* generic/gdbtk-cmds.c (gdb_entry_point): New TCL command.
* library/interface.tcl (gdbtk_locate_main): Try the program's
entry point if no main function is found.
Okay to apply?
Nicholas Duffek
<nsd@redhat.com>
[patch follows]
Index: gdb/gdbtk/generic/gdbtk-cmds.c
===================================================================
diff -up gdb/gdbtk/generic/gdbtk-cmds.c gdb/gdbtk/generic/gdbtk-cmds.c
--- gdb/gdbtk/generic/gdbtk-cmds.c Tue Feb 13 23:07:32 2001
+++ gdb/gdbtk/generic/gdbtk-cmds.c Tue Feb 13 23:07:11 2001
@@ -197,6 +197,7 @@ static int gdb_cmd (ClientData, Tcl_Inte
static int gdb_confirm_quit (ClientData, Tcl_Interp *, int,
Tcl_Obj * CONST[]);
static int gdb_disassemble (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST[]);
+static int gdb_entry_point (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST[]);
static int gdb_eval (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST[]);
static int gdb_fetch_registers (ClientData, Tcl_Interp *, int,
Tcl_Obj * CONST[]);
@@ -334,6 +335,8 @@ Gdbtk_Init (interp)
NULL);
Tcl_CreateObjCommand (interp, "gdb_listfuncs", call_wrapper, gdb_listfuncs,
NULL);
+ Tcl_CreateObjCommand (interp, "gdb_entry_point", call_wrapper,
+ gdb_entry_point, NULL);
Tcl_CreateObjCommand (interp, "gdb_get_mem", call_wrapper, gdb_get_mem,
NULL);
Tcl_CreateObjCommand (interp, "gdb_stop", call_wrapper, gdb_stop, NULL);
@@ -3258,6 +3261,23 @@ gdb_loc (clientData, interp, objc, objv)
Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
Tcl_NewStringObj ("", -1));
#endif
+ return TCL_OK;
+}
+
+/* This implements the TCL command gdb_entry_point. It returns the current
+ entry point address. */
+
+static int
+gdb_entry_point (clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+{
+ char *addrstr;
+
+ addrstr = paddr_nz (entry_point_address ());
+ Tcl_SetStringObj (result_ptr->obj_ptr, addrstr, -1);
return TCL_OK;
}
Index: gdb/gdbtk/library/interface.tcl
===================================================================
diff -up gdb/gdbtk/library/interface.tcl gdb/gdbtk/library/interface.tcl
--- gdb/gdbtk/library/interface.tcl Tue Feb 13 23:07:49 2001
+++ gdb/gdbtk/library/interface.tcl Tue Feb 13 23:07:11 2001
@@ -726,6 +726,10 @@ proc gdbtk_locate_main {} {
return $linespec
}
}
+ if {![catch gdb_entry_point entry_point]
+ && ![catch {gdb_loc "*$entry_point"} linespec]} {
+ return $linespec
+ }
return {}
}