This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3 7/9] compile: New 'compile print'
- From: Pedro Alves <palves at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>, gdb-patches at sourceware dot org
- Cc: Phil Muldoon <pmuldoon at redhat dot com>
- Date: Wed, 29 Apr 2015 16:49:50 +0100
- Subject: Re: [PATCH v3 7/9] compile: New 'compile print'
- Authentication-results: sourceware.org; auth=none
- References: <20150411194322 dot 29128 dot 52477 dot stgit at host1 dot jankratochvil dot net> <20150411194418 dot 29128 dot 3411 dot stgit at host1 dot jankratochvil dot net>
On 04/11/2015 08:44 PM, Jan Kratochvil wrote:
> + case COMPILE_I_PRINT_ADDRESS_SCOPE:
> + case COMPILE_I_PRINT_VALUE_SCOPE:
> + fputs_unfiltered ("#include <string.h>\n"
OOC, why do we need the include?
> + "void "
> + GCC_FE_WRAPPER_FUNCTION
> + " (struct "
> + COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG
> + " *"
> + COMPILE_I_SIMPLE_REGISTER_ARG_NAME
> + ", "
> + COMPILE_I_PRINT_OUT_ARG_TYPE
> + " "
> + COMPILE_I_PRINT_OUT_ARG
> + ") {\n",
> + buf);
> + break;
> +
> case COMPILE_I_RAW_SCOPE:
> break;
> default:
> @@ -354,6 +355,114 @@ copy_sections (bfd *abfd, asection *sect, void *data)
> do_cleanups (cleanups);
> }
>
> +/* Fetch the type of COMPILE_I_EXPR_PTR_TYPE and COMPILE_I_EXPR_VAL
> + symbols in OBJFILE so we can calculate how much memory to allocate
> + for the out parameter. This avoids needing a malloc in the generated
> + code. Throw an error if anything fails.
> + Set *OUT_VALUE_TAKE_ADDRESSP depending whether inferior code should
> + copy COMPILE_I_EXPR_VAL or its address - this depends on __auto_type
> + array-to-pointer type conversion of COMPILE_I_EXPR_VAL, as detected
> + by COMPILE_I_EXPR_PTR_TYPE preserving the array type. */
This comment seems a bit stale. At least, I don't see an
OUT_VALUE_TAKE_ADDRESSP parameter.
> +
> +static struct type *
> +get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
> + enum compile_i_scope_types scope)
> +{
> + struct symbol *gdb_ptr_type_sym, *gdb_val_sym;
> + struct type *gdb_ptr_type, *gdb_type_from_ptr, *gdb_type, *retval;
> + const struct block *block;
> + const struct blockvector *bv;
> + int nblocks = 0;
> + int block_loop = 0;
Otherwise this looks reasonable to me.
Thanks,
Pedro Alves