public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* I meet errors when I modify the return value or parameters of userspace function by systemtap
@ 2020-04-27  5:06 张威
  2020-04-27 18:17 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: 张威 @ 2020-04-27  5:06 UTC (permalink / raw)
  To: systemtap

I meet errors when I modify the return value or parameters of userspace function by systemtap.

My test program is as follows:

#include <stdio.h>

int func(int *p, int val)
{
        printf("p=%p val=%d\n", p, val);
        return 1;
}

int main()
{
        int a = 7;
        func(&a, a);
        return 0;
}

gcc -g -o test test.c

I try:

# stap -e 'probe process("./test").function("func").return { $return = 8}' -g
It report:

In file included from /usr/local/share/systemtap/runtime/linux/runtime.h:217:0,
                 from /usr/local/share/systemtap/runtime/runtime.h:26,
                 from /tmp/stapT3qC74/stap_9773c65134daae52581873c5e83f3c28_1223_src.c:26:
/tmp/stapT3qC74/stap_9773c65134daae52581873c5e83f3c28_1223_src.c: In function ‘function___private__input___dwarf_tvar_set_return_0’:
root@redis-server1:/home/fit508/test# stap -e 'probe process("./test").function("func").return { $return = 8}' -g
In file included from /usr/local/share/systemtap/runtime/linux/runtime.h:217:0,
                 from /usr/local/share/systemtap/runtime/runtime.h:26,
                 from /tmp/stapMDBcSh/stap_9773c65134daae52581873c5e83f3c28_1223_src.c:26:
/tmp/stapMDBcSh/stap_9773c65134daae52581873c5e83f3c28_1223_src.c: In function ‘function___private__input___dwarf_tvar_set_return_0’:
/usr/local/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/local/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/stapMDBcSh/stap_9773c65134daae52581873c5e83f3c28_1223_src.c:182:3: note: in expansion of macro ‘u_store_register’
   u_store_register(0, l->__tmp0);
   ^~~~~~~~~~~~~~~~
/usr/local/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/local/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/stapMDBcSh/stap_9773c65134daae52581873c5e83f3c28_1223_src.c:182:3: note: in expansion of macro ‘u_store_register’
   u_store_register(0, l->__tmp0);
   ^~~~~~~~~~~~~~~~
scripts/Makefile.build:330: recipe for target '/tmp/stapMDBcSh/stap_9773c65134daae52581873c5e83f3c28_1223_src.o' failed
make[1]: *** [/tmp/stapMDBcSh/stap_9773c65134daae52581873c5e83f3c28_1223_src.o] Error 1
Makefile:1577: recipe for target '_module_/tmp/stapMDBcSh' failed
make: *** [_module_/tmp/stapMDBcSh] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed.  [man error::pass4]
but I can trace its return value of funcion, it work well:

# stap -e 'probe process("./test").function("func").returnntf("%d\n", $return);}' -g
1
So, I want to ask if i can modify the return value of the user space function, just like system call function example in http://www.programmersought.com/article/9329729776/.

my os is :ubuntu 18.04, kernel is 4.15.0-96
systemtap version: 4.2
gcc version: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0


--
-------------------------------------------------------------------------------
Zhang Wei  
Email. 1541469@tongji.edu.cn
*******************************************************

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

* Re: I meet errors when I modify the return value or parameters of userspace function by systemtap
  2020-04-27  5:06 I meet errors when I modify the return value or parameters of userspace function by systemtap 张威
@ 2020-04-27 18:17 ` Frank Ch. Eigler
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2020-04-27 18:17 UTC (permalink / raw)
  To: 张威; +Cc: systemtap

张威 <1541469@tongji.edu.cn> writes:

> /usr/local/share/systemtap/runtime/linux/loc2c-runtime.h:297:69: error: ‘regnoo’ undeclared (first use in this function); did you mean ‘rep_nop’?
> [...]

You're doing nothing wrong; we had a typo.  The following patch fixes
it.  You can hand-apply the change to your copy of
/usr/share/systemtap/runtime/linux/loc2c-runtime.h .

commit ccad93fd0f81851fd69ff0257c6010a8d1984c8c
Author: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date:   Fri Feb 7 04:07:21 2020 +0000

https://sourceware.org/git/?p=systemtap.git;a=commitdiff;h=ccad93fd0f81851fd69ff0257c6010a8d1984c8c

- FChE


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

end of thread, other threads:[~2020-04-27 18:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27  5:06 I meet errors when I modify the return value or parameters of userspace function by systemtap 张威
2020-04-27 18:17 ` Frank Ch. Eigler

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).