public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gdcproject.org>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/5] Add d_main_name to dlang.c
Date: Sat, 18 Jan 2014 17:09:00 -0000	[thread overview]
Message-ID: <CABOHX+e31XHSJGu-MLggDL71YtymiG7p4qsfaLjk6y7wKcpvww@mail.gmail.com> (raw)
In-Reply-To: <87wqi981ef.fsf@fleche.redhat.com>

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

On 9 January 2014 18:18, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Iain" == Iain Buclaw <ibuclaw@gdcproject.org> writes:
>
> Iain> The main program in D is _Dmain (demangled as 'D main') not C 'main'.
> Iain> So the logical entry point of the program should be set accordingly.
>
> Iain> 2014-01-09  Iain Buclaw  <ibuclaw@gdcproject.org>
>
> Iain>         * d-lang.h (d_main_name): Add declaration.
> Iain>         * d-lang.c (d_main_name): New function.
> Iain>         * symtab.c (find_main_name): Add call to d_main_name.
>
> This is ok.
>


FYI, this has been amended slightly for the recent change to set_main_name.

[-- Attachment #2: dlang-p3.patch --]
[-- Type: text/x-diff, Size: 1705 bytes --]

diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 766b5fa..b693829 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -29,6 +29,27 @@
 
 #include <ctype.h>
 
+/* The name of the symbol to use to get the name of the main subprogram.  */
+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 8834a1d..9ede338 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 09b2326..97b85b8 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5122,6 +5122,13 @@ find_main_name (void)
       return;
     }
 
+  new_main_name = d_main_name ();
+  if (new_main_name != NULL)
+    {
+      set_main_name (new_main_name, language_d);
+      return;
+    }
+
   new_main_name = go_main_name ();
   if (new_main_name != NULL)
     {

  parent reply	other threads:[~2014-01-18 17:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 13:09 Iain Buclaw
2014-01-09 18:18 ` Tom Tromey
2014-01-09 18:29   ` Iain Buclaw
2014-01-10 17:26     ` Iain Buclaw
2014-01-10 18:57       ` Tom Tromey
2014-01-10 19:36         ` Iain Buclaw
2014-01-10 19:47           ` Tom Tromey
2014-01-18 17:09   ` Iain Buclaw [this message]
2014-01-18 18:22     ` Iain Buclaw

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+e31XHSJGu-MLggDL71YtymiG7p4qsfaLjk6y7wKcpvww@mail.gmail.com \
    --to=ibuclaw@gdcproject.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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).