public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Nicholas Duffek <nsd@redhat.com>
To: insight@sources.redhat.com
Subject: [RFA] gdbtk/generic/gdbtk-cmds.c: try entry point if no "main"
Date: Tue, 27 Feb 2001 12:40:00 -0000	[thread overview]
Message-ID: <200102272042.PAA00418@nog.bosbc.com> (raw)

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 {}
 }
 

             reply	other threads:[~2001-02-27 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-27 12:40 Nicholas Duffek [this message]
2001-02-27 12:52 ` Keith Seitz
2001-04-12 12:51 Nick Duffek
2001-04-12 12:52 ` Fernando Nasser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200102272042.PAA00418@nog.bosbc.com \
    --to=nsd@redhat.com \
    --cc=insight@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).