On 4 April 2018 at 13:26, Alex Bennée <alex.ben...@linaro.org> wrote:
>
> Abdallah Bouassida <abdallah.bouass...@lauterbach.com> writes:
>
>> Generate an XML description for the cp-regs.
>> Register these regs with the gdb_register_coprocessor().
>> Add arm_gdb_get_sysreg() to use it as a callback to read those regs.
>> Add a dummy arm_gdb_set_sysreg().
>>
>> Signed-off-by: Abdallah Bouassida <abdallah.bouass...@lauterbach.com>
>> ---
>>  gdbstub.c            | 10 ++++++++
>>  include/qom/cpu.h    |  5 +++-
>>  target/arm/cpu.c     |  1 +
>>  target/arm/cpu.h     | 26 +++++++++++++++++++
>>  target/arm/gdbstub.c | 71 
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  target/arm/helper.c  | 27 ++++++++++++++++++++
>>  6 files changed, 139 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdbstub.c b/gdbstub.c
>> index f1d5148..09065bc 100644
>> --- a/gdbstub.c
>> +++ b/gdbstub.c
>> @@ -674,6 +674,16 @@ static const char *get_feature_xml(const char *p, const 
>> char **newp,
>>          }
>>          return target_xml;
>>      }
>> +    if (cc->gdb_get_dynamic_xml) {
>> +        CPUState *cpu = first_cpu;
>> +        char *xmlname = g_strndup(p, len);
>> +        const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname);
>> +
>> +        free(xmlname);
>
> g_free for a g_strndup'ed string please - although I'm confused as to
> why you need to g_strdup the string. You already have p and its not like
> gdb_get_dynamic_xml couldn't dup the string if it needed to (which it
> doesn't seem to).

This is strndup, not strdup. p is not a NUL-terminated string,
so we're creating one to hand to the hook function rather than
requiring it to deal with a non-terminated string.

thanks
-- PMM

Reply via email to