Bug 23599 - Use of usymname() with stap -u leads to kernel module compilation errors
Summary: Use of usymname() with stap -u leads to kernel module compilation errors
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: tapsets (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-30 23:22 UTC by agentzh
Modified: 2018-09-16 03:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description agentzh 2018-08-30 23:22:58 UTC
Consider the following minimal example:

```
$ stap -e 'probe oneshot { println(usymname(0xdeadbeef)) }' -u
/tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.c: In function ‘function___global_print_ubacktrace__overload_0’:
/tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.c:1103:5: error: implicit declaration of function ‘_stp_stack_user_print’; did you mean ‘_stp_stat_per_cpu_ptr’? [-Werror=implicit-function-declaration]
     _stp_stack_user_print(CONTEXT, _STP_SYM_FULL);
     ^~~~~~~~~~~~~~~~~~~~~
     _stp_stat_per_cpu_ptr
/tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.c: In function ‘function___global_sprint_ubacktrace__overload_0’:
/tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.c:1365:5: error: implicit declaration of function ‘_stp_stack_user_sprint’; did you mean ‘_stp_store_deref_string’? [-Werror=implicit-function-declaration]
     _stp_stack_user_sprint (STAP_RETVALUE, MAXSTRINGLEN, CONTEXT,
     ^~~~~~~~~~~~~~~~~~~~~~
     _stp_store_deref_string
/tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.c: In function ‘function___private__opt_stap_old_share_systemtap_tapset_linux_ucontext_symbols_stp___ustack_raw__overload_0’:
/tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.c:2848:35: error: implicit declaration of function ‘_stp_stack_user_get’; did you mean ‘_stp_stat_get’? [-Werror=implicit-function-declaration]
                   STAP_RETVALUE = _stp_stack_user_get (CONTEXT, (unsigned)STAP_ARG_n);
                                   ^~~~~~~~~~~~~~~~~~~
                                   _stp_stat_get
cc1: all warnings being treated as errors
make[1]: *** [scripts/Makefile.build:324: /tmp/stapcgQk9g/stap_ca4ae4c5dee3b96fa22873c547018f71_10015_src.o] Error 1
make: *** [Makefile:1565: _module_/tmp/stapcgQk9g] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed.  [man error::pass4]
```

After removing the `-u` command-line option, this example works as expected immediately:

```
$ stap -e 'probe oneshot { println(usymname(0xdeadbeef)) }'
0xdeadbeef
```

Seems like use of `usymname()` brings in other unused tapset functions like `__ustack_raw` in the same tapset file (tapset/linux/ucontext-symbols.stp) but for some reasons, their `/* unwind */` pragma fails to set the `need_unwind` flag in the `systemtap_session` object.
Comment 1 agentzh 2018-08-30 23:47:44 UTC
OK, the following quick patch seems to fix this issue:

https://pastebin.com/K1hyYXjq

I'll prepare a formal patch to the mailing list for formal review :)
Comment 2 agentzh 2018-09-16 03:18:12 UTC
Already committed a fix to master via commit 0ff547ede.