[Lldb-commits] Format strings and different operating systems

Filipe Cabecinhas filcab at gmail.com
Tue Jun 19 07:39:23 PDT 2012


Hi all,  

We (will) have an issue with format strings (or types) and support for multiple operating systems.

Right now, we're printing the addr_t type with %llx. This makes sense in Mac OS X (Lion), which uses unsigned long long for uint64_t (addr_t is typedeffed to uint64_t).
But FreeBSD (9) uses an unsigned long.

And we get lots of these warnings when compiling for FreeBSD:
llvm[4]: Compiling ThreadSpec.cpp for Debug+Asserts build
3/usr/home/filcab/dev/llvm-lldb/tools/lldb/source/Target/ThreadSpec.cpp:143:38: warning: format specifies type 'unsigned long long' but the argument has type 'lldb::tid_t' (aka 'unsigned long') [-Wformat]
s->Printf("tid: 0x%llx ", GetTID());
~~~^ ~~~~~~~~
%lx


I see three options:
Changing the format strings and interpolate PRIx64 and similar constants;
Converting the debug printfs to a more C++-like mechanism, like llvm has;
Creating an lldb format string and an interpreter for it.


I think the last option is overkill. The first option looks rather ugly, though.

But this issue should be addressed if lldb is to be portable and we want it to compile cleanly in several architectures.  

Which one would you prefer? There's the “easy fix” and the more though-out fix. :)

Regards,

  Filipe






More information about the lldb-commits mailing list