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
f4543fcd
Commit
f4543fcd
authored
Sep 03, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not create instance for kprobe
parent
566597c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
28 deletions
+6
-28
src/cc/libbpf.c
src/cc/libbpf.c
+6
-28
No files found.
src/cc/libbpf.c
View file @
f4543fcd
...
@@ -392,12 +392,10 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
...
@@ -392,12 +392,10 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
{
{
int
kfd
;
int
kfd
;
char
buf
[
256
];
char
buf
[
256
];
char
new_name
[
128
];
char
event_alias
[
128
];
struct
perf_reader
*
reader
=
NULL
;
struct
perf_reader
*
reader
=
NULL
;
static
char
*
event_type
=
"kprobe"
;
static
char
*
event_type
=
"kprobe"
;
int
n
;
snprintf
(
new_name
,
sizeof
(
new_name
),
"%s_bcc_%d"
,
ev_name
,
getpid
());
reader
=
perf_reader_new
(
cb
,
NULL
,
NULL
,
cb_cookie
,
probe_perf_reader_page_cnt
);
reader
=
perf_reader_new
(
cb
,
NULL
,
NULL
,
cb_cookie
,
probe_perf_reader_page_cnt
);
if
(
!
reader
)
if
(
!
reader
)
goto
error
;
goto
error
;
...
@@ -409,8 +407,9 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
...
@@ -409,8 +407,9 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
goto
error
;
goto
error
;
}
}
snprintf
(
event_alias
,
sizeof
(
event_alias
),
"%s_bcc_%d"
,
ev_name
,
getpid
());
snprintf
(
buf
,
sizeof
(
buf
),
"%c:%ss/%s %s"
,
attach_type
==
BPF_PROBE_ENTRY
?
'p'
:
'r'
,
snprintf
(
buf
,
sizeof
(
buf
),
"%c:%ss/%s %s"
,
attach_type
==
BPF_PROBE_ENTRY
?
'p'
:
'r'
,
event_type
,
new_name
,
fn_name
);
event_type
,
event_alias
,
fn_name
);
if
(
write
(
kfd
,
buf
,
strlen
(
buf
))
<
0
)
{
if
(
write
(
kfd
,
buf
,
strlen
(
buf
))
<
0
)
{
if
(
errno
==
EINVAL
)
if
(
errno
==
EINVAL
)
fprintf
(
stderr
,
"check dmesg output for possible cause
\n
"
);
fprintf
(
stderr
,
"check dmesg output for possible cause
\n
"
);
...
@@ -419,24 +418,10 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
...
@@ -419,24 +418,10 @@ void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, con
}
}
close
(
kfd
);
close
(
kfd
);
if
(
access
(
"/sys/kernel/debug/tracing/instances"
,
F_OK
)
!=
-
1
)
{
snprintf
(
buf
,
sizeof
(
buf
),
"/sys/kernel/debug/tracing/events/%ss/%s"
,
event_type
,
event_alias
);
snprintf
(
buf
,
sizeof
(
buf
),
"/sys/kernel/debug/tracing/instances/bcc_%d"
,
getpid
());
if
(
access
(
buf
,
F_OK
)
==
-
1
)
{
if
(
mkdir
(
buf
,
0755
)
==
-
1
)
goto
retry
;
}
n
=
snprintf
(
buf
,
sizeof
(
buf
),
"/sys/kernel/debug/tracing/instances/bcc_%d/events/%ss/%s"
,
getpid
(),
event_type
,
new_name
);
if
(
n
<
sizeof
(
buf
)
&&
bpf_attach_tracing_event
(
progfd
,
buf
,
reader
,
pid
,
cpu
,
group_fd
)
==
0
)
goto
out
;
snprintf
(
buf
,
sizeof
(
buf
),
"/sys/kernel/debug/tracing/instances/bcc_%d"
,
getpid
());
rmdir
(
buf
);
}
retry:
snprintf
(
buf
,
sizeof
(
buf
),
"/sys/kernel/debug/tracing/events/%ss/%s"
,
event_type
,
new_name
);
if
(
bpf_attach_tracing_event
(
progfd
,
buf
,
reader
,
pid
,
cpu
,
group_fd
)
<
0
)
if
(
bpf_attach_tracing_event
(
progfd
,
buf
,
reader
,
pid
,
cpu
,
group_fd
)
<
0
)
goto
error
;
goto
error
;
out:
return
reader
;
return
reader
;
error:
error:
...
@@ -586,14 +571,7 @@ static int bpf_detach_probe(const char *ev_name, const char *event_type)
...
@@ -586,14 +571,7 @@ static int bpf_detach_probe(const char *ev_name, const char *event_type)
int
bpf_detach_kprobe
(
const
char
*
ev_name
)
int
bpf_detach_kprobe
(
const
char
*
ev_name
)
{
{
char
buf
[
256
];
return
bpf_detach_probe
(
ev_name
,
"kprobe"
);
int
ret
=
bpf_detach_probe
(
ev_name
,
"kprobe"
);
snprintf
(
buf
,
sizeof
(
buf
),
"/sys/kernel/debug/tracing/instances/bcc_%d"
,
getpid
());
if
(
access
(
buf
,
F_OK
)
!=
-
1
)
{
rmdir
(
buf
);
}
return
ret
;
}
}
int
bpf_detach_uprobe
(
const
char
*
ev_name
)
int
bpf_detach_uprobe
(
const
char
*
ev_name
)
...
...
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