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
d1fbcb11
Commit
d1fbcb11
authored
Feb 25, 2018
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to use LLVM 5
parent
c9366aed
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
241 additions
and
237 deletions
+241
-237
INSTALL.md
INSTALL.md
+1
-1
docker/Dockerfile.ubuntu
docker/Dockerfile.ubuntu
+2
-2
src/ast/codegen_llvm.cpp
src/ast/codegen_llvm.cpp
+5
-5
src/ast/irbuilderbpf.cpp
src/ast/irbuilderbpf.cpp
+7
-3
src/bpftrace.cpp
src/bpftrace.cpp
+1
-1
tests/codegen.cpp
tests/codegen.cpp
+225
-225
No files found.
INSTALL.md
View file @
d1fbcb11
...
...
@@ -27,7 +27,7 @@ To use some BPFtrace features, minimum kernel versions are required:
-
CMake
-
Flex
-
Bison
-
LLVM
3.9
development packages
-
LLVM
5.0
development packages
-
LibElf
### Compilation
...
...
docker/Dockerfile.ubuntu
View file @
d1fbcb11
...
...
@@ -5,9 +5,9 @@ RUN apt-get update && apt-get install -y \
flex \
g++ \
git \
libclang-
3.9
-dev \
libclang-
5.0
-dev \
libelf-dev \
llvm-
3.9
-dev \
llvm-
5.0
-dev \
zlib1g-dev
COPY build.sh /build.sh
...
...
src/ast/codegen_llvm.cpp
View file @
d1fbcb11
...
...
@@ -382,11 +382,11 @@ void CodegenLLVM::visit(Probe &probe)
{
b_
.
getInt8PtrTy
()},
// struct pt_regs *ctx
false
);
Function
*
func
=
Function
::
Create
(
func_type
,
Function
::
ExternalLinkage
,
probe
.
name
(),
module_
.
get
());
func
->
setSection
(
probe
.
name
());
func
->
setSection
(
"s_"
+
probe
.
name
());
BasicBlock
*
entry
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"entry"
,
func
);
b_
.
SetInsertPoint
(
entry
);
ctx_
=
&
func
->
getArgumentList
().
front
();
ctx_
=
func
->
arg_begin
();
if
(
probe
.
pred
)
{
probe
.
pred
->
accept
(
*
this
);
...
...
@@ -590,7 +590,7 @@ void CodegenLLVM::createLog2Function()
BasicBlock
*
entry
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"entry"
,
log2_func
);
b_
.
SetInsertPoint
(
entry
);
Value
*
arg
=
&
log2_func
->
getArgumentList
().
front
();
Value
*
arg
=
log2_func
->
arg_begin
();
Value
*
n_alloc
=
b_
.
CreateAllocaBPF
(
SizedType
(
Type
::
integer
,
8
));
b_
.
CreateStore
(
arg
,
n_alloc
);
...
...
@@ -628,8 +628,8 @@ void CodegenLLVM::createStrcmpFunction()
BasicBlock
*
not_equal_block
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"strcmp.not_equal"
,
strcmp_func
);
b_
.
SetInsertPoint
(
entry
);
Value
*
s1
=
&
strcmp_func
->
getArgumentList
().
front
();
Value
*
s2
=
&
strcmp_func
->
getArgumentList
().
back
()
;
Value
*
s1
=
strcmp_func
->
arg_begin
();
Value
*
s2
=
strcmp_func
->
arg_begin
()
+
1
;
for
(
int
i
=
0
;
i
<
STRING_SIZE
;
i
++
)
{
...
...
src/ast/irbuilderbpf.cpp
View file @
d1fbcb11
...
...
@@ -49,11 +49,15 @@ AllocaInst *IRBuilderBPF::CreateAllocaBPF(llvm::Type *ty, const std::string &nam
{
Function
*
parent
=
GetInsertBlock
()
->
getParent
();
BasicBlock
&
entry_block
=
parent
->
getEntryBlock
();
AllocaInst
*
alloca
;
auto
ip
=
saveIP
();
if
(
entry_block
.
empty
())
alloca
=
new
AllocaInst
(
ty
,
name
,
&
entry_block
);
SetInsertPoint
(
&
entry_block
);
else
alloca
=
new
AllocaInst
(
ty
,
name
,
&
entry_block
.
front
());
SetInsertPoint
(
&
entry_block
.
front
());
AllocaInst
*
alloca
=
CreateAlloca
(
ty
,
nullptr
,
name
);
// TODO dodgy
restoreIP
(
ip
);
CreateLifetimeStart
(
alloca
);
return
alloca
;
}
...
...
src/bpftrace.cpp
View file @
d1fbcb11
...
...
@@ -189,7 +189,7 @@ void perf_event_lost(void *cb_cookie, uint64_t lost)
std
::
unique_ptr
<
AttachedProbe
>
BPFtrace
::
attach_probe
(
Probe
&
probe
)
{
auto
func
=
sections_
.
find
(
probe
.
prog_name
);
auto
func
=
sections_
.
find
(
"s_"
+
probe
.
prog_name
);
if
(
func
==
sections_
.
end
())
{
std
::
cerr
<<
"Code not generated for probe: "
<<
probe
.
name
<<
std
::
endl
;
...
...
tests/codegen.cpp
View file @
d1fbcb11
This diff is collapsed.
Click to expand it.
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