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
7d7eb0c6
Commit
7d7eb0c6
authored
Jan 19, 2016
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
4d57da10
2be91230
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
0 deletions
+20
-0
src/cc/bpf_module.cc
src/cc/bpf_module.cc
+5
-0
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.cc
+1
-0
src/cc/shared_table.cc
src/cc/shared_table.cc
+11
-0
src/cc/shared_table.h
src/cc/shared_table.h
+2
-0
src/cc/table_desc.h
src/cc/table_desc.h
+1
-0
No files found.
src/cc/bpf_module.cc
View file @
7d7eb0c6
...
...
@@ -49,6 +49,7 @@
#include "frontends/clang/b_frontend_action.h"
#include "bpf_module.h"
#include "kbuild_helper.h"
#include "shared_table.h"
#include "libbpf.h"
namespace
ebpf
{
...
...
@@ -113,6 +114,10 @@ BPFModule::~BPFModule() {
engine_
.
reset
();
rw_engine_
.
reset
();
ctx_
.
reset
();
for
(
auto
table
:
*
tables_
)
{
if
(
table
.
is_shared
)
SharedTables
::
instance
()
->
remove_fd
(
table
.
name
);
}
}
static
void
debug_printf
(
Module
*
mod
,
IRBuilder
<>
&
B
,
const
string
&
fmt
,
vector
<
Value
*>
args
)
{
...
...
src/cc/frontends/clang/b_frontend_action.cc
View file @
7d7eb0c6
...
...
@@ -599,6 +599,7 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
C
.
getDiagnostics
().
Report
(
Decl
->
getLocStart
(),
diag_id
)
<<
table
.
name
<<
"already in use"
;
return
false
;
}
table_it
->
is_shared
=
true
;
return
true
;
}
...
...
src/cc/shared_table.cc
View file @
7d7eb0c6
...
...
@@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <unistd.h>
#include "shared_table.h"
namespace
ebpf
{
...
...
@@ -43,4 +45,13 @@ bool SharedTables::insert_fd(const string &name, int fd) {
return
true
;
}
bool
SharedTables
::
remove_fd
(
const
string
&
name
)
{
auto
table
=
tables_
.
find
(
name
);
if
(
table
==
tables_
.
end
())
return
false
;
close
(
table
->
second
);
tables_
.
erase
(
table
);
return
true
;
}
}
src/cc/shared_table.h
View file @
7d7eb0c6
...
...
@@ -30,6 +30,8 @@ class SharedTables {
bool
insert_fd
(
const
std
::
string
&
name
,
int
fd
);
// lookup an fd in the shared table, or -1 if not found
int
lookup_fd
(
const
std
::
string
&
name
)
const
;
// close and remove a shared fd. return true if the value was found
bool
remove_fd
(
const
std
::
string
&
name
);
private:
static
SharedTables
*
instance_
;
std
::
map
<
std
::
string
,
int
>
tables_
;
...
...
src/cc/table_desc.h
View file @
7d7eb0c6
...
...
@@ -38,6 +38,7 @@ struct TableDesc {
llvm
::
Function
*
leaf_sscanf
;
llvm
::
Function
*
key_snprintf
;
llvm
::
Function
*
leaf_snprintf
;
bool
is_shared
;
};
}
// namespace ebpf
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