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
ad0e8836
Commit
ad0e8836
authored
Mar 04, 2016
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename stack lookup() to get_stackid
Signed-off-by:
Brenden Blanco
<
bblanco@plumgrid.com
>
parent
9cafce2a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
src/cc/export/helpers.h
src/cc/export/helpers.h
+6
-8
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.cc
+11
-7
tests/python/test_stackid.py
tests/python/test_stackid.py
+4
-2
No files found.
src/cc/export/helpers.h
View file @
ad0e8836
...
...
@@ -48,6 +48,7 @@ struct _name##_table_t { \
int (*delete) (_key_type *); \
void (*call) (void *, int index); \
void (*increment) (_key_type); \
int (*get_stackid) (void *, u64); \
_leaf_type data[_max_entries]; \
}; \
__attribute__((section("
maps
/
" _table_type))) \
...
...
@@ -110,15 +111,12 @@ struct _name##_table_t _name
#define BPF_HISTOGRAM(...) \
BPF_HISTX(__VA_ARGS__, BPF_HIST3, BPF_HIST2, BPF_HIST1)(__VA_ARGS__)
struct bpf_stacktrace {
u64 ip[BPF_MAX_STACK_DEPTH];
};
#define BPF_STACK_TRACE(_name, _max_entries) \
struct _name##_table_t { \
int key; \
struct { u64 data[BPF_MAX_STACK_DEPTH]; } leaf; \
int (*lookup) (void *); \
struct { u64 data[BPF_MAX_STACK_DEPTH]; } data[_max_entries]; \
}; \
__attribute__((section("
maps
/
stacktrace
"))) \
struct _name##_table_t _name
BPF_TABLE("
stacktrace
", int, struct bpf_stacktrace, _name, _max_entries);
// packet parsing state machine helpers
#define cursor_advance(_cursor, _len) \
...
...
src/cc/frontends/clang/b_frontend_action.cc
View file @
ad0e8836
...
...
@@ -352,16 +352,20 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
Call
->
getArg
(
2
)
->
getLocEnd
()));
txt
=
"bpf_perf_event_output("
+
arg0
+
", bpf_pseudo_fd(1, "
+
fd
+
")"
;
txt
+=
", bpf_get_smp_processor_id(), "
+
args_other
+
")"
;
}
else
{
if
(
memb_name
==
"lookup"
)
{
}
else
if
(
memb_name
==
"get_stackid"
)
{
if
(
table_it
->
type
==
BPF_MAP_TYPE_STACK_TRACE
)
{
prefix
=
"bpf_get_stackid"
;
// TODO: expose the different flags, how?
suffix
=
", 0)"
;
txt
=
"bpf_get_stackid("
;
txt
+=
"bpf_pseudo_fd(1, "
+
fd
+
"), "
+
args
+
")"
;
}
else
{
prefix
=
"bpf_map_lookup_elem"
;
suffix
=
")"
;
unsigned
diag_id
=
C
.
getDiagnostics
().
getCustomDiagID
(
DiagnosticsEngine
::
Error
,
"get_stackid only available on stacktrace maps"
);
C
.
getDiagnostics
().
Report
(
Call
->
getLocStart
(),
diag_id
);
return
false
;
}
}
else
{
if
(
memb_name
==
"lookup"
)
{
prefix
=
"bpf_map_lookup_elem"
;
suffix
=
")"
;
}
else
if
(
memb_name
==
"update"
)
{
prefix
=
"bpf_map_update_elem"
;
suffix
=
", "
+
map_update_policy
+
")"
;
...
...
tests/python/test_stackid.py
View file @
ad0e8836
...
...
@@ -14,7 +14,9 @@ BPF_STACK_TRACE(stack_traces, 10240);
BPF_HASH(stack_entries, int, int);
BPF_HASH(stub);
int kprobe__htab_map_delete_elem(struct pt_regs *ctx, struct bpf_map *map, u64 *k) {
int id = stack_traces.lookup(ctx);
int id = stack_traces.get_stackid(ctx, (BPF_F_REUSE_STACKID));
if (id < 0)
return 0;
int key = 1;
stack_entries.update(&key, &id);
return 0;
...
...
@@ -29,7 +31,7 @@ int kprobe__htab_map_delete_elem(struct pt_regs *ctx, struct bpf_map *map, u64 *
self
.
assertIn
(
k
,
stack_entries
)
stackid
=
stack_entries
[
k
]
self
.
assertIsNotNone
(
stackid
)
stack
=
stack_traces
[
stackid
].
data
stack
=
stack_traces
[
stackid
].
ip
self
.
assertEqual
(
b
.
ksym
(
stack
[
0
]),
"htab_map_delete_elem"
)
...
...
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