On Tue, Jan 23, 2018 at 1:54 PM, Uros Bizjak <ubiz...@gmail.com> wrote:
> On Tue, Jan 23, 2018 at 11:38 AM, Uros Bizjak <ubiz...@gmail.com> wrote:
>> On Tue, Jan 23, 2018 at 8:32 AM, Uros Bizjak <ubiz...@gmail.com> wrote:
>>> On Tue, Jan 23, 2018 at 5:49 AM, Ian Lance Taylor <i...@golang.org> wrote:
>>>> On Sun, Jan 21, 2018 at 3:13 PM, Uros Bizjak <ubiz...@gmail.com> wrote:
>>>>>
>>>>> The default "go build" compile options over-optimize the auxiliary
>>>>> executable, built in TestCrashDumpsAllThreads testcase
>>>>> (libgo/go/runtime/crash_unix_test.go). This over-optimization results
>>>>> in removal of the trivial summing loop and in the inlining of the
>>>>> main.loop function into main.$thunk0.
>>>>>
>>>>> The testcase expects backtrace that shows several instances of
>>>>> main.loop in the backtrace dump. When main.loop gets inlined into
>>>>> thunk, its name is not dumped anymore.
>>>>>
>>>>> The solution is to pass "-O0" to gccgo, which inhibits unwanted inlining.
>>>>>
>>>>> Patch was bootstrapped and regression tested on x86_64-linux-gnu and
>>>>> alphev68-linux-gnu, where for the later target the patch fixed the
>>>>> mentioned failure.
>>>>
>>>> That sounds like a bug somewhere.  Even when one function gets inlined
>>>> into another, its name should still be dumped.  This is implemented by
>>>> report_inlined_functions in libbacktrace/dwarf.c.  While something
>>>> like your patch may be needed, I'd like to more clearly understand why
>>>> libbacktrace isn't working.
>>>
>>> If I manually compile the testcase from crash_unix_test.go wth gccgo
>>> -O2 (the asm is attached), the main.loop function is not even present
>>> in the dump.
>>
>> Digging deeper into the source, here is the problem:
>
> [...]
>
>> So, those $LBB labels are at the wrong place. During runtime, we get
>> (oh, why can't we display PC in hex?!):
>
> Following testcase:
>
> --cut here--
> package main
>
> func loop(i int, c chan bool) {
>         close(c)
>         for {
>                 for j := 0; j < 0x7fffffff; j++ {
>                 }
>         }
> }
> --cut here--
>
> can be compiled with a crosscompiler to alpha-linux-gnu:
>
> ~/gcc-build-alpha/gcc/go1 -O2 -fkeep-static-functions l.go
>
> to generate assembly, where $LBB2 is placed after "lda" insn.

[...]

> I will open a PR:

PR 83992 [1].

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83992

Uros.

Reply via email to