[Lldb-commits] [lldb] 9f6a308 - [lldb/Utility] Fix a bug in stringify_append for printing addresses.

Shafik Yaghmour via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 16 16:03:18 PDT 2020



> On Apr 16, 2020, at 3:17 PM, Davidino Italiano <ditaliano at apple.com> wrote:
> 
> 
> 
>> On Apr 16, 2020, at 2:37 PM, Shafik Yaghmour via lldb-commits <lldb-commits at lists.llvm.org <mailto:lldb-commits at lists.llvm.org>> wrote:
>> 
>>> 
>>> On Apr 16, 2020, at 2:04 PM, Jonas Devlieghere via lldb-commits <lldb-commits at lists.llvm.org <mailto:lldb-commits at lists.llvm.org>> wrote:
>>> 
>>> 
>>> Author: Jonas Devlieghere
>>> Date: 2020-04-16T14:03:55-07:00
>>> New Revision: 9f6a308457d1bfebf1cee94b0306e738f270e512
>>> 
>>> URL: https://github.com/llvm/llvm-project/commit/9f6a308457d1bfebf1cee94b0306e738f270e512 <https://github.com/llvm/llvm-project/commit/9f6a308457d1bfebf1cee94b0306e738f270e512>
>>> DIFF: https://github.com/llvm/llvm-project/commit/9f6a308457d1bfebf1cee94b0306e738f270e512.diff <https://github.com/llvm/llvm-project/commit/9f6a308457d1bfebf1cee94b0306e738f270e512.diff>
>>> 
>>> LOG: [lldb/Utility] Fix a bug in stringify_append for printing addresses.
>>> 
>>> The recent change in the API macros revealed that we were not printing
>>> the pointer address for a bunch of methods, but rather the address of
>>> the pointer. It's something I had already noticed while looking at some
>>> reproducer traces, but hadn't made it to the top of my list yet. This
>>> fixes the issue by providing a more specific overload.
>>> 
>>> Added: 
>>> 
>>> 
>>> Modified: 
>>>   lldb/include/lldb/Utility/ReproducerInstrumentation.h
>>> 
>>> Removed: 
>>> 
>>> 
>>> 
>>> ################################################################################
>>> diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
>>> index 3728e19386d1..3b5dde3d2e2a 100644
>>> --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
>>> +++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
>>> @@ -32,6 +32,11 @@ inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
>>>  ss << &t;
>>> }
>>> 
>> 
>> 
>> Note you can use the narrower static_cast<void*>
>> 
> 
> That would be wrong.

In the function pointer case, it would be ill-formed but otherwise this is a standard conversion and those are valid via static_cast, see [conv.ptr]p2 http://eel.is/c++draft/conv.ptr#2

> 
>>> +template <typename T>
>>> +inline void stringify_append(llvm::raw_string_ostream &ss, T *t) {
>>> +  ss << reinterpret_cast<void *>(t);
>>> +}
>>> +
>>> template <typename T>
>>> inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) {
>>>  ss << reinterpret_cast<const void *>(t);
>>> @@ -115,7 +120,7 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
>>> 
>>> #define LLDB_CONSTRUCT_(T, ...)                                                \
>>>  lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,                \
>>> -                                          stringify_args(__VA_ARGS__));        \
>>> +                                          stringify_args(this, __VA_ARGS__));  \
>>>  if (lldb_private::repro::InstrumentationData _data =                         \
>>>          LLDB_GET_INSTRUMENTATION_DATA()) {                                   \
>>>    _recorder.Record(_data.GetSerializer(), _data.GetRegistry(),               \
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> lldb-commits mailing list
>>> lldb-commits at lists.llvm.org <mailto:lldb-commits at lists.llvm.org>
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>> 
>> _______________________________________________
>> lldb-commits mailing list
>> lldb-commits at lists.llvm.org <mailto:lldb-commits at lists.llvm.org>
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits <https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200416/8a436403/attachment-0001.html>


More information about the lldb-commits mailing list