diff mbox series

[2/8] trace-cruncher: Fix bug in the constructor if tc_synth class

Message ID 20220210152339.363943-3-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series trace-cruncher:Fixes before v0.2 (Beta) | expand

Commit Message

Yordan Karadzhov Feb. 10, 2022, 3:23 p.m. UTC
There is a missing argument when calling one of the low-level APIs for
synthetic events (add_sum()). In the patch we also add comments, in order
to make this part of the code more readable.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 tracecruncher/ft_utils.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tracecruncher/ft_utils.py b/tracecruncher/ft_utils.py
index f4d1f05..7e0e642 100644
--- a/tracecruncher/ft_utils.py
+++ b/tracecruncher/ft_utils.py
@@ -357,6 +357,8 @@  class tc_synth(tc_event):
             for f in synth_fields:
                 args = f.split(' ')
                 if args[0] == 'delta_t' and len(args) < 4:
+                    # The expected format is: 'delta_t [name] hd'.
+                    # Arguments 1 and 2 are optional.
                     if len(args) == 1:
                         self.synth.add_delta_T()
                     elif len(args) == 3 and args[2] == 'hd':
@@ -366,15 +368,26 @@  class tc_synth(tc_event):
                     else:
                         self.synth.add_delta_T(name=args[1])
                 elif args[0] == 'delta_start' and len(args) == 4:
+                    # The expected format is:
+                    # 'delta_start [name] [start_field] [end_field]'.
                     self.synth.add_delta_start(name=args[1],
                                                start_field=args[2],
                                                end_field=args[3])
+
                 elif args[0] == 'delta_end' and len(args) == 4:
+                    # The expected format is:
+                    # 'delta_end [name] [start_field] [end_field]'.
                     self.synth.add_delta_end(name=args[1],
                                              start_field=args[2],
                                              end_field=args[3])
-                elif args[0] == 'delta_start' and len(args) == 3:
-                    self.synth.add_sum(start_field=args[1], end_field=args[2])
+
+                elif args[0] == 'sun' and len(args) == 4:
+                    # The expected format is:
+                    # 'sum [name] [start_field] [end_field]'.
+                    self.synth.add_sum(name=args[1],
+                                       start_field=args[2],
+                                       end_field=args[3])
+
                 else:
                     raise ValueError('Invalid synth. field \'{0}\''.format(f))