Bug 17362 - no script-level local variables available in F20's kernel.function("do_execve")
Summary: no script-level local variables available in F20's kernel.function("do_execve")
Status: RESOLVED INVALID
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-08 15:15 UTC by Martin Cermak
Modified: 2014-10-06 21:12 UTC (History)
2 users (show)

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 Martin Cermak 2014-09-08 15:15:40 UTC
No script-level local variables available in F20's kernel.function("do_execve"). This changed between 3.13.9-200.fc20 and 3.15.10-201.fc20:

# uname -r; rpm -q systemtap
3.13.9-200.fc20.x86_64
systemtap-2.7-1.mcermak.e454243.fc20.x86_64
# stap -L 'kernel.function("do_execve")'
kernel.function("do_execve@fs/exec.c:1575") $filename:char const* $__argv:char const* const* $__envp:char const* const*
#
# stap -e 'probe kernel.function("do_execve"){log(user_string($__argv[0]))}' -c /bin/true
/bin/true
#

# uname -r; rpm -q systemtap
3.15.10-201.fc20.x86_64
systemtap-2.7-1.mcermak.e454243.fc20.x86_64
# stap -L 'kernel.function("do_execve")'
kernel.function("do_execve@fs/exec.c:1547")
#
# stap -e 'probe kernel.function("do_execve"){log(user_string($__argv[0]))}' -c /bin/true
semantic error: failed to retrieve location attribute for '__argv' [man error::dwarf]: identifier '$__argv' at <input>:1:52
        dieoffset: 0x186983f from unknown debug file for kernel
        function: do_execve at fs/exec.c:1553 inlined by SYSC_execve at fs/exec.c:1607 inlined by SyS_execve at fs/exec.c:1602
        source: probe kernel.function("do_execve"){log(user_string($__argv[0]))}
                                                                   ^

Pass 2: analysis failed.  [man error::pass2]
#


The function declaration didn't change significantly:
=====
# grep -A 8 '^int do_execve' /usr/src/debug/kernel-3.13.fc20/linux-3.13.9-200.fc20.x86_64/fs/exec.c
int do_execve(const char *filename,
        const char __user *const __user *__argv,
        const char __user *const __user *__envp)
{
        struct user_arg_ptr argv = { .ptr.native = __argv };
        struct user_arg_ptr envp = { .ptr.native = __envp };
        return do_execve_common(filename, argv, envp);
}

# grep -A 8 '^int do_execve' /usr/src/debug/kernel-3.15.fc20/linux-3.15.10-201.fc20.x86_64/fs/exec.c
int do_execve(struct filename *filename,
        const char __user *const __user *__argv,
        const char __user *const __user *__envp)
{
        struct user_arg_ptr argv = { .ptr.native = __argv };
        struct user_arg_ptr envp = { .ptr.native = __envp };
        return do_execve_common(filename, argv, envp);
}
#
=====

This breaks systemtap.base/pointer_array.exp testcase on newer f20 kernels.
Comment 1 Frank Ch. Eigler 2014-09-08 15:34:09 UTC
Chances are this is related to
https://bugzilla.redhat.com/show_bug.cgi?id=1126580
Comment 2 Josh Stone 2014-09-08 18:37:56 UTC
If you use a script like:

  probe f = kernel.function("do_execve"){}
  probe f.call, f.inline { println($$parms) }

in pass-2 output you'll see:

  kernel.function("do_execve@fs/exec.c:1547").call /* pc=_stext+0x1edf38 */ /* <- kernel.function("do_execve@fs/exec.c:1547").call */
  println(sprintf("filename=%#x __argv=%#x __envp=%#x", _dwarf_tvar_get_filename_0(), _dwarf_tvar_get___argv_1(), _dwarf_tvar_get___envp_2()))

  kernel.function("do_execve@fs/exec.c:1547").inline /* pc=_stext+0x1ee16f */ /* <- kernel.function("do_execve@fs/exec.c:1547").inline */
  println(sprintf("__envp=? __argv=? filename=?"))

So there's a full .call function which has all the parameters available, and an .inline instance which has none of them.


(In reply to Frank Ch. Eigler from comment #1)
> Chances are this is related to
> https://bugzilla.redhat.com/show_bug.cgi?id=1126580

The producer string does indeed include -fno-var-tracking-assignments.
Comment 3 Martin Cermak 2014-09-09 15:19:36 UTC
Very similar issue affecting at_var.exp. Old kernel:

=====
# rpm -q systemtap; uname -r
systemtap-2.7-1.mcermak.e454243.fc20.x86_64
3.13.9-200.fc20.x86_64
# cat systemtap.base/at_var.c
#include <sys/time.h>

struct foo
{
  int bar;
};

static struct foo foo;

void sub(const char *file)
{
  struct timeval times[2];
  times[0].tv_sec = 1;
  times[0].tv_usec = 2;
  times[1].tv_sec = 3;
  times[1].tv_usec = 4;
  utimes (file, times);
  foo.bar -= 2; /* 40 */
}

int
main (int argc, char **argv)
{
  foo.bar = 41 + argc; /* 42 */
  sub(argv[0]);
  return 0;
}
# gcc -g systemtap.base/at_var.c
# stap -e 'probe kernel.function("SYSC_utimes") {println($utimes$$, $utimes[1]$$, @var("utimes")$$, @var("utimes")[1]$$)}' -c ./a.out 
{.tv_sec=1, .tv_usec=2}{.tv_sec=3, .tv_usec=4}{.tv_sec=1, .tv_usec=2}{.tv_sec=3, .tv_usec=4}
#
=====

new kernel:

=====
# rpm -q systemtap; uname -r
systemtap-2.7-1.mcermak.e454243.fc20.x86_64
3.15.10-201.fc20.x86_64
# gcc -g systemtap.base/at_var.c
# stap -e 'probe kernel.function("SYSC_utimes") {println($utimes$$, $utimes[1]$$, @var("utimes")$$, @var("utimes")[1]$$)}' -c ./a.out
{.tv_sec=?, .tv_usec=?}{.tv_sec=?, .tv_usec=?}{.tv_sec=?, .tv_usec=?}{.tv_sec=?, .tv_usec=?}
#
=====
Comment 4 Frank Ch. Eigler 2014-10-06 21:12:46 UTC
There is no systemtap bug here; the kernel compilation simply is
slightly (mis)configured to lack full debuginfo.