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
abef8350
Commit
abef8350
authored
Feb 28, 2018
by
4ast
Committed by
GitHub
Feb 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1610 from iovisor/yhs_dev
free llvm engine/context memory when rw_engine is not used
parents
d7814b79
af96bba7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
7 deletions
+33
-7
src/cc/bpf_module.cc
src/cc/bpf_module.cc
+33
-7
No files found.
src/cc/bpf_module.cc
View file @
abef8350
...
...
@@ -140,6 +140,11 @@ BPFModule::~BPFModule() {
v
->
leaf_snprintf
=
unimplemented_snprintf
;
}
if
(
!
rw_engine_enabled_
)
{
for
(
auto
section
:
sections_
)
delete
get
<
0
>
(
section
.
second
);
}
engine_
.
reset
();
rw_engine_
.
reset
();
ctx_
.
reset
();
...
...
@@ -607,14 +612,17 @@ int BPFModule::run_pass_manager(Module &mod) {
int
BPFModule
::
finalize
()
{
Module
*
mod
=
&*
mod_
;
std
::
map
<
std
::
string
,
std
::
tuple
<
uint8_t
*
,
uintptr_t
>>
tmp_sections
,
*
sections_p
;
mod
->
setDataLayout
(
"e-m:e-p:64:64-i64:64-n32:64-S128"
);
mod
->
setTargetTriple
(
"bpf-pc-linux"
);
sections_p
=
rw_engine_enabled_
?
&
sections_
:
&
tmp_sections
;
string
err
;
EngineBuilder
builder
(
move
(
mod_
));
builder
.
setErrorStr
(
&
err
);
builder
.
setMCJITMemoryManager
(
ebpf
::
make_unique
<
MyMemoryManager
>
(
&
sections_
));
builder
.
setMCJITMemoryManager
(
ebpf
::
make_unique
<
MyMemoryManager
>
(
sections_p
));
builder
.
setMArch
(
"bpf"
);
builder
.
setUseOrcMCJITReplacement
(
false
);
engine_
=
unique_ptr
<
ExecutionEngine
>
(
builder
.
create
());
...
...
@@ -631,17 +639,35 @@ int BPFModule::finalize() {
engine_
->
finalizeObject
();
// give functions an id
for
(
auto
section
:
sections_
)
if
(
!
strncmp
(
FN_PREFIX
.
c_str
(),
section
.
first
.
c_str
(),
FN_PREFIX
.
size
()))
function_names_
.
push_back
(
section
.
first
);
if
(
flags_
&
DEBUG_SOURCE
)
{
SourceDebugger
src_debugger
(
mod
,
sections_
,
FN_PREFIX
,
mod_src_
,
SourceDebugger
src_debugger
(
mod
,
*
sections_p
,
FN_PREFIX
,
mod_src_
,
src_dbg_fmap_
);
src_debugger
.
dump
();
}
if
(
!
rw_engine_enabled_
)
{
// Setup sections_ correctly and then free llvm internal memory
for
(
auto
section
:
tmp_sections
)
{
auto
fname
=
section
.
first
;
uintptr_t
size
=
get
<
1
>
(
section
.
second
);
uint8_t
*
tmp_p
=
NULL
;
// Only copy data for non-map sections
if
(
strncmp
(
"maps/"
,
section
.
first
.
c_str
(),
5
))
{
uint8_t
*
addr
=
get
<
0
>
(
section
.
second
);
tmp_p
=
new
uint8_t
[
size
];
memcpy
(
tmp_p
,
addr
,
size
);
}
sections_
[
fname
]
=
make_tuple
(
tmp_p
,
size
);
}
engine_
.
reset
();
ctx_
.
reset
();
}
// give functions an id
for
(
auto
section
:
sections_
)
if
(
!
strncmp
(
FN_PREFIX
.
c_str
(),
section
.
first
.
c_str
(),
FN_PREFIX
.
size
()))
function_names_
.
push_back
(
section
.
first
);
return
0
;
}
...
...
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