All of lore.kernel.org
 help / color / mirror / Atom feed
* bogus values of variables in userspace probes
@ 2015-11-24 11:18 Michael Petlan
  2015-11-24 14:54 ` Arnaldo Carvalho de Melo
  2015-11-24 15:08 ` bogus values of variables in userspace probes Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 16+ messages in thread
From: Michael Petlan @ 2015-11-24 11:18 UTC (permalink / raw)
  To: linux-perf-users

[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]

Hi *,

I have been playing with perf-probe tool and I found out that some bogus
values of a function argument are obtained by perf-record.

How to reproduce:

gcc -O0 -g -o dummy dummy.c
perf probe -x ./dummy --add 'isprime a'
perf record -e probe_dummy:isprime ./dummy
perf script

The actual output looks like the following:

dummy 32476 [000] 3534401.838454: probe_dummy:isprime: (400530) a=32767
dummy 32476 [000] 3534401.838504: probe_dummy:isprime: (400530) a=32714
dummy 32476 [000] 3534401.838513: probe_dummy:isprime: (400530) a=3
dummy 32476 [000] 3534401.838519: probe_dummy:isprime: (400530) a=4
dummy 32476 [000] 3534401.838525: probe_dummy:isprime: (400530) a=5
dummy 32476 [000] 3534401.838531: probe_dummy:isprime: (400530) a=6
dummy 32476 [000] 3534401.838537: probe_dummy:isprime: (400530) a=7
dummy 32476 [000] 3534401.838543: probe_dummy:isprime: (400530) a=13
dummy 32476 [000] 3534401.838561: probe_dummy:isprime: (400530) a=17

But if you look into the source, you can see that the function isprime()
is called with the following arguments:

int numbers[] = { 2, 3, 4, 5, 6, 7, 13, 17, 19 };

So the first and last ones are omitted, there are some bogus numbers instead
of them and all that is shifted somehow.

Note that when I probe for %ax register it looks correct.

The version of kernel/perf is 4.3.0. The architecture is x86_64.
Am I missing something or is it a bug?

Thank you!
Michael


[-- Attachment #2: dummy.c --]
[-- Type: text/x-csrc, Size: 381 bytes --]

#include <stdlib.h>
#include <stdio.h>

int isprime(int a)
{
	int i;
	if(a <= 1)
		return 0;
	for(i = 2; i <= a / 2; i++)
		if(!(a % i))
			return 0;
	return 1;
}

int main(int argc, char **argv)
{
	int numbers[] = { 2, 3, 4, 5, 6, 7, 13, 17, 19 };
	int i;

	for(i = 0; i < 9; i++)
	{
		printf("%i %s prime\n", numbers[i], (isprime(numbers[i]))? "is" : "is not");
	}

	return 0;
}

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

end of thread, other threads:[~2015-11-25 19:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 11:18 bogus values of variables in userspace probes Michael Petlan
2015-11-24 14:54 ` Arnaldo Carvalho de Melo
2015-11-24 16:13   ` Arnaldo Carvalho de Melo
2015-11-25  6:32     ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-25 10:34   ` [BUGFIX PATCH perf/core ] perf probe: Fix to free temporal Dwarf_Frame correctly Masami Hiramatsu
2015-11-24 15:08 ` bogus values of variables in userspace probes Arnaldo Carvalho de Melo
2015-11-24 18:30   ` Michael Petlan
2015-11-24 19:16     ` Arnaldo Carvalho de Melo
2015-11-25 13:25       ` Michael Petlan
2015-11-25 13:33         ` Jiri Olsa
2015-11-25 14:43           ` perftool-testsuite was: " Arnaldo Carvalho de Melo
2015-11-25 15:58             ` Michael Petlan
2015-11-25 19:27               ` Arnaldo Carvalho de Melo
2015-11-25 15:07         ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-25  1:03     ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-25  2:24       ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.