public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: 张威 <1541469@tongji.edu.cn>
To: systemtap@sourceware.org
Subject: I meet errors when I modify the return value or parameters of userspace function by systemtap
Date: Mon, 27 Apr 2020 13:06:33 +0800 (GMT+08:00)	[thread overview]
Message-ID: <6ed9aec7.689c.171ba079cd2.Coremail.1541469@tongji.edu.cn> (raw)

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
*******************************************************

             reply	other threads:[~2020-04-27  5:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27  5:06 张威 [this message]
2020-04-27 18:17 ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ed9aec7.689c.171ba079cd2.Coremail.1541469@tongji.edu.cn \
    --to=1541469@tongji.edu.cn \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).