Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
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
bpftrace
Commits
2776c852
Commit
2776c852
authored
Mar 01, 2018
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build
BCC API for attaching tracing events has been cleaned up - no more perf readers
parent
60718404
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
34 deletions
+24
-34
src/attached_probe.cpp
src/attached_probe.cpp
+24
-32
src/attached_probe.h
src/attached_probe.h
+0
-2
No files found.
src/attached_probe.cpp
View file @
2776c852
...
...
@@ -8,7 +8,6 @@
#include "bcc_syms.h"
#include "common.h"
#include "libbpf.h"
#include "perf_reader.h"
#include <linux/perf_event.h>
namespace
bpftrace
{
...
...
@@ -68,9 +67,16 @@ AttachedProbe::AttachedProbe(Probe &probe, std::tuple<uint8_t *, uintptr_t> &fun
AttachedProbe
::~
AttachedProbe
()
{
close
(
progfd_
);
if
(
perf_reader_
)
perf_reader_free
(
perf_reader_
);
int
err
=
0
;
for
(
int
perf_event_fd
:
perf_event_fds_
)
{
err
=
bpf_close_perf_event_fd
(
perf_event_fd
);
if
(
err
)
std
::
cerr
<<
"Error closing perf event FDs for probe: "
<<
probe_
.
name
<<
std
::
endl
;
}
err
=
0
;
switch
(
probe_
.
type
)
{
case
ProbeType
:
:
kprobe
:
...
...
@@ -85,7 +91,6 @@ AttachedProbe::~AttachedProbe()
err
=
bpf_detach_tracepoint
(
probe_
.
path
.
c_str
(),
eventname
().
c_str
());
break
;
case
ProbeType
:
:
profile
:
err
=
detach_profile
();
break
;
default:
abort
();
...
...
@@ -172,39 +177,37 @@ void AttachedProbe::load_prog()
void
AttachedProbe
::
attach_kprobe
()
{
perf_reader_cb
cb
=
nullptr
;
void
*
cb_cookie
=
nullptr
;
perf_reader_
=
bpf_attach_kprobe
(
progfd_
,
attachtype
(
probe_
.
type
),
eventname
().
c_str
(),
probe_
.
attach_point
.
c_str
(),
cb
,
cb_cookie
);
int
perf_event_fd
=
bpf_attach_kprobe
(
progfd_
,
attachtype
(
probe_
.
type
),
eventname
().
c_str
(),
probe_
.
attach_point
.
c_str
());
if
(
perf_
reader_
==
nullptr
)
if
(
perf_
event_fd
<
0
)
throw
std
::
runtime_error
(
"Error attaching probe: '"
+
probe_
.
name
+
"'"
);
perf_event_fds_
.
push_back
(
perf_event_fd
);
}
void
AttachedProbe
::
attach_uprobe
()
{
int
pid
=
-
1
;
perf_reader_cb
cb
=
nullptr
;
void
*
cb_cookie
=
nullptr
;
perf_reader_
=
bpf_attach_uprobe
(
progfd_
,
attachtype
(
probe_
.
type
),
eventname
().
c_str
(),
probe_
.
path
.
c_str
(),
offset
(),
pid
,
cb
,
cb_cookie
);
int
perf_event_fd
=
bpf_attach_uprobe
(
progfd_
,
attachtype
(
probe_
.
type
),
eventname
().
c_str
(),
probe_
.
path
.
c_str
(),
offset
(),
pid
);
if
(
perf_
reader_
==
nullptr
)
if
(
perf_
event_fd
<
0
)
throw
std
::
runtime_error
(
"Error attaching probe: "
+
probe_
.
name
);
perf_event_fds_
.
push_back
(
perf_event_fd
);
}
void
AttachedProbe
::
attach_tracepoint
()
{
perf_reader_cb
cb
=
nullptr
;
void
*
cb_cookie
=
nullptr
;
int
perf_event_fd
=
bpf_attach_tracepoint
(
progfd_
,
probe_
.
path
.
c_str
(),
eventname
().
c_str
())
;
perf_reader_
=
bpf_attach_tracepoint
(
progfd_
,
probe_
.
path
.
c_str
(),
eventname
().
c_str
(),
cb
,
cb_cookie
);
if
(
perf_reader_
==
nullptr
)
if
(
perf_event_fd
<
0
)
throw
std
::
runtime_error
(
"Error attaching probe: "
+
probe_
.
name
);
perf_event_fds_
.
push_back
(
perf_event_fd
);
}
void
AttachedProbe
::
attach_profile
()
...
...
@@ -251,15 +254,4 @@ void AttachedProbe::attach_profile()
}
}
int
AttachedProbe
::
detach_profile
()
{
for
(
int
perf_event_fd
:
perf_event_fds_
)
{
int
err
=
bpf_close_perf_event_fd
(
perf_event_fd
);
if
(
err
)
return
err
;
}
return
0
;
}
}
// namespace bpftrace
src/attached_probe.h
View file @
2776c852
...
...
@@ -27,12 +27,10 @@ private:
void
attach_uprobe
();
void
attach_tracepoint
();
void
attach_profile
();
int
detach_profile
();
Probe
&
probe_
;
std
::
tuple
<
uint8_t
*
,
uintptr_t
>
&
func_
;
std
::
vector
<
int
>
perf_event_fds_
;
void
*
perf_reader_
=
nullptr
;
int
progfd_
;
};
...
...
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