GDB printf command
Daniel Jacobowitz
drow@false.org
Tue Oct 17 14:54:00 GMT 2006
On Tue, Oct 17, 2006 at 03:43:18PM +0100, Andrew STUBBS wrote:
> I'm not really sure what you are suggesting I do exactly. What do you
> think ought to be done and where?
I think we ought to run a format string parser to break up the string,
then look at what arguments we've got and their types, and squeeze the
two together.
This sounds like a fairly complicated solution, and I'd agree, except
that we can steal most of the code for it from this "gnulib" project I
keep talking about: a collection of GPL and LGPL utility routines,
designed to be imported into other projects.
For example, I've attached the headers which handle the parsing.
There's no "take this argument and format set and print it" function;
it's all wrapped up in a vasnprintf implementation. However, we could
trivially split that out, and ask the gnulib maintainers to accept such a
change; I bet they would accept such a patch.
Once we have the structure in place, we could basically replace
printf_fetchargs (which uses va_arg) with something that operated on
our list of values and did appropriate type checking / casts, then
hand it back to the gnulib printf routine.
> How much effort do you think it will take? Like everyone else I don't
> have enormous amounts of time for projects I wasn't expecting.
This I can not predict, I'm afraid.
> Assuming it isn't a big task I am certainly interested in getting it
> done right. Whatever that is, hopefully it does include the same target
> working the same on all hosts (or at least all the same features
> working, for some definition of 'work').
Precisely.
--
Daniel Jacobowitz
CodeSourcery
-------------- next part --------------
A non-text attachment was scrubbed...
Name: printf-args.h
Type: text/x-chdr
Size: 2859 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20061017/870f96f5/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: printf-parse.h
Type: text/x-chdr
Size: 2160 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20061017/870f96f5/attachment-0001.bin>
More information about the Gdb
mailing list