From 6377854769ea85f2dd38aac9a9b11fded61245f3 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sat, 18 Jan 2014 17:09:43 +0000 Subject: [PATCH] Add d_main_name to set the logical entry point for D programs. gdb/ChangeLog: 2014-01-17 Iain Buclaw * 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. --- gdb/ChangeLog | 6 ++++++ gdb/d-lang.c | 21 +++++++++++++++++++++ gdb/d-lang.h | 4 ++++ gdb/symtab.c | 7 +++++++ 4 files changed, 38 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e26922b9484..4715d3149a8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2014-01-17 Iain Buclaw + + * 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. + 2014-01-17 Iain Buclaw * d-lang.c (d_language_defn): Change macro_expansion_c to diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 766b5fa81b0..b6938290846 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -29,6 +29,27 @@ #include +/* 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 8834a1d6c0a..9ede338f13c 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 09b2326ed52..97b85b84ac5 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) { -- 2.30.2