[lttng-dev] [PATCH babeltrace] Make examples work

Jérémie Galarneau jeremie.galarneau at efficios.com
Wed Jul 24 15:32:12 EDT 2013


This patch depends on the other two you submitted. Resubmit them as a
series. Use git format-patch's "-n" option for that.

Also, please provide a clearer commit message.

Regards,
Jérémie

On Wed, Jul 24, 2013 at 5:57 AM, Xiaona Han <xiaonahappy13 at 163.com> wrote:
> Signed-off-by: Xiaona Han <xiaonahappy13 at 163.com>
> ---
>  bindings/python/examples/example-api-test.py |   16 +++++--------
>  bindings/python/examples/sched_switch.py     |   32 +++++++++++++-------------
>  2 files changed, 22 insertions(+), 26 deletions(-)
>
> diff --git a/bindings/python/examples/example-api-test.py b/bindings/python/examples/example-api-test.py
> index fc59e24..3c3527c 100644
> --- a/bindings/python/examples/example-api-test.py
> +++ b/bindings/python/examples/example-api-test.py
> @@ -50,23 +50,19 @@ while(event is not None):
>                 event.get_cycles(), event.get_name()))
>
>         if event.get_name() == "sched_switch":
> -               sco = event.get_top_level_scope(ctf.scope.EVENT_FIELDS)
> -               prev_field = event.get_field(sco, "_prev_comm")
> -               prev_comm = prev_field.get_char_array()
> -
> -               if ctf.field_error():
> +               prev_field = event.get_field("_prev_comm")
> +               if not prev_field:
>                         print("ERROR: Missing prev_comm context info")
>                 else:
> +                       prev_comm = prev_field[0].getvalue()
>                         print("sched_switch prev_comm: {}".format(prev_comm))
>
>         if event.get_name() == "exit_syscall":
> -               sco = event.get_top_level_scope(ctf.scope.EVENT_FIELDS)
> -               ret_field = event.get_field(sco, "_ret")
> -               ret_code = ret_field.get_int64()
> -
> -               if ctf.field_error():
> +               ret_field = event.get_field("_ret")
> +               if not ret_field:
>                         print("ERROR: Unable to extract ret")
>                 else:
> +                       ret_code = ret_field[0].get_value()
>                         print("exit_syscall ret: {}".format(ret_code))
>
>         ret = ctf_it.next()
> diff --git a/bindings/python/examples/sched_switch.py b/bindings/python/examples/sched_switch.py
> index d5ed25b..0e6947c 100644
> --- a/bindings/python/examples/sched_switch.py
> +++ b/bindings/python/examples/sched_switch.py
> @@ -57,8 +57,8 @@ while event is not None:
>                                 break # Next event
>
>                         # Getting PID
> -                       pid_field = event.get_field(sco, "_pid")
> -                       pid = pid_field.get_int64()
> +                       pid_field = event.get_field_with_scope(sco, "_pid")
> +                       pid = pid_field.get_value()
>
>                         if ctf.field_error():
>                                 print("ERROR: Missing PID info for sched_switch")
> @@ -70,44 +70,44 @@ while event is not None:
>                         sco = event.get_top_level_scope(ctf.scope.EVENT_FIELDS)
>
>                         # prev_comm
> -                       field = event.get_field(sco, "_prev_comm")
> -                       prev_comm = field.get_char_array()
> +                       field = event.get_field_with_scope(sco, "_prev_comm")
> +                       prev_comm = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing prev_comm context info")
>
>                         # prev_tid
> -                       field = event.get_field(sco, "_prev_tid")
> -                       prev_tid = field.get_int64()
> +                       field = event.get_field_with_scope(sco, "_prev_tid")
> +                       prev_tid = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing prev_tid context info")
>
>                         # prev_prio
> -                       field = event.get_field(sco, "_prev_prio")
> -                       prev_prio = field.get_int64()
> +                       field = event.get_field_with_scope(sco, "_prev_prio")
> +                       prev_prio = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing prev_prio context info")
>
>                         # prev_state
> -                       field = event.get_field(sco, "_prev_state")
> -                       prev_state = field.get_int64()
> +                       field = event.get_field_with_scope(sco, "_prev_state")
> +                       prev_state = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing prev_state context info")
>
>                         # next_comm
> -                       field = event.get_field(sco, "_next_comm")
> -                       next_comm = field.get_char_array()
> +                       field = event.get_field_with_scope(sco, "_next_comm")
> +                       next_comm = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing next_comm context info")
>
>                         # next_tid
> -                       field = event.get_field(sco, "_next_tid")
> -                       next_tid = field.get_int64()
> +                       field = event.get_field_with_scope(sco, "_next_tid")
> +                       next_tid = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing next_tid context info")
>
>                         # next_prio
> -                       field = event.get_field(sco, "_next_prio")
> -                       next_prio = field.get_int64()
> +                       field = event.get_field_with_scope(sco, "_next_prio")
> +                       next_prio = field.get_value()
>                         if ctf.field_error():
>                                 print("ERROR: Missing next_prio context info")
>
> --
> 1.7.1
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list