This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Convert 'name' of 'struct varobj' to 'const char *'.
- From: Tom Tromey <tromey at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Fri, 30 Aug 2013 10:20:40 -0600
- Subject: Re: [PATCH] Convert 'name' of 'struct varobj' to 'const char *'.
- Authentication-results: sourceware.org; auth=none
- References: <1377825178-20943-1-git-send-email-yao at codesourcery dot com>
>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
Yao> This patch is to change the type of field 'name' of 'struct varobj'
Yao> from 'char *' to 'const char *'.
It's tempting to do this but I think the new casts tell us that
something fishy is going on.
Yao> struct varobj *
Yao> -varobj_create (char *objname,
Yao> - char *expression, CORE_ADDR frame, enum varobj_type type)
Yao> +varobj_create (char *objname, const char *expression, CORE_ADDR frame,
Yao> + enum varobj_type type)
Here we're claiming that this takes a const char *.
Yao> - xfree (var->name);
Yao> + xfree ((void *) var->name);
But here we cast away const to free the object.
I think this means the object wasn't "really const". It's an
abstraction violation.
A different approach might be to change varobj_create to accept a const,
and then xstrdup it there. But then the field still could not really be
const.
Tom