[PATCH] Fix ptype problem printing typedefs defined differently in different compilation units

Fred Fish fnf@specifix.com
Wed Jan 4 02:46:00 GMT 2006


On Tuesday 03 January 2006 18:15, Jim Blandy wrote:
> The test looks good; please commit that.

OK.

> I have some questions about the patch, though. 
> get_current_source_symtab_and_line is a user-interface thing, and I'm
> uncomfortable calling it from one of our fundamental lookup functions.

There is a static pointer to the current source symtab in source.c,
and only functions in that file have direct access to it.  All the
rest of gdb seems to use one of the accessor functions exported from
source.c:

	get_current_source_symtab_and_line
	set_current_source_symtab_and_line
	clear_current_source_symtab_and_line

> Why isn't the right block being passed to lookup_symbol in the first
> place?

ptype_command() calls parse_expression() with the name of the type as
the only argument

parse_expression() calls parse_exp_1() with zero as the block

parse_exp_1() simply calls parse_exp_in_context(), passing on zero.

parse_exp_in_context() sees that block is zero and tries to find
expression_context_block by calling get_selected_block(), but since
the target isn't running, that returns zero, which gets saved in
expression_context_block.

parse_exp_context() then calls the C parser, which calls the lexer, which
calls lookup_symbol() with the current value of expression_context_block,
which is zero.

-Fred





More information about the Gdb-patches mailing list