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
32109bf9
Commit
32109bf9
authored
Jul 28, 2015
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include libbpf.h in some places, cleanup constants
Signed-off-by:
Brenden Blanco
<
bblanco@plumgrid.com
>
parent
fdb0ace2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
11 deletions
+10
-11
src/cc/b_frontend_action.cc
src/cc/b_frontend_action.cc
+2
-4
src/cc/bpf_module.cc
src/cc/bpf_module.cc
+1
-0
src/cc/codegen_llvm.cc
src/cc/codegen_llvm.cc
+3
-5
src/cc/codegen_llvm.h
src/cc/codegen_llvm.h
+0
-2
src/libbpf.h
src/libbpf.h
+4
-0
No files found.
src/cc/b_frontend_action.cc
View file @
32109bf9
...
@@ -25,9 +25,7 @@
...
@@ -25,9 +25,7 @@
#include "b_frontend_action.h"
#include "b_frontend_action.h"
extern
"C"
#include "libbpf.h"
int
bpf_create_map
(
enum
bpf_map_type
map_type
,
int
key_size
,
int
value_size
,
int
max_entries
);
namespace
ebpf
{
namespace
ebpf
{
...
@@ -90,7 +88,7 @@ bool BTypeVisitor::VisitFunctionDecl(FunctionDecl *D) {
...
@@ -90,7 +88,7 @@ bool BTypeVisitor::VisitFunctionDecl(FunctionDecl *D) {
// put each non-static non-inline function decl in its own section, to be
// put each non-static non-inline function decl in its own section, to be
// extracted by the MemoryManager
// extracted by the MemoryManager
if
(
D
->
isExternallyVisible
()
&&
D
->
hasBody
())
{
if
(
D
->
isExternallyVisible
()
&&
D
->
hasBody
())
{
string
attr
=
string
(
"__attribute__((section(
\"
.bpf.fn."
)
+
D
->
getName
().
str
()
+
"
\"
)))
\n
"
;
string
attr
=
string
(
"__attribute__((section(
\"
"
)
+
BPF_FN_PREFIX
+
D
->
getName
().
str
()
+
"
\"
)))
\n
"
;
rewriter_
.
InsertText
(
D
->
getLocStart
(),
attr
);
rewriter_
.
InsertText
(
D
->
getLocStart
(),
attr
);
// remember the arg names of the current function...first one is the ctx
// remember the arg names of the current function...first one is the ctx
fn_args_
.
clear
();
fn_args_
.
clear
();
...
...
src/cc/bpf_module.cc
View file @
32109bf9
...
@@ -63,6 +63,7 @@
...
@@ -63,6 +63,7 @@
#include "b_frontend_action.h"
#include "b_frontend_action.h"
#include "bpf_module.h"
#include "bpf_module.h"
#include "kbuild_helper.h"
#include "kbuild_helper.h"
#include "libbpf.h"
namespace
ebpf
{
namespace
ebpf
{
...
...
src/cc/codegen_llvm.cc
View file @
32109bf9
...
@@ -38,9 +38,7 @@
...
@@ -38,9 +38,7 @@
#include "cc/lexer.h"
#include "cc/lexer.h"
#include "cc/type_helper.h"
#include "cc/type_helper.h"
#include "linux/bpf.h"
#include "linux/bpf.h"
#include "libbpf.h"
extern
"C"
int
bpf_create_map
(
int
map_type
,
int
key_size
,
int
value_size
,
int
max_entries
);
namespace
ebpf
{
namespace
ebpf
{
namespace
cc
{
namespace
cc
{
...
@@ -801,7 +799,7 @@ StatusTuple CodegenLLVM::visit_table_index_expr_node(TableIndexExprNode *n) {
...
@@ -801,7 +799,7 @@ StatusTuple CodegenLLVM::visit_table_index_expr_node(TableIndexExprNode *n) {
// result = lookup(key)
// result = lookup(key)
Value
*
lookup1
=
B
.
CreateBitCast
(
B
.
CreateCall
(
lookup_fn
,
vector
<
Value
*>
({
pseudo_map_fd
,
key_ptr
})),
leaf_ptype
);
Value
*
lookup1
=
B
.
CreateBitCast
(
B
.
CreateCall
(
lookup_fn
,
vector
<
Value
*>
({
pseudo_map_fd
,
key_ptr
})),
leaf_ptype
);
Value
*
result
;
Value
*
result
=
nullptr
;
if
(
n
->
table_
->
policy_id
()
->
name_
==
"AUTO"
)
{
if
(
n
->
table_
->
policy_id
()
->
name_
==
"AUTO"
)
{
Function
*
parent
=
B
.
GetInsertBlock
()
->
getParent
();
Function
*
parent
=
B
.
GetInsertBlock
()
->
getParent
();
BasicBlock
*
label_start
=
B
.
GetInsertBlock
();
BasicBlock
*
label_start
=
B
.
GetInsertBlock
();
...
@@ -1079,7 +1077,7 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) {
...
@@ -1079,7 +1077,7 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) {
auto
leaf
=
scopes_
->
top_struct
()
->
lookup
(
n
->
leaf_id
()
->
name_
,
/*search_local*/
true
);
auto
leaf
=
scopes_
->
top_struct
()
->
lookup
(
n
->
leaf_id
()
->
name_
,
/*search_local*/
true
);
if
(
!
leaf
)
return
mkstatus_
(
n
,
"cannot find leaf %s"
,
n
->
leaf_id
()
->
name_
.
c_str
());
if
(
!
leaf
)
return
mkstatus_
(
n
,
"cannot find leaf %s"
,
n
->
leaf_id
()
->
name_
.
c_str
());
int
map_type
=
BPF_MAP_TYPE_UNSPEC
;
bpf_map_type
map_type
=
BPF_MAP_TYPE_UNSPEC
;
if
(
n
->
type_id
()
->
name_
==
"FIXED_MATCH"
)
if
(
n
->
type_id
()
->
name_
==
"FIXED_MATCH"
)
map_type
=
BPF_MAP_TYPE_HASH
;
map_type
=
BPF_MAP_TYPE_HASH
;
else
if
(
n
->
type_id
()
->
name_
==
"INDEXED"
)
else
if
(
n
->
type_id
()
->
name_
==
"INDEXED"
)
...
...
src/cc/codegen_llvm.h
View file @
32109bf9
...
@@ -37,8 +37,6 @@ class StructType;
...
@@ -37,8 +37,6 @@ class StructType;
class
SwitchInst
;
class
SwitchInst
;
}
}
#define BPF_FN_PREFIX ".bpf.fn."
namespace
ebpf
{
namespace
ebpf
{
namespace
cc
{
namespace
cc
{
...
...
src/libbpf.h
View file @
32109bf9
...
@@ -49,6 +49,10 @@ int bpf_detach_kprobe(const char *event_desc);
...
@@ -49,6 +49,10 @@ int bpf_detach_kprobe(const char *event_desc);
#define LOG_BUF_SIZE 65536
#define LOG_BUF_SIZE 65536
extern
char
bpf_log_buf
[
LOG_BUF_SIZE
];
extern
char
bpf_log_buf
[
LOG_BUF_SIZE
];
// Put non-static/inline functions in their own section with this prefix +
// fn_name to enable discovery by the bcc library.
#define BPF_FN_PREFIX ".bpf.fn."
/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
#define BPF_ALU64_REG(OP, DST, SRC) \
#define BPF_ALU64_REG(OP, DST, SRC) \
...
...
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