public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] loc2c-runtime: fix compilation failure
@ 2020-02-07  4:07 d.hatayama
  2020-02-07  9:51 ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: d.hatayama @ 2020-02-07  4:07 UTC (permalink / raw)
  To: 'systemtap@sourceware.org'

I ran into the following compilation failure when I tried to change
$return in a return probe for some user-space process:

    # ./runstap.sh
    Pass 1: parsed user script and 478 library scripts using 238944virt/81096res/12424shr/68276data kb, in 790usr/230sys/1187real ms.
    Pass 2: analyzed script: 3 probes, 6 functions, 1 embed, 2 globals using 255944virt/99036res/13544shr/85276data kb, in 300usr/70sys/449real ms.
    Pass 3: translated to C into "/tmp/stapnWDsqi/stap_ea515d442eab2d1921c7105860f0337f_3673_src.c" using 255944virt/99364res/13872shr/85276data kb, in 270usr/430sys/716real ms.
    In file included from /usr/share/systemtap/runtime/linux/runtime.h:217,
   		  from /usr/share/systemtap/runtime/runtime.h:26,
   		  from /tmp/stapnWDsqi/stap_ea515d442eab2d1921c7105860f0337f_3673_src.c:27:
    /tmp/stapnWDsqi/stap_ea515d442eab2d1921c7105860f0337f_3673_src.c: In function ‘function___private___foobar_stp__dwarf_tvar_set_return_1’:
    /usr/share/systemtap/runtime/linux/loc2c-runtime.h:297:69: error: ‘regnoo’ undeclared (first use in this function); did you mean ‘reg_info’?
     #define u_store_register(regno,value) check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
   								      ^~~~~~
    /usr/share/systemtap/runtime/linux/loc2c-runtime.h:44:23: note: in definition of macro ‘check_store_register’
       if ((regs) == 0 || (regno) < 0 || (regno) > (maxregno)) {      \
   			^~~~~
    /tmp/stapnWDsqi/stap_ea515d442eab2d1921c7105860f0337f_3673_src.c:725:3: note: in expansion of macro ‘u_store_register’
       u_store_register(0, l->__tmp0);
       ^~~~~~~~~~~~~~~~
    /usr/share/systemtap/runtime/linux/loc2c-runtime.h:297:69: note: each undeclared identifier is reported only once for each function it appears in
     #define u_store_register(regno,value) check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
   								      ^~~~~~
    /usr/share/systemtap/runtime/linux/loc2c-runtime.h:44:23: note: in definition of macro ‘check_store_register’
       if ((regs) == 0 || (regno) < 0 || (regno) > (maxregno)) {      \
   			^~~~~
    /tmp/stapnWDsqi/stap_ea515d442eab2d1921c7105860f0337f_3673_src.c:725:3: note: in expansion of macro ‘u_store_register’
       u_store_register(0, l->__tmp0);
       ^~~~~~~~~~~~~~~~
    make[1]: *** [scripts/Makefile.build:312: /tmp/stapnWDsqi/stap_ea515d442eab2d1921c7105860f0337f_3673_src.o] Error 1
    make: *** [Makefile:1544: _module_/tmp/stapnWDsqi] Error 2
    WARNING: kbuild exited with status: 2
    Pass 4: compiled C into "stap_ea515d442eab2d1921c7105860f0337f_3673.ko" in 46720usr/15990sys/64098real ms.
    Pass 4: compilation failed.  [man error::pass4]

This failure is caused by a typo of the name of an argument variable
of macro u_store_register introduced at the commit
a03b455bc656216a4829dbad08e630949d944c75.
---
 runtime/linux/loc2c-runtime.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtime/linux/loc2c-runtime.h b/runtime/linux/loc2c-runtime.h
index b4a329b..0270fa1 100644
--- a/runtime/linux/loc2c-runtime.h
+++ b/runtime/linux/loc2c-runtime.h
@@ -294,7 +294,7 @@ static void ursl_store64 (const struct usr_regset_lut* lut,unsigned lutsize,  in
 #define uu_store_register(_regs,regno,value)  (_stp_is_compat_task() ? ursl_store32(url_i386, ARRAY_SIZE(url_i386), EM_386, regno, value) : ursl_store64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno, value))
 
 #define u_fetch_register(regno) check_fetch_register(c->uregs,regno,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),uu_fetch_register)
-#define u_store_register(regno,value) check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
+#define u_store_register(regno,value) check_store_register(c->uregs,regno,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
 
 #endif
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] loc2c-runtime: fix compilation failure
  2020-02-07  4:07 [PATCH] loc2c-runtime: fix compilation failure d.hatayama
@ 2020-02-07  9:51 ` Mark Wielaard
  2020-02-07 10:11   ` d.hatayama
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2020-02-07  9:51 UTC (permalink / raw)
  To: d.hatayama; +Cc: 'systemtap@sourceware.org'

Hi,

On Fri, Feb 07, 2020 at 04:07:21AM +0000, d.hatayama@fujitsu.com wrote:
> I ran into the following compilation failure when I tried to change
> $return in a return probe for some user-space process:
> [...] 
> This failure is caused by a typo of the name of an argument variable
> of macro u_store_register introduced at the commit
> a03b455bc656216a4829dbad08e630949d944c75.
> ---
>  runtime/linux/loc2c-runtime.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/runtime/linux/loc2c-runtime.h b/runtime/linux/loc2c-runtime.h
> index b4a329b..0270fa1 100644
> --- a/runtime/linux/loc2c-runtime.h
> +++ b/runtime/linux/loc2c-runtime.h
> @@ -294,7 +294,7 @@ static void ursl_store64 (const struct usr_regset_lut* lut,unsigned lutsize,  in
>  #define uu_store_register(_regs,regno,value)  (_stp_is_compat_task() ? ursl_store32(url_i386, ARRAY_SIZE(url_i386), EM_386, regno, value) : ursl_store64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno, value))
>  
>  #define u_fetch_register(regno) check_fetch_register(c->uregs,regno,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),uu_fetch_register)
> -#define u_store_register(regno,value) check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
> +#define u_store_register(regno,value) check_store_register(c->uregs,regno,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
>  
>  #endif

This looks completely correct. The typo is pretty clear in the
original commit.  I am just surprised we haven't seen this issue
before since the commit was pushed almost a year ago. What was the
exact script that showed this issue? We should probably add it as a
testcase together with the fix.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] loc2c-runtime: fix compilation failure
  2020-02-07  9:51 ` Mark Wielaard
@ 2020-02-07 10:11   ` d.hatayama
  0 siblings, 0 replies; 3+ messages in thread
From: d.hatayama @ 2020-02-07 10:11 UTC (permalink / raw)
  To: 'Mark Wielaard'; +Cc: 'systemtap@sourceware.org'



> -----Original Message-----
> From: Mark Wielaard <mark@klomp.org>
> Sent: Friday, February 7, 2020 6:51 PM
> To: Hatayama, Daisuke/畑山 大輔 <d.hatayama@fujitsu.com>
> Cc: 'systemtap@sourceware.org' <systemtap@sourceware.org>
> Subject: Re: [PATCH] loc2c-runtime: fix compilation failure
> 
> Hi,
> 
> On Fri, Feb 07, 2020 at 04:07:21AM +0000, d.hatayama@fujitsu.com wrote:
> > I ran into the following compilation failure when I tried to change
> > $return in a return probe for some user-space process:
> > [...]
> > This failure is caused by a typo of the name of an argument variable
> > of macro u_store_register introduced at the commit
> > a03b455bc656216a4829dbad08e630949d944c75.
> > ---
> >  runtime/linux/loc2c-runtime.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/runtime/linux/loc2c-runtime.h b/runtime/linux/loc2c-runtime.h
> > index b4a329b..0270fa1 100644
> > --- a/runtime/linux/loc2c-runtime.h
> > +++ b/runtime/linux/loc2c-runtime.h
> > @@ -294,7 +294,7 @@ static void ursl_store64 (const struct usr_regset_lut* lut,unsigned lutsize,  in
> >  #define uu_store_register(_regs,regno,value)  (_stp_is_compat_task() ? ursl_store32(url_i386,
> ARRAY_SIZE(url_i386), EM_386, regno, value) : ursl_store64(url_x86_64, ARRAY_SIZE(url_x86_64), EM_X86_64, regno,
> value))
> >
> >  #define u_fetch_register(regno)
> check_fetch_register(c->uregs,regno,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),uu_fetc
> h_register)
> > -#define u_store_register(regno,value)
> check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,u
> u_store_register)
> > +#define u_store_register(regno,value)
> check_store_register(c->uregs,regno,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,u
> u_store_register)
> >
> >  #endif
> 
> This looks completely correct. The typo is pretty clear in the
> original commit.  I am just surprised we haven't seen this issue
> before since the commit was pushed almost a year ago. What was the
> exact script that showed this issue? We should probably add it as a
> testcase together with the fix.
> 

