[Lldb-commits] [PATCH] D27632: Add Formatv() versions of all our printf style formatting functions
Greg Clayton via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 9 16:02:57 PST 2016
clayborg added a comment.
It is nice to be able to use StringRef and std::string as is. I was wondering if you have:
StringRef null;
StringRef empty("");
StringRef hello("hello")
What does this show:
formatv("{0} {1} {2}", null, empty, hello);
I would hope for:
(null) "" "hello"
Where "(null)" is used for the empty StringRef since it doesn't have a value. This is what printf does if you pass nullptr in for a %s. The other string has a pointer, but no size, so it should show the empty string. Also for std::string and for StringRef if would be great if we can show binary values since a StringRef and std::string can contain NULL characters and also non printable characters. One option that would be really cool for both StringRef and std::string would be the memory view stuff we did a month back! So we could do:
StringRef bytes("\x01\x02\x03");
formatv("{0:memory}", bytes);
And get out a memory dump.
================
Comment at: source/Target/Target.cpp:1558-1559
+ error.SetErrorStringWithFormatv(
+ "{0}[{1:x+}] can't be resolved, {0} is not currently loaded",
addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"),
+ resolved_addr.GetFileAddress());
----------------
Can we add lldb_private::FileSpec support with this patch as well? Then the code can be:
```
error.SetErrorStringWithFormatv(
"{0}[{1:x+}] can't be resolved, {0;filename} is not currently loaded",
addr_module_sp->GetFileSpec(), resolved_addr.GetFileAddress());
```
https://reviews.llvm.org/D27632
More information about the lldb-commits
mailing list