This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] fortran: add module names to the symbol table


ptype/whatis is now recognizing fortran modules:

	(gdb) ptype modname

	old> No symbol "modname" in current context.

	new> type = module modname

I used the code path for c++ namespace as a reference and changed the bits
to deal with fortran modules, thus things look odd e.g. I touched cp-namespace.c
Therefore I`d like to get your comments on this patch.

2013-02-25  Sanimir Agovic  <sanimir.agovic@intel.com>

	* cp-namespace.c (cp_lookup_nested_symbol): Enable nested lookups for
	fortran modules.
	* dwarf2read.c (read_module): Add fortran module to the symbol table.
	(add_partial_symbol, add_partial_module): Add fortran module to the
	partial symbol table.
	(new_symbol_full): Create full symbol for fortran module.

testsuite/

	* gdb.fortran/module.exp: Completion matches fortran module
	names as well. ptype/whatis on modules return a proper type.

Change-Id: I07d6eb4ce438bb8af6a89d4ac927b5dcd5f4c57f
Signed-off-by: Sanimir Agovic <sanimir.agovic@intel.com>
---
 gdb/cp-namespace.c                   |  1 +
 gdb/dwarf2read.c                     | 10 ++++++++++
 gdb/testsuite/gdb.fortran/module.exp |  6 +++---
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 279021e..bc867ff 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -775,6 +775,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
     {
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_NAMESPACE:
+    case TYPE_CODE_MODULE:
     case TYPE_CODE_UNION:
       {
 	/* NOTE: carlton/2003-11-10: We don't treat C++ class members
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index df6298b..28aefa9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6035,6 +6035,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 			   0, (CORE_ADDR) 0, cu->language, objfile);
       break;
     case DW_TAG_namespace:
+    case DW_TAG_module:
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
 			   VAR_DOMAIN, LOC_TYPEDEF,
@@ -6111,6 +6112,10 @@ static void
 add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc,
 		    CORE_ADDR *highpc, int need_pc, struct dwarf2_cu *cu)
 {
+  /* Add a symbol for the module.  */
+
+  add_partial_symbol (pdi, cu);
+
   /* Now scan partial symbols in that module.  */
 
   if (pdi->has_children)
@@ -12160,6 +12165,10 @@ static void
 read_module (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct die_info *child_die = die->child;
+  struct type *type;
+
+  type = read_type_die (die, cu);
+  new_symbol (die, type, cu);
 
   while (child_die && child_die->tag)
     {
@@ -16104,6 +16113,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  }
 	  break;
 	case DW_TAG_namespace:
+	case DW_TAG_module:
 	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;
 	  list_to_add = &global_symbols;
 	  break;
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 6a2b87d..0b04feb 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -54,7 +54,7 @@ gdb_test "print var_x" " = 30" "print var_x value 30"
 gdb_test "print var_y" "No symbol \"var_y\" in current context\\."
 gdb_test "print var_z" " = 31" "print var_x value 31"
 
-gdb_test "ptype modmany" {No symbol "modmany" in current context.}
+gdb_test "ptype modmany" "type = module modmany"
 
 proc complete {expr list} {
     set cmd "complete p $expr"
@@ -62,8 +62,8 @@ proc complete {expr list} {
     gdb_test $cmd $expect "complete $expr"
 }
 set modmany_list {modmany::var_a modmany::var_b modmany::var_c modmany::var_i}
-complete "modm" $modmany_list
-complete "modmany" $modmany_list
+complete "modm" "modmany $modmany_list"
+complete "modmany" "modmany $modmany_list"
 complete "modmany::" $modmany_list
 complete "modmany::var" $modmany_list
 
-- 
1.7.11.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]