clang confuses kgdb on static symbols

2015-10-20 Thread Andriy Gapon

I see exactly the same behavior both kgdb and kgdb710 (devel/gdb with KGDB 
option):
(kgdb) p/x intr_cpus
No symbol "intr_cpus" in current context.
(kgdb) p/x 'intr_cpus.0'
$1 = 0xf

Not sure if clang should try to not produce that '.0' suffix (especially given
that there are no other intr_cpus symbols) or if kgdb should somehow figure out
the suffix.

-- 
Andriy Gapon
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread John Baldwin
On Tuesday, October 20, 2015 02:38:48 PM Andriy Gapon wrote:
> 
> I see exactly the same behavior both kgdb and kgdb710 (devel/gdb with KGDB 
> option):
> (kgdb) p/x intr_cpus
> No symbol "intr_cpus" in current context.
> (kgdb) p/x 'intr_cpus.0'
> $1 = 0xf
> 
> Not sure if clang should try to not produce that '.0' suffix (especially given
> that there are no other intr_cpus symbols) or if kgdb should somehow figure 
> out
> the suffix.

What if you disable the hack in sys/conf/kern.mk to use dwarf-2?

If '-gdwarf-4' works then you can just set that in the DEBUG makeoptions as a
test, otherwise try hacking kern.mk to disable this bit:

#
# Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
# and gcc 4.8 is to generate DWARF version 4. However, our tools don't
# cope well with DWARF 4, so force it to genereate DWARF2, which they
# understand. Do this unconditionally as it is harmless when not needed,
# but critical for these newer versions.
#
.if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
CFLAGS+=-gdwarf-2
.endif


-- 
John Baldwin
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Ed Maste
On 20 October 2015 at 13:27, John Baldwin  wrote:
>
> If '-gdwarf-4' works then you can just set that in the DEBUG makeoptions as a
> test, otherwise try hacking kern.mk to disable this bit:
>
> #
> # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
> # and gcc 4.8 is to generate DWARF version 4. However, our tools don't
> # cope well with DWARF 4, so force it to genereate DWARF2, which they
> # understand. Do this unconditionally as it is harmless when not needed,
> # but critical for these newer versions.
> #
> .if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
> CFLAGS+=-gdwarf-2
> .endif

Note that Clang defaults to DWARF 2 on FreeBSD, so removing the
override in kern.mk isn't sufficient.

>From contrib/llvm/tools/clang/lib/Driver/Tools.cpp:
else if (!A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_ggdb0)) {
  // Default is dwarf-2 for Darwin, OpenBSD, FreeBSD and Solaris.
  const llvm::Triple  = getToolChain().getTriple();
  if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::OpenBSD ||
  Triple.getOS() == llvm::Triple::FreeBSD ||
  Triple.getOS() == llvm::Triple::Solaris)
CmdArgs.push_back("-gdwarf-2");
  else
CmdArgs.push_back("-g");
}

It may be time for us to remove this default from Clang.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Ed Maste
On 20 October 2015 at 16:30, Konstantin Belousov  wrote:
>
> Wouldn't this cause another outburst of 'works by default' discussion
> from some other place ?

Ok, I'll hold off on this until we make progress on the gdb retirement plan.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Ed Maste
On 20 October 2015 at 17:18, Warner Losh  wrote:
>
>> On Oct 20, 2015, at 3:07 PM, Ed Maste  wrote:
>>
>> On 20 October 2015 at 16:30, Konstantin Belousov  wrote:
>>>
>>> Wouldn't this cause another outburst of 'works by default' discussion
>>> from some other place ?
>>
>> Ok, I'll hold off on this until we make progress on the gdb retirement plan.
>
> Have the issues with ctfconvert been fixed that caused us to go
> to dwarf2 by default?

It should be - kaiw imported a new libdwarf when this first came up to
pick up new DWARF support. It had a few outstanding issues, but those
should now be fixed with my elftoolchain update in r276371 last
December.

