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
ccac69c2
Commit
ccac69c2
authored
Jan 29, 2019
by
Brendan Gregg
Committed by
GitHub
Jan 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #374 from boat0/new_bcc_api
follow the new libbcc interface: bcc_{create_map, prog_load}
parents
e9e699f8
c03c39fc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
0 deletions
+28
-0
CMakeLists.txt
CMakeLists.txt
+4
-0
src/CMakeLists.txt
src/CMakeLists.txt
+6
-0
src/attached_probe.cpp
src/attached_probe.cpp
+4
-0
src/map.cpp
src/map.cpp
+8
-0
tests/CMakeLists.txt
tests/CMakeLists.txt
+6
-0
No files found.
CMakeLists.txt
View file @
ccac69c2
...
@@ -51,6 +51,10 @@ set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
...
@@ -51,6 +51,10 @@ set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_symbol_exists
(
name_to_handle_at
"sys/types.h;sys/stat.h;fcntl.h"
HAVE_NAME_TO_HANDLE_AT
)
check_symbol_exists
(
name_to_handle_at
"sys/types.h;sys/stat.h;fcntl.h"
HAVE_NAME_TO_HANDLE_AT
)
set
(
CMAKE_REQUIRED_DEFINITIONS
)
set
(
CMAKE_REQUIRED_DEFINITIONS
)
set
(
CMAKE_REQUIRED_LIBRARIES bcc
)
check_symbol_exists
(
bcc_prog_load
"
${
LIBBCC_INCLUDE_DIRS
}
/libbpf.h"
HAVE_BCC_PROG_LOAD
)
check_symbol_exists
(
bcc_create_map
"
${
LIBBCC_INCLUDE_DIRS
}
/libbpf.h"
HAVE_BCC_CREATE_MAP
)
find_package
(
LLVM REQUIRED
)
find_package
(
LLVM REQUIRED
)
include_directories
(
${
LLVM_INCLUDE_DIRS
}
)
include_directories
(
${
LLVM_INCLUDE_DIRS
}
)
add_definitions
(
${
LLVM_DEFINITIONS
}
)
add_definitions
(
${
LLVM_DEFINITIONS
}
)
...
...
src/CMakeLists.txt
View file @
ccac69c2
...
@@ -18,6 +18,12 @@ add_executable(bpftrace
...
@@ -18,6 +18,12 @@ add_executable(bpftrace
if
(
HAVE_NAME_TO_HANDLE_AT
)
if
(
HAVE_NAME_TO_HANDLE_AT
)
target_compile_definitions
(
bpftrace PRIVATE HAVE_NAME_TO_HANDLE_AT=1
)
target_compile_definitions
(
bpftrace PRIVATE HAVE_NAME_TO_HANDLE_AT=1
)
endif
(
HAVE_NAME_TO_HANDLE_AT
)
endif
(
HAVE_NAME_TO_HANDLE_AT
)
if
(
HAVE_BCC_PROG_LOAD
)
target_compile_definitions
(
bpftrace PRIVATE HAVE_BCC_PROG_LOAD
)
endif
(
HAVE_BCC_PROG_LOAD
)
if
(
HAVE_BCC_CREATE_MAP
)
target_compile_definitions
(
bpftrace PRIVATE HAVE_BCC_CREATE_MAP
)
endif
(
HAVE_BCC_CREATE_MAP
)
target_link_libraries
(
bpftrace arch ast parser resources
)
target_link_libraries
(
bpftrace arch ast parser resources
)
if
(
STATIC_LINKING
)
if
(
STATIC_LINKING
)
...
...
src/attached_probe.cpp
View file @
ccac69c2
...
@@ -331,7 +331,11 @@ void AttachedProbe::load_prog()
...
@@ -331,7 +331,11 @@ void AttachedProbe::load_prog()
for
(
int
attempt
=
0
;
attempt
<
3
;
attempt
++
)
for
(
int
attempt
=
0
;
attempt
<
3
;
attempt
++
)
{
{
#ifdef HAVE_BCC_PROG_LOAD
progfd_
=
bcc_prog_load
(
progtype
(
probe_
.
type
),
namep
,
#else
progfd_
=
bpf_prog_load
(
progtype
(
probe_
.
type
),
namep
,
progfd_
=
bpf_prog_load
(
progtype
(
probe_
.
type
),
namep
,
#endif
reinterpret_cast
<
struct
bpf_insn
*>
(
insns
),
prog_len
,
license
,
reinterpret_cast
<
struct
bpf_insn
*>
(
insns
),
prog_len
,
license
,
kernel_version
(
attempt
),
log_level
,
log_buf
,
log_buf_size
);
kernel_version
(
attempt
),
log_level
,
log_buf
,
log_buf_size
);
if
(
progfd_
>=
0
)
if
(
progfd_
>=
0
)
...
...
src/map.cpp
View file @
ccac69c2
...
@@ -46,7 +46,11 @@ Map::Map(const std::string &name, const SizedType &type, const MapKey &key, int
...
@@ -46,7 +46,11 @@ Map::Map(const std::string &name, const SizedType &type, const MapKey &key, int
int
value_size
=
type
.
size
;
int
value_size
=
type
.
size
;
int
flags
=
0
;
int
flags
=
0
;
#ifdef HAVE_BCC_CREATE_MAP
mapfd_
=
bcc_create_map
(
map_type
,
name
.
c_str
(),
key_size
,
value_size
,
max_entries
,
flags
);
#else
mapfd_
=
bpf_create_map
(
map_type
,
name
.
c_str
(),
key_size
,
value_size
,
max_entries
,
flags
);
mapfd_
=
bpf_create_map
(
map_type
,
name
.
c_str
(),
key_size
,
value_size
,
max_entries
,
flags
);
#endif
if
(
mapfd_
<
0
)
if
(
mapfd_
<
0
)
{
{
std
::
cerr
<<
"Error creating map: '"
<<
name_
<<
"'"
<<
std
::
endl
;
std
::
cerr
<<
"Error creating map: '"
<<
name_
<<
"'"
<<
std
::
endl
;
...
@@ -80,7 +84,11 @@ Map::Map(enum bpf_map_type map_type)
...
@@ -80,7 +84,11 @@ Map::Map(enum bpf_map_type map_type)
std
::
cerr
<<
"invalid map type"
<<
std
::
endl
;
std
::
cerr
<<
"invalid map type"
<<
std
::
endl
;
abort
();
abort
();
}
}
#ifdef HAVE_BCC_CREATE_MAP
mapfd_
=
bcc_create_map
(
map_type
,
name
.
c_str
(),
key_size
,
value_size
,
max_entries
,
flags
);
#else
mapfd_
=
bpf_create_map
(
map_type
,
name
.
c_str
(),
key_size
,
value_size
,
max_entries
,
flags
);
mapfd_
=
bpf_create_map
(
map_type
,
name
.
c_str
(),
key_size
,
value_size
,
max_entries
,
flags
);
#endif
if
(
mapfd_
<
0
)
if
(
mapfd_
<
0
)
{
{
std
::
string
name
;
std
::
string
name
;
...
...
tests/CMakeLists.txt
View file @
ccac69c2
...
@@ -31,6 +31,12 @@ add_executable(bpftrace_test
...
@@ -31,6 +31,12 @@ add_executable(bpftrace_test
if
(
HAVE_NAME_TO_HANDLE_AT
)
if
(
HAVE_NAME_TO_HANDLE_AT
)
target_compile_definitions
(
bpftrace_test PRIVATE HAVE_NAME_TO_HANDLE_AT=1
)
target_compile_definitions
(
bpftrace_test PRIVATE HAVE_NAME_TO_HANDLE_AT=1
)
endif
(
HAVE_NAME_TO_HANDLE_AT
)
endif
(
HAVE_NAME_TO_HANDLE_AT
)
if
(
HAVE_BCC_PROG_LOAD
)
target_compile_definitions
(
bpftrace_test PRIVATE HAVE_BCC_PROG_LOAD
)
endif
(
HAVE_BCC_PROG_LOAD
)
if
(
HAVE_BCC_CREATE_MAP
)
target_compile_definitions
(
bpftrace_test PRIVATE HAVE_BCC_CREATE_MAP
)
endif
(
HAVE_BCC_CREATE_MAP
)
target_link_libraries
(
bpftrace_test arch ast parser resources
)
target_link_libraries
(
bpftrace_test arch ast parser resources
)
if
(
STATIC_LINKING
)
if
(
STATIC_LINKING
)
...
...
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