Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
11cb3bc1
Commit
11cb3bc1
authored
Mar 24, 2016
by
Sasha Goldshtein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowing more natural syntax for tracepoints with no "tp" struct prefix
parent
3abb8d69
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
9 deletions
+26
-9
man/man8/argdist.8
man/man8/argdist.8
+4
-3
man/man8/trace.8
man/man8/trace.8
+4
-2
src/python/bcc/tracepoint.py
src/python/bcc/tracepoint.py
+18
-4
No files found.
man/man8/argdist.8
View file @
11cb3bc1
...
@@ -92,7 +92,8 @@ You may use the parameters directly, or valid C expressions that involve the
...
@@ -92,7 +92,8 @@ You may use the parameters directly, or valid C expressions that involve the
parameters, such as "size % 10".
parameters, such as "size % 10".
Tracepoints may access a special structure called "tp" that is formatted according
Tracepoints may access a special structure called "tp" that is formatted according
to the tracepoint format (which you can obtain using tplist). For example, the
to the tracepoint format (which you can obtain using tplist). For example, the
block:block_rq_complete tracepoint can access tp.nr_sector.
block:block_rq_complete tracepoint can access tp.nr_sector. You may also use the
members of the "tp" struct directly, e.g. "nr_sector" instead of "tp.nr_sector".
Return probes can use the argument values received by the
Return probes can use the argument values received by the
function when it was entered, through the $entry(paramname) special variable.
function when it was entered, through the $entry(paramname) special variable.
Return probes can also access the function's return value in $retval, and the
Return probes can also access the function's return value in $retval, and the
...
@@ -147,11 +148,11 @@ Count fork() calls in libc across all processes, grouped by pid:
...
@@ -147,11 +148,11 @@ Count fork() calls in libc across all processes, grouped by pid:
.TP
.TP
Print histogram of number of sectors in completing block I/O requests:
Print histogram of number of sectors in completing block I/O requests:
#
#
.B argdist -H 't:block:block_rq_complete():u32:
tp.
nr_sector'
.B argdist -H 't:block:block_rq_complete():u32:nr_sector'
.TP
.TP
Aggregate interrupts by interrupt request (IRQ):
Aggregate interrupts by interrupt request (IRQ):
#
#
.B argdist -C 't:irq:irq_handler_entry():int:
tp.
irq'
.B argdist -C 't:irq:irq_handler_entry():int:irq'
.TP
.TP
Print histograms of sleep() and nanosleep() parameter values:
Print histograms of sleep() and nanosleep() parameter values:
#
#
...
...
man/man8/trace.8
View file @
11cb3bc1
...
@@ -92,7 +92,9 @@ same special keywords as in the predicate (arg1, arg2, etc.).
...
@@ -92,7 +92,9 @@ same special keywords as in the predicate (arg1, arg2, etc.).
In tracepoints, both the predicate and the arguments may refer to the tracepoint
In tracepoints, both the predicate and the arguments may refer to the tracepoint
format structure, which is stored in the special "tp" variable. For example, the
format structure, which is stored in the special "tp" variable. For example, the
block:block_rq_complete tracepoint can print or filter by tp.nr_sector. To
block:block_rq_complete tracepoint can print or filter by tp.nr_sector. To
discover the format of your tracepoint, use the tplist tool.
discover the format of your tracepoint, use the tplist tool. Note that you can
also use the members of the "tp" struct directly, e.g "nr_sector" instead of
"tp.nr_sector".
The predicate expression and the format specifier replacements for printing
The predicate expression and the format specifier replacements for printing
may also use the following special keywords: $pid, $tgid to refer to the
may also use the following special keywords: $pid, $tgid to refer to the
...
@@ -118,7 +120,7 @@ Trace returns from the readline function in bash and print the return value as a
...
@@ -118,7 +120,7 @@ Trace returns from the readline function in bash and print the return value as a
.TP
.TP
Trace the block:block_rq_complete tracepoint and print the number of sectors completed:
Trace the block:block_rq_complete tracepoint and print the number of sectors completed:
#
#
.B trace 't:block:block_rq_complete """%d sectors"",
tp.
nr_sector'
.B trace 't:block:block_rq_complete """%d sectors"", nr_sector'
.SH SOURCE
.SH SOURCE
This is from bcc.
This is from bcc.
.IP
.IP
...
...
src/python/bcc/tracepoint.py
View file @
11cb3bc1
...
@@ -109,11 +109,12 @@ int __trace_entry_update(struct pt_regs *ctx)
...
@@ -109,11 +109,12 @@ int __trace_entry_update(struct pt_regs *ctx)
self
.
category
=
category
self
.
category
=
category
self
.
event
=
event
self
.
event
=
event
self
.
tp_id
=
tp_id
self
.
tp_id
=
tp_id
self
.
_retrieve_struct_fields
()
def
_generate_struct_fields
(
self
):
def
_retrieve_struct_fields
(
self
):
self
.
struct_fields
=
[]
format_lines
=
Tracepoint
.
get_tpoint_format
(
self
.
category
,
format_lines
=
Tracepoint
.
get_tpoint_format
(
self
.
category
,
self
.
event
)
self
.
event
)
text
=
""
for
line
in
format_lines
:
for
line
in
format_lines
:
match
=
re
.
search
(
r'field:([^;]*);.*size:(\
d+);
', line)
match
=
re
.
search
(
r'field:([^;]*);.*size:(\
d+);
', line)
if match is None:
if match is None:
...
@@ -126,6 +127,11 @@ int __trace_entry_update(struct pt_regs *ctx)
...
@@ -126,6 +127,11 @@ int __trace_entry_update(struct pt_regs *ctx)
continue
continue
if field_name.startswith("common_"):
if field_name.startswith("common_"):
continue
continue
self.struct_fields.append((field_type, field_name))
def _generate_struct_fields(self):
text = ""
for field_type, field_name in self.struct_fields:
text += " %s %s;\n" % (field_type, field_name)
text += " %s %s;\n" % (field_type, field_name)
return text
return text
...
@@ -134,10 +140,17 @@ int __trace_entry_update(struct pt_regs *ctx)
...
@@ -134,10 +140,17 @@ int __trace_entry_update(struct pt_regs *ctx)
return """
return """
struct %s {
struct %s {
u64 __do_not_use__;
u64 __do_not_use__;
%s
%s
};
};
""" % (self.struct_name, self._generate_struct_fields())
""" % (self.struct_name, self._generate_struct_fields())
def _generate_struct_locals(self):
text = ""
for field_type, field_name in self.struct_fields:
text += " %s %s = tp.%s;\n" % (
field_type, field_name, field_name)
return text
def generate_get_struct(self):
def generate_get_struct(self):
return """
return """
u64 tid = bpf_get_current_pid_tgid();
u64 tid = bpf_get_current_pid_tgid();
...
@@ -145,7 +158,8 @@ struct %s {
...
@@ -145,7 +158,8 @@ struct %s {
if (di == 0) { return 0; }
if (di == 0) { return 0; }
struct %s tp = {};
struct %s tp = {};
bpf_probe_read(&tp, sizeof(tp), (void *)*di);
bpf_probe_read(&tp, sizeof(tp), (void *)*di);
""" % self.struct_name
%s
""" % (self.struct_name, self._generate_struct_locals())
@classmethod
@classmethod
def enable_tracepoint(cls, category, event):
def enable_tracepoint(cls, category, event):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment