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]

[PATCH v2 1/1] don't list typedef symbols in C++, d and ada


C++ "struct foo { ... }" also defines a typedef for "foo", in order
to make command like "gdb) ptype (foo *)0" work, function
symbol_matches_domain relaxes the check for domain check for cplus,
d and ada.

However the command "list foo" will invoke symbol_matches_domain,
which results in odd result when execute command "list foo".

For example, consider debugging following program.
struct foo {
        int i;
};

int foo(void);

int main()
{
        struct foo l;
        return foo();
}

int foo() {
        return 0;
}

(gdb) list foo
file: "example.c", line number: 1
file: "example.c", line number: 13

Following patch get rid of "non var" symbols in function
find_function_symbols. 

Tested on x86-64 GNU/Linux. 
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>

gdb/ChangeLog:
2017-07-16 Zhouyi Zhou <zhouzhouyi@gmail.com>
	* linespec.c (find_function_symbols): remove non-var symbols
	from the matching result.
---
 gdb/linespec.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index 4c076fe..fd74cde 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3223,6 +3223,8 @@ find_function_symbols (struct linespec_state *state,
 {
   struct collect_info info;
   VEC (const_char_ptr) *symbol_names = NULL;
+  int ix;
+  struct symbol *sym;
   struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr),
 					  &symbol_names);
 
@@ -3240,7 +3242,17 @@ find_function_symbols (struct linespec_state *state,
     add_matching_symbols_to_info (name, &info, state->search_pspace);
 
   do_cleanups (cleanup);
-
+  
+  for (ix = 0; VEC_iterate (symbolp, info.result.symbols, ix, sym); ++ix)
+    {
+      if (sym->domain != VAR_DOMAIN)
+	{
+	  VEC_unordered_remove (symbolp,
+				info.result.symbols, ix);
+	  --ix;
+	}
+    }
+  
   if (VEC_empty (symbolp, info.result.symbols))
     {
       VEC_free (symbolp, info.result.symbols);
-- 
2.5.0


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