It's enough to reproduce the issue as follows on my system:

# cat ./repro.c
static int f(void)
{
  return 0;
}

int main()
{
  f();
}
# gcc -g -O0 ./repro.c -o repro
# stap -v -g -e 'probe process("./repro").function("f").return {$return = 1}' -c ./repro
Pass 1: parsed user script and 478 library scripts using 238948virt/80996res/12320shr/68280data kb, in 750usr/240sys/1001real ms.
Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using 240532virt/83832res/13444shr/69864data kb, in 20usr/10sys/48real ms.
Pass 3: translated to C into "/tmp/stapDh6s0j/stap_300c9b53758795cc27758f1eaadbf6bd_1183_src.c" using 240664virt/84332res/13696shr/69996data kb, in 170usr/290sys/474real ms.
In file included from /usr/share/systemtap/runtime/linux/runtime.h:217,
                 from /usr/share/systemtap/runtime/runtime.h:26,
                 from /tmp/stapDh6s0j/stap_300c9b53758795cc27758f1eaadbf6bd_1183_src.c:26:
/tmp/stapDh6s0j/stap_300c9b53758795cc27758f1eaadbf6bd_1183_src.c: In function ‘function___private__input___dwarf_tvar_set_return_0’:
/usr/share/systemtap/runtime/linux/loc2c-runtime.h:297:69: error: ‘regnoo’ undeclared (first use in this function); did you mean ‘rep_nop’?
 #define u_store_register(regno,value) check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
                                                                     ^~~~~~
