Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Aug 2017 10:10:11 -0700
From:      Mark Johnston <markj@FreeBSD.org>
To:        Andreas Longwitz <longwitz@incore.de>
Cc:        "freebsd-dtrace@freebsd.org" <freebsd-dtrace@freebsd.org>
Subject:   Re: g_journal_read has broken argument list in V10
Message-ID:  <20170803171011.GB4968@wkstn-mjohnston.west.isilon.com>
In-Reply-To: <598343D8.8060101@incore.de>
References:  <596F2CDA.1000705@incore.de> <598343D8.8060101@incore.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 03, 2017 at 05:40:08PM +0200, Andreas Longwitz wrote:
> > I use FreeBSD 10.3-STABLE r317936 with "old" /usr/lib/dtrace/ip.c and
> > can't get DTrace to work for the function g_journal_read(). In the
> > output of "dtrace -lv" I see
> > 
> > 33379        fbt      geom_journal      g_journal_read entry
> > 
> >         Probe Description Attributes
> >                 Identifier Names: Private
> >                 Data Semantics:   Private
> >                 Dependency Class: Unknown
> > 
> >         Argument Attributes
> >                 Identifier Names: Private
> >                 Data Semantics:   Private
> >                 Dependency Class: ISA
> > 
> >         Argument Types
> >                 args[0]: struct g_journal_softc *
> >                 args[1]: off_t
> >                 args[2]: off_t
> >                 args[3]: struct bio *
> > 
> > but the sourcefile g_journal.c gives
> > 
> > static void
> > g_journal_read(struct g_journal_softc *sc, struct bio *pbp, off_t
> > ostart, off_t oend)
> > 
> > So args[0] and args[2] matches in type, but args[1] and args[3] does
> > not. This problem did not exist in FreeBSD V8, dtrace -lv gives correct
> > 
> > 31519        fbt      geom_journal      g_journal_read entry
> > 
> >         Probe Description Attributes
> >                 Identifier Names: Private
> >                 Data Semantics:   Private
> >                 Dependency Class: Unknown
> > 
> >         Argument Attributes
> >                 Identifier Names: Private
> >                 Data Semantics:   Private
> >                 Dependency Class: ISA
> > 
> >         Argument Types
> >                 args[0]: struct g_journal_softc *
> >                 args[1]: struct bio *
> >                 args[2]: off_t
> >                 args[3]: off_t
> > 
> > Please can somebody show me how this can be fixed ?
> > 
> The output of ctfdump g_journal.o | grep g_journal_read is
> 
>   [23] FUNC (g_journal_read) returns: 4 args: (1057, 381, 381, 955)
>   [24] FUNC (g_journal_read_done) returns: 4 args: (955)
> 
> with the type definitions
> 
>      1057 struct g_journal_softc *
>       955 struct bio *
>       381 TYPEDEF off_t
> 
> Compiling g_journal.c with -O1 instead of the standard -O2 gives
> 
>   [49] FUNC (g_journal_read) returns: 4 args: (1057, 955, 381, 381)
>   [50] FUNC (g_journal_read_done) returns: 4 args: (955)
>   [51] FUNC (g_journal_read_find) returns: 955 args: (955, 3, 955, 381, 381)
>   [52] FUNC (g_journal_read_first) returns: 4 args: (1057, 955)
>   [53] FUNC (g_journal_read_queue_find) returns: 955 args: (1082, 955,
> 381, 381)
> 
> and in this case the argument list for DTrace of g_journal_read is
> correct. The number of args given by ctfdump seems to be broken in most
> cases.
> 
> The function g_journal_read() is the only one in g_journal.c that shows
> the described problem. I can not decide, if the object module
> g_journal.o is broken or if ctfconvert does something wrong.

It's possible that the compiler is reordering arguments. CTF is
generated from DWARF info, so the way to determine if this is the case
is to inspect the dwarf tags with dwarfdump or readelf -w and check the
parameter order there. I don't know why the arguments would be getting
reordered in this case, but I've seen it happen before, particularly in
functions that take struct values as parameters. Specifically, on amd64
such parameters are moved to the end of the list so other parameters may
be passed in registers.

FWIW, with clang 5.0 on ~CURRENT I get the expected parameter order:

    [23] FUNC (g_journal_read) returns: 1 args: (1090, 988, 332, 332)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170803171011.GB4968>