public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gdcproject.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] Add d_main_name to dlang.c
Date: Tue, 19 Nov 2013 01:53:00 -0000	[thread overview]
Message-ID: <CABOHX+fBVoYBcaUS95pT-19jeuWiN21SiWWGUC5Y6O-A-3Pj_g@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

Hi,

This is the first patch of a few that will eventually get sent across
as I write them.  Adds support for gdb to discover the source location
of D main function.

Regards,
Iain.

[-- Attachment #2: dmain-name.patch --]
[-- Type: text/x-patch, Size: 1994 bytes --]

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2013-11-18  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	* d-lang.h (d_main_name): Add declaration.
+	* d-lang.c (d_main_name): New function.
+	* symtab.c (find_main_name): Add call to d_main_name.
+
 2013-11-18  Tom Tromey  <tromey@redhat.com>
 
 	* common/gdb_stat.h: Remove.
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 35d92ea..d8067f2 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -29,6 +29,27 @@
 
 #include <ctype.h>
 
+/* The main function in the main package.  */
+static const char D_MAIN[] = "D main";
+
+/* Function returning the special symbol name used by D for the main
+   procedure in the main program if it is found in minimal symbol list.
+   This function tries to find minimal symbols so that it finds them even
+   if the program was compiled without debugging information.  */
+
+const char *
+d_main_name (void)
+{
+  struct minimal_symbol *msym;
+
+  msym = lookup_minimal_symbol (D_MAIN, NULL, NULL);
+  if (msym != NULL)
+    return D_MAIN;
+
+  /* No known entry procedure found, the main program is probably not D.  */
+  return NULL;
+}
+
 /* Extract identifiers from MANGLED_STR and append it to TEMPBUF.
    Return 1 on success or 0 on failure.  */
 static int
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index fb6678a..4933431 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -22,6 +22,10 @@
 
 #include "symtab.h"
 
+/* Defined in d-lang.c  */
+
+extern const char *d_main_name (void);
+
 extern char *d_demangle (const char *mangled, int options);
 
 extern void d_val_print (struct type *type, const gdb_byte *valaddr,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8fac0be..6467313 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5018,6 +5018,13 @@ find_main_name (void)
       return;
     }
 
+  new_main_name = d_main_name ();
+  if (new_main_name != NULL)
+    {
+      set_main_name (new_main_name);
+      return;
+    }
+
   new_main_name = go_main_name ();
   if (new_main_name != NULL)
     {

             reply	other threads:[~2013-11-18 23:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  1:53 Iain Buclaw [this message]
2013-11-19 16:09 ` Tom Tromey
2013-11-19 17:50   ` Iain Buclaw
2013-11-19 18:06     ` Tom Tromey
2013-11-19 21:05       ` Pierre Muller
     [not found]       ` <39451.43601527$1384894769@news.gmane.org>
2013-11-19 21:08         ` Tom Tromey
2014-01-03 18:18           ` Iain Buclaw
2014-01-07  9:53             ` Iain Buclaw
2014-01-07 10:44               ` Joel Brobecker

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=CABOHX+fBVoYBcaUS95pT-19jeuWiN21SiWWGUC5Y6O-A-3Pj_g@mail.gmail.com \
    --to=ibuclaw@gdcproject.org \
    --cc=gdb-patches@sourceware.org \
    /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).