fche changed the topic of #systemtap to: http://sourceware.org/systemtap; email systemtap@sourceware.org if answers here not timely, conversations may be logged
derek0883 has joined #systemtap
<derek0883> anyone knows how to access kernel global variables?
<fche> @var("foo") or $foo from a probe context where $foo is in scope
<derek0883> cool, thanks @fche
<derek0883> @fche, printf("command = %p\n", @var("boot_command_line")); works. however. printf("command = %s\n", kernel_string(@var("boot_command_line"))); got runtime error. do you know why?
hpt has joined #systemtap
<fche> hm no, is the %p pointer value plausible?
<derek0883> yes, %p result exactly matches sudo cat /proc/kallsyms | grep boot_command_line
<fche> hm I wonder if it's some kernel pointer checking paranoia at work
<fche> what's your kernel version?
<derek0883> 4.15.18
<derek0883> ERROR: kernel string copy fault at 0x00000000f6e778ec [man error::fault] near identifier 'kernel_string' at /usr/local/share/systemtap/tapset/linux/conversions.stp:18:10
<fche> can you paste your stap script more completely?
<fche> stap -e 'probe kernel.function("do_exit") { printf("command = %s\n", kernel_string(@var("boot_command_line"))) }'
<fche> is what I'm using here (kernel probe to put it in kernel context), but I'm not getting errors, only empty strings
<fche> are these ordinary char*'s in the kernel or something different?
<derek0883> #! /usr/bin/env stap
<derek0883> probe begin {
<derek0883> printf("command = %p\n", @var("boot_command_line"));
<derek0883> printf("command = %s\n", kernel_string(@var("boot_command_line")));
<derek0883> exit();
<derek0883> }
<fche> (btw that won't work on 4.4+ stap; you'll need --compatible=4.3 or something, because probe begin is not a @var()capable context directly)
<fche> but anyway
<fche> I see no errors here 5.9.10-200.fc33.x86_64 as the kernel, just empty strings
<derek0883> got it, thanks
<fche> oh I'm also using stap 4.4, that MIGHT make a difference
<derek0883> Systemtap translator/driver (version 4.1/0.165
<derek0883> I'm using old version, maybe that's difference
<fche> conceivably .......
<fche> any other such global char*'s you can think of printing?
<fche> printf("command = %.*M\n", 20, @var("boot_command_line")); <<< hex-dumps that
<fche> and here on my box that's a bunch of zeroes
<fche> wonder why
<derek0883> another one is command_line, but I got same result. let me think other one.
<fche> yeah no read error hear, just \0's.
<fche> (I can trigger read faults with bad addresses like 0x0)
<derek0883> printf("command = %s\n", kernel_string(@var("last_unloaded_module")));
<derek0883> this last_unloaded_module works
<fche> ditto here
<fche> wonder if something's special about those few you chose - maybe copied at boot time somewhere, then cleared in this copy
<fche> dunno
<derek0883> I think you are right
<derek0883> printf("command = %s\n", kernel_string(@var("saved_command_line")));
<derek0883> this one works
hpt has quit [Ping timeout: 276 seconds]
<fche> wild
pviktori has quit [Ping timeout: 256 seconds]
pviktori has joined #systemtap
mjw has quit [Quit: Leaving]
orivej has joined #systemtap
wynn1212 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 276 seconds]
derek0883 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
derek0883 has quit [Ping timeout: 264 seconds]
_whitelogger has joined #systemtap
ggherdov_ has quit [Changing host]
ggherdov_ has joined #systemtap
ggherdov_ has joined #systemtap
ggherdov_ has quit [Changing host]
ggherdov_ is now known as ggherdov
orivej has joined #systemtap
derek0883 has joined #systemtap
derek0883 has quit [Ping timeout: 264 seconds]
eichiro has quit [*.net *.split]
eichiro has joined #systemtap
fdalleau_away is now known as fdalleau
derek0883 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
<derek0883> Hi @fche I can get address by @var("nmi_desc"), nmi_desc is a array name, do you know how can I access like an array? currently I can only access nmi_desc[0]. is there any better way that I don't have to manually calculate offset? thanks.
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
fdalleau is now known as fdalleau_away
orivej has quit [Ping timeout: 245 seconds]
orivej has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 246 seconds]
derek0883 has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
<fche> if the type is not forward-declared or something incomplete, you should be able to say @var("nmi_desc")[1] and so on
khaled has quit [Quit: Konversation terminated!]
khaled has joined #systemtap
derek0883 has quit [Remote host closed the connection]
derek0883 has joined #systemtap
derek0883 has quit [Ping timeout: 264 seconds]
derek0883 has joined #systemtap