lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87vbr72bi7.fsf@sejong.aot.lge.com>
Date:	Wed, 09 Jul 2014 17:16:00 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Joseph Schuchart <joseph.schuchart@...dresden.de>
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...hat.com>,
	Thomas Ilsche <thomas.ilsche@...dresden.de>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3]  perf script: Provide additional sample information on generic events

On Wed, 09 Jul 2014 09:40:36 +0200, Joseph Schuchart wrote:
>  [PATCH 3/3]  perf script: Provide additional sample information on
>  generic events  to Python scripts, including pid, tid, and cpu for which the
>  event was  recorded. At the moment, the pointer to the sample struct is
>  passed to  scripts, which seems to be of little use. The patch puts this
>  information in  dictionaries for easy access by Python scripts.
>
> Signed-off-by: Joseph Schuchart <joseph.schuchart@...dresden.de>
> Acked-by: Thomas Ilsche <thomas.ilsche@...dresden.de>

Acked-by: Namhyung Kim <namhyung@...nel.org>

Thanks,
Namhyung


> ---
>  .../util/scripting-engines/trace-event-python.c    | 23 +++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index dae78e4..64923cd 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -446,7 +446,7 @@ static void python_process_general_event(struct perf_sample *sample,
>  					 struct thread *thread,
>  					 struct addr_location *al)
>  {
> -	PyObject *handler, *retval, *t, *dict, *callchain;
> +	PyObject *handler, *retval, *t, *dict, *callchain, *dict_sample;
>  	static char handler_name[64];
>  	unsigned n = 0;
>  
> @@ -462,6 +462,10 @@ static void python_process_general_event(struct perf_sample *sample,
>  	if (!dict)
>  		Py_FatalError("couldn't create Python dictionary");
>  
> +	dict_sample = PyDict_New();
> +	if (!dict_sample)
> +		Py_FatalError("couldn't create Python dictionary");
> +
>  	snprintf(handler_name, sizeof(handler_name), "%s", "process_event");
>  
>  	handler = PyDict_GetItemString(main_dict, handler_name);
> @@ -471,8 +475,21 @@ static void python_process_general_event(struct perf_sample *sample,
>  	pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
>  	pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
>  			(const char *)&evsel->attr, sizeof(evsel->attr)));
> -	pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize(
> -			(const char *)sample, sizeof(*sample)));
> +
> +	pydict_set_item_string_decref(dict_sample, "pid",
> +			PyInt_FromLong(sample->pid));
> +	pydict_set_item_string_decref(dict_sample, "tid",
> +			PyInt_FromLong(sample->tid));
> +	pydict_set_item_string_decref(dict_sample, "cpu",
> +			PyInt_FromLong(sample->cpu));
> +	pydict_set_item_string_decref(dict_sample, "ip",
> +			PyLong_FromUnsignedLongLong(sample->ip));
> +	pydict_set_item_string_decref(dict_sample, "time",
> +			PyLong_FromUnsignedLongLong(sample->time));
> +	pydict_set_item_string_decref(dict_sample, "period",
> +			PyLong_FromUnsignedLongLong(sample->period));
> +	pydict_set_item_string_decref(dict, "sample", dict_sample);
> +
>  	pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
>  			(const char *)sample->raw_data, sample->raw_size));
>  	pydict_set_item_string_decref(dict, "comm",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