Re: [RFA-v3] Allow explicit 16 or 32 char in 'x /s'

Ulrich Weigand
2010-07-05T10:17:56Z

Tom Tromey wrote:
> >>>>> "Ulrich" =3D=3D Ulrich Weigand <uweigand@de.ibm.com> writes:
>
> Ulrich> This test required that malloc is present in the inferior; if target
> Ulrich> code is statically linked, we need to make sure the routine gets
> Ulrich> pulled in (just like other testcases already do).
>
> Ulrich> * gdb.base/charset.c (main): Make sure malloc gets linked in.
>
> With this patch I now get:
>
> Running ../../../src/gdb/testsuite/gdb.base/charset.exp ...
> gdb compile failed, ../../../src/gdb/testsuite/gdb.base/charset.c: In function 'main':
> ../../../src/gdb/testsuite/gdb.base/charset.c:126: warning: incompatible implicit declaration of built-in function 'malloc'

Huh, sorry about that.

> It isn't safe here to include <stdlib.h>, since this test intentionally
> defines its own "wchar_t".
>
> Adding:
>
> extern void *malloc (int);
>
> works for me, but it seems possibly problematic.

Yes, it really should be size_t, not int (and that may be a real issue
on some 64-bit systems). But if you cannot include standard headers,
you don't get size_t either ...

> Maybe adding -fno-builtin for gcc is the thing to do?
>
> I am not really sure what is best. Any other ideas?

Can we split the testcase so that the parts that require the
non-standard wchar_t definition are separate from the parts
that construct strings in the inferior?

Bye,
Ulrich

--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com