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
e25f0498
Commit
e25f0498
authored
Oct 12, 2018
by
Brendan Gregg
Committed by
GitHub
Oct 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #171 from cneira/headers
BPFTRACE_KERNEL_SOURCE environment variable
parents
bfbd2cd7
5892a8cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
README.md
README.md
+8
-1
src/clang_parser.cpp
src/clang_parser.cpp
+18
-3
No files found.
README.md
View file @
e25f0498
...
...
@@ -4,6 +4,13 @@ BPFtrace is a high-level tracing language for Linux enhanced Berkeley Packet Fil
To learn more about BPFtrace, see the
[
Reference Guide
](
docs/reference_guide.md
)
and
[
One-Liner Tutorial
](
docs/tutorial_one_liners.md
)
.
BPFTrace depends on the kernel headers which are searched for by default in:
```
bash
/lib/modules/
$(
uname
-r
)
```
The default search directory could be overridden using the environment variable BPFTRACE_KERNEL_HEADERS.
## Install
For build and install instructions, see
[
INSTALL.md
](
INSTALL.md
)
.
...
...
src/clang_parser.cpp
View file @
e25f0498
...
...
@@ -159,10 +159,25 @@ void ClangParser::parse(ast::Program *program, StructMap &structs)
struct
utsname
utsname
;
uname
(
&
utsname
);
std
::
string
kernel_modules_dir
=
std
::
string
(
"/lib/modules/"
)
+
utsname
.
release
;
const
char
*
env_kernel_modules_dir
=
::
getenv
(
"BPFTRACE_KERNEL_HEADERS"
);
std
::
string
kernel_modules_dir
=
env_kernel_modules_dir
?
std
::
string
(
env_kernel_modules_dir
)
:
std
::
string
(
"/lib/modules/"
)
+
utsname
.
release
;
if
(
!
is_dir
(
kernel_modules_dir
)){
std
::
cerr
<<
"WARNING: ("
<<
kernel_modules_dir
<<
") is not a valid dir"
<<
std
::
endl
;
std
::
cerr
<<
"Use environment variable BPFTRACE_KERNEL_HEADERS to setup"
" a valid directory for kernel headers."
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
auto
kpath_info
=
get_kernel_path_info
(
kernel_modules_dir
);
auto
kpath
=
kernel_modules_dir
+
"/"
+
kpath_info
.
second
;
bool
has_kpath_source
=
kpath_info
.
first
;
auto
kpath
=
env_kernel_modules_dir
?
kernel_modules_dir
:
kernel_modules_dir
+
"/"
+
kpath_info
.
second
;
bool
has_kpath_source
=
env_kernel_modules_dir
?
true
:
kpath_info
.
first
;
std
::
vector
<
std
::
string
>
kflags
;
...
...
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