Testing that support is of course one of the prerequisites for
changing the default back to DWARF 4.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Dimitry Andric
On 20 Oct 2015, at 13:38, Andriy Gapon  wrote:
> 
> I see exactly the same behavior both kgdb and kgdb710 (devel/gdb with KGDB 
> option):
> (kgdb) p/x intr_cpus
> No symbol "intr_cpus" in current context.
> (kgdb) p/x 'intr_cpus.0'
> $1 = 0xf
> 
> Not sure if clang should try to not produce that '.0' suffix (especially given
> that there are no other intr_cpus symbols) or if kgdb should somehow figure 
> out
> the suffix.

As far as I know, static symbols are candidates for shuffling around,
completely optimizing away, et cetera, as long as the program still
works according to the abstract model.  (This is of course without
taking e.g. __used attributes into account.)

It appears that intr_cpus is a struct, and I have seen before that
individual members of such static structs are sometimes assigned
individual symbols, suffixed with .0, .1 and so on.  This is likely what
is happening in this case.

-Dimitry



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Konstantin Belousov
On Tue, Oct 20, 2015 at 04:07:35PM -0400, Ed Maste wrote:
> On 20 October 2015 at 15:55, Konstantin Belousov  wrote:
> >
> > We cannot stop generating dwarf-2 until in tree gdb and kgdb are substituted
> > by a working replacement.
> 
> Note that I'm only suggesting removing the baked-in default from
> Clang, not the setting in kern.mk.

Wouldn't this cause another outburst of 'works by default' discussion
from some other place ?
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Konstantin Belousov
On Tue, Oct 20, 2015 at 03:44:13PM -0400, Ed Maste wrote:
> On 20 October 2015 at 13:27, John Baldwin  wrote:
> >
> > If '-gdwarf-4' works then you can just set that in the DEBUG makeoptions as 
> > a
> > test, otherwise try hacking kern.mk to disable this bit:
> >
> > #
> > # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
> > # and gcc 4.8 is to generate DWARF version 4. However, our tools don't
> > # cope well with DWARF 4, so force it to genereate DWARF2, which they
> > # understand. Do this unconditionally as it is harmless when not needed,
> > # but critical for these newer versions.
> > #
> > .if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
> > CFLAGS+=-gdwarf-2
> > .endif
> 
> Note that Clang defaults to DWARF 2 on FreeBSD, so removing the
> override in kern.mk isn't sufficient.
> 
> >From contrib/llvm/tools/clang/lib/Driver/Tools.cpp:
> else if (!A->getOption().matches(options::OPT_g0) &&
>  !A->getOption().matches(options::OPT_ggdb0)) {
>   // Default is dwarf-2 for Darwin, OpenBSD, FreeBSD and Solaris.
>   const llvm::Triple  = getToolChain().getTriple();
>   if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::OpenBSD ||
>   Triple.getOS() == llvm::Triple::FreeBSD ||
>   Triple.getOS() == llvm::Triple::Solaris)
> CmdArgs.push_back("-gdwarf-2");
>   else
> CmdArgs.push_back("-g");
> }
> 
> It may be time for us to remove this default from Clang.

I doubt that names of the local symbols have anything to do with the dwarf
version.

We cannot stop generating dwarf-2 until in tree gdb and kgdb are substituted
by a working replacement.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Ed Maste
On 20 October 2015 at 15:55, Konstantin Belousov  wrote:
>
> We cannot stop generating dwarf-2 until in tree gdb and kgdb are substituted
> by a working replacement.

Note that I'm only suggesting removing the baked-in default from
Clang, not the setting in kern.mk.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: clang confuses kgdb on static symbols

2015-10-20 Thread Warner Losh

> On Oct 20, 2015, at 3:07 PM, Ed Maste  wrote:
> 
> On 20 October 2015 at 16:30, Konstantin Belousov  wrote:
>> 
>> Wouldn't this cause another outburst of 'works by default' discussion
>> from some other place ?
> 
> Ok, I'll hold off on this until we make progress on the gdb retirement plan.

Have the issues with ctfconvert been fixed that caused us to go
to dwarf2 by default?

Warner




signature.asc
Description: Message signed with OpenPGP using GPGMail