aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2012-04-25 14:07:23 +0000
committerDoug Evans <dje@google.com>2012-04-25 14:07:23 +0000
commita766d390bb857383a5f9ae80a102e1f8705f4c2e (patch)
tree056e6d8d57aee5d234d9ed4619a27306dfec3dd7 /gdb/symtab.c
parente65f9ffb8e49431537404712a5b1eed310964cb0 (diff)
downloadgdb-a766d390bb857383a5f9ae80a102e1f8705f4c2e.zip
gdb-a766d390bb857383a5f9ae80a102e1f8705f4c2e.tar.gz
gdb-a766d390bb857383a5f9ae80a102e1f8705f4c2e.tar.bz2
Initial pass at Go language support.
* NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index af115cd..6c70113 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -39,6 +39,7 @@
#include "objc-lang.h"
#include "d-lang.h"
#include "ada-lang.h"
+#include "go-lang.h"
#include "p-lang.h"
#include "addrmap.h"
@@ -500,6 +501,7 @@ symbol_set_language (struct general_symbol_info *gsymbol,
{
gsymbol->language = language;
if (gsymbol->language == language_d
+ || gsymbol->language == language_go
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
@@ -620,6 +622,22 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
return demangled;
}
}
+ /* FIXME(dje): Continually adding languages here is clumsy.
+ Better to just call la_demangle if !auto, and if auto then call
+ a utility routine that tries successive languages in turn and reports
+ which one it finds. I realize the la_demangle options may be different
+ for different languages but there's already a FIXME for that. */
+ if (gsymbol->language == language_go
+ || gsymbol->language == language_auto)
+ {
+ demangled = go_demangle (mangled, 0);
+ if (demangled != NULL)
+ {
+ gsymbol->language = language_go;
+ return demangled;
+ }
+ }
+
/* We could support `gsymbol->language == language_fortran' here to provide
module namespaces also for inferiors with only minimal symbol table (ELF
symbols). Just the mangling standard is not standardized across compilers
@@ -742,7 +760,11 @@ symbol_set_names (struct general_symbol_info *gsymbol,
&entry, INSERT));
/* If this name is not in the hash table, add it. */
- if (*slot == NULL)
+ if (*slot == NULL
+ /* A C version of the symbol may have already snuck into the table.
+ This happens to, e.g., main.init (__go_init_main). Cope. */
+ || (gsymbol->language == language_go
+ && (*slot)->demangled[0] == '\0'))
{
char *demangled_name = symbol_find_demangled_name (gsymbol,
linkage_name_copy);
@@ -804,6 +826,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol)
{
case language_cplus:
case language_d:
+ case language_go:
case language_java:
case language_objc:
case language_fortran:
@@ -832,6 +855,7 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol)
{
case language_cplus:
case language_d:
+ case language_go:
case language_java:
case language_objc:
case language_fortran:
@@ -1123,7 +1147,7 @@ demangle_for_lookup (const char *name, enum language lang,
modified_name = name;
- /* If we are using C++, D, or Java, demangle the name before doing a
+ /* If we are using C++, D, Go, or Java, demangle the name before doing a
lookup, so we can always binary search. */
if (lang == language_cplus)
{
@@ -1164,6 +1188,15 @@ demangle_for_lookup (const char *name, enum language lang,
make_cleanup (xfree, demangled_name);
}
}
+ else if (lang == language_go)
+ {
+ demangled_name = go_demangle (name, 0);
+ if (demangled_name)
+ {
+ modified_name = demangled_name;
+ make_cleanup (xfree, demangled_name);
+ }
+ }
*result_name = modified_name;
return cleanup;
@@ -4802,6 +4835,13 @@ find_main_name (void)
return;
}
+ new_main_name = go_main_name ();
+ if (new_main_name != NULL)
+ {
+ set_main_name (new_main_name);
+ return;
+ }
+
new_main_name = pascal_main_name ();
if (new_main_name != NULL)
{