[llvm] r291529 - [XRay] Implement `llvm-xray convert` -- trace file conversion
Frédéric Riss via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 21:16:22 PST 2017
> On Feb 14, 2017, at 2:18 PM, Dimitry Andric <dimitry at andric.com> wrote:
>
> On 14 Feb 2017, at 22:12, Dimitry Andric <dimitry at andric.com> wrote:
>>
>> On 14 Feb 2017, at 21:40, Dean Michael Berris <dberris at google.com> wrote:
>>>
>>> On Tue, Feb 14, 2017 at 12:33 PM Dimitry Andric <dimitry at andric.com> wrote:
> ...
>>> What happens here is that the test/tools/llvm-xray/X86/convert-with-debug-syms.txt test case has the following CHECK-NEXT lines:
>>>
>>> ; CHECK-NEXT: - { type: 0, func-id: 2, function: {{.*foo.*}}, cpu: 37, thread: 84697, kind: function-enter,
>>> ; CHECK-NEXT: tsc: 3315356841454542 }
>>>
>>> However, on my FreeBSD-based systems, the output for the 'foo' and 'bar' lines is formatted slightly differently, wrapping at the 'kind' key instead of the 'tsc' key:
>>>
>>> - { type: 0, func-id: 2, function: 'foo(void)', cpu: 37, thread: 84697,
>>> kind: function-enter, tsc: 3315356841454542 }
>>>
>>> Any idea what causes this? Maybe the yaml outputter is retrieving the terminal size differently somehow, and thus wrapping it at another margin?
>>>
>>> If so, maybe there is some way of ensuring the output either never wraps, or always wraps at the same margin?
>>>
>>>
>>> Interesting. I've not found this before. We're currently just using the defaults for the yaml printer. There could be a way to not pretty-print, but I haven't explored that specifically.
>>
>> I was just reading include/llvm/Support/YAMLTraits.h, and there it has:
>>
>> Output(llvm::raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
>>
>> and xray-converter.cc instantiates an Output object with only the raw_ostream specified, so it should indeed use the default WrapColumn.
>>
>> However, when I just ran this on Ubuntu, it *didn't* wrap at 70 columns. The output was this, instead:
>>
>> ---
>> header:
>> version: 1
>> type: 0
>> constant-tsc: true
>> nonstop-tsc: true
>> cycle-frequency: 2601000000
>> records:
>> - { type: 0, func-id: 3, function: main, cpu: 37, thread: 84697, kind: function-enter,
>> tsc: 3315356841453914 }
>> - { type: 0, func-id: 2, function: 'foo()', cpu: 37, thread: 84697, kind: function-enter,
>> tsc: 3315356841454542 }
>> - { type: 0, func-id: 2, function: 'foo()', cpu: 37, thread: 84697, kind: function-exit,
>> tsc: 3315356841454670 }
>> - { type: 0, func-id: 1, function: 'bar()', cpu: 37, thread: 84697, kind: function-enter,
>> tsc: 3315356841454762 }
>> - { type: 0, func-id: 1, function: 'bar()', cpu: 37, thread: 84697, kind: function-exit,
>> tsc: 3315356841454802 }
>> - { type: 0, func-id: 3, function: main, cpu: 37, thread: 84697, kind: function-exit,
>> tsc: 3315356841494828 }
>> ...
>>
>> It turns out this is apparently influenced by the LANG setting, which is en_US.UTF-8 on Ubuntu, and then the column counting in the YAML Output traits don't work as expected? With LANG=C, it properly wraps at 70 chars.
>
> I've been reading lib/Support/YAMLTraits.cpp, but I don't completely understand the wrapping logic. The wrap column is only checked in a few specific instances, and not in every output() method. Frederic Riss originally implemented this, so maybe he can enlighten us?
Wow I didn’t have any recollection of this… Anyway, I didn’t implement the line-wrapping, I just made it conditional.
Fred
>
> In any case, I think it is better to make the llvm-xray output independent of wrapping columns, so setting WrapColumn to 0 explicitly. I have submitted https://reviews.llvm.org/D29962 for this.
>
> -Dimitry
>
More information about the llvm-commits
mailing list