/usr/share/systemtap/runtime/linux/loc2c-runtime.h:44:23: note: in definition of macro ‘check_store_register’
   if ((regs) == 0 || (regno) < 0 || (regno) > (maxregno)) {      \
                       ^~~~~
/tmp/stapDh6s0j/stap_300c9b53758795cc27758f1eaadbf6bd_1183_src.c:182:3: note: in expansion of macro ‘u_store_register’
   u_store_register(0, l->__tmp0);
   ^~~~~~~~~~~~~~~~
/usr/share/systemtap/runtime/linux/loc2c-runtime.h:297:69: note: each undeclared identifier is reported only once for each function it appears in
 #define u_store_register(regno,value) check_store_register(c->uregs,regnoo,_stp_is_compat_task()?ARRAY_SIZE(url_i386):ARRAY_SIZE(url_x86_64),value,uu_store_register)
                                                                     ^~~~~~
/usr/share/systemtap/runtime/linux/loc2c-runtime.h:44:23: note: in definition of macro ‘check_store_register’
   if ((regs) == 0 || (regno) < 0 || (regno) > (maxregno)) {      \
                       ^~~~~
/tmp/stapDh6s0j/stap_300c9b53758795cc27758f1eaadbf6bd_1183_src.c:182:3: note: in expansion of macro ‘u_store_register’
   u_store_register(0, l->__tmp0);
   ^~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:312: /tmp/stapDh6s0j/stap_300c9b53758795cc27758f1eaadbf6bd_1183_src.o] Error 1
make: *** [Makefile:1544: _module_/tmp/stapDh6s0j] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_300c9b53758795cc27758f1eaadbf6bd_1183.ko" in 45630usr/15450sys/62241real ms.
Pass 4: compilation failed.  [man error::pass4]

Thanks.
HATAYAMA, Daisuke

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-07 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07  4:07 [PATCH] loc2c-runtime: fix compilation failure d.hatayama
2020-02-07  9:51 ` Mark Wielaard
2020-02-07 10:11   ` d.hatayama

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).