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
d1233156
Commit
d1233156
authored
Oct 16, 2018
by
Alastair Robertson
Committed by
GitHub
Oct 16, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #166 from psanford/fix-uprobe-golang-symbols
Allow '.' in idents for golang
parents
d9fb8982
80792a52
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
19 deletions
+41
-19
src/ast/ast.h
src/ast/ast.h
+6
-4
src/bpftrace.cpp
src/bpftrace.cpp
+4
-3
src/parser.yy
src/parser.yy
+2
-1
tests/ast.cpp
tests/ast.cpp
+5
-5
tests/bpftrace.cpp
tests/bpftrace.cpp
+20
-6
tests/parser.cpp
tests/parser.cpp
+4
-0
No files found.
src/ast/ast.h
View file @
d1233156
...
...
@@ -199,20 +199,22 @@ public:
:
provider
(
provider
)
{
}
AttachPoint
(
const
std
::
string
&
provider
,
const
std
::
string
&
func
)
:
provider
(
provider
),
func
(
func
)
{
}
:
provider
(
provider
),
func
(
func
)
,
need_expansion
(
true
)
{
}
AttachPoint
(
const
std
::
string
&
provider
,
const
std
::
string
&
target
,
const
std
::
string
&
func
)
:
provider
(
provider
),
target
(
target
),
func
(
func
)
{
}
const
std
::
string
&
func
,
bool
need_expansion
)
:
provider
(
provider
),
target
(
target
),
func
(
func
),
need_expansion
(
need_expansion
)
{
}
AttachPoint
(
const
std
::
string
&
provider
,
const
std
::
string
&
target
,
int
freq
)
:
provider
(
provider
),
target
(
target
),
freq
(
freq
)
{
}
:
provider
(
provider
),
target
(
target
),
freq
(
freq
)
,
need_expansion
(
true
)
{
}
std
::
string
provider
;
std
::
string
target
;
std
::
string
func
;
int
freq
=
0
;
bool
need_expansion
=
false
;
void
accept
(
Visitor
&
v
)
override
;
std
::
string
name
(
const
std
::
string
&
attach_point
)
const
;
...
...
src/bpftrace.cpp
View file @
d1233156
...
...
@@ -59,9 +59,10 @@ int BPFtrace::add_probe(ast::Probe &p)
}
std
::
vector
<
std
::
string
>
attach_funcs
;
if
(
attach_point
->
func
.
find
(
"*"
)
!=
std
::
string
::
npos
||
if
(
attach_point
->
need_expansion
&&
(
attach_point
->
func
.
find
(
"*"
)
!=
std
::
string
::
npos
||
attach_point
->
func
.
find
(
"["
)
!=
std
::
string
::
npos
&&
attach_point
->
func
.
find
(
"]"
)
!=
std
::
string
::
npos
)
attach_point
->
func
.
find
(
"]"
)
!=
std
::
string
::
npos
)
)
{
std
::
string
file_name
;
switch
(
probetype
(
attach_point
->
provider
))
...
...
src/parser.yy
View file @
d1233156
...
...
@@ -142,7 +142,8 @@ attach_points : attach_points "," attach_point { $$ = $1; $1->push_back($3); }
attach_point : ident { $$ = new ast::AttachPoint($1); }
| ident ":" wildcard { $$ = new ast::AttachPoint($1, $3); }
| ident PATH wildcard { $$ = new ast::AttachPoint($1, $2.substr(1, $2.size()-2), $3); }
| ident PATH STRING { $$ = new ast::AttachPoint($1, $2.substr(1, $2.size()-2), $3, false); }
| ident PATH wildcard { $$ = new ast::AttachPoint($1, $2.substr(1, $2.size()-2), $3, true); }
| ident PATH INT { $$ = new ast::AttachPoint($1, $2.substr(1, $2.size()-2), $3); }
;
...
...
tests/ast.cpp
View file @
d1233156
...
...
@@ -37,12 +37,12 @@ TEST(ast, probe_name_kprobe)
TEST
(
ast
,
probe_name_uprobe
)
{
AttachPoint
ap1
(
"uprobe"
,
"/bin/sh"
,
"readline"
);
AttachPoint
ap1
(
"uprobe"
,
"/bin/sh"
,
"readline"
,
true
);
AttachPointList
attach_points1
=
{
&
ap1
};
Probe
uprobe1
(
&
attach_points1
,
nullptr
,
nullptr
);
EXPECT_EQ
(
uprobe1
.
name
(),
"uprobe:/bin/sh:readline"
);
AttachPoint
ap2
(
"uprobe"
,
"/bin/sh"
,
"somefunc"
);
AttachPoint
ap2
(
"uprobe"
,
"/bin/sh"
,
"somefunc"
,
true
);
AttachPointList
attach_points2
=
{
&
ap1
,
&
ap2
};
Probe
uprobe2
(
&
attach_points2
,
nullptr
,
nullptr
);
EXPECT_EQ
(
uprobe2
.
name
(),
"uprobe:/bin/sh:readline,uprobe:/bin/sh:somefunc"
);
...
...
@@ -50,12 +50,12 @@ TEST(ast, probe_name_uprobe)
TEST
(
ast
,
probe_name_usdt
)
{
AttachPoint
ap1
(
"usdt"
,
"/bin/sh"
,
"probe1"
);
AttachPoint
ap1
(
"usdt"
,
"/bin/sh"
,
"probe1"
,
true
);
AttachPointList
attach_points1
=
{
&
ap1
};
Probe
usdt1
(
&
attach_points1
,
nullptr
,
nullptr
);
EXPECT_EQ
(
usdt1
.
name
(),
"usdt:/bin/sh:probe1"
);
AttachPoint
ap2
(
"usdt"
,
"/bin/sh"
,
"probe2"
);
AttachPoint
ap2
(
"usdt"
,
"/bin/sh"
,
"probe2"
,
true
);
AttachPointList
attach_points2
=
{
&
ap1
,
&
ap2
};
Probe
usdt2
(
&
attach_points2
,
nullptr
,
nullptr
);
EXPECT_EQ
(
usdt2
.
name
(),
"usdt:/bin/sh:probe1,usdt:/bin/sh:probe2"
);
...
...
@@ -65,7 +65,7 @@ TEST(ast, attach_point_name)
{
AttachPoint
ap1
(
"kprobe"
,
"sys_read"
);
AttachPoint
ap2
(
"kprobe"
,
"sys_thisone"
);
AttachPoint
ap3
(
"uprobe"
,
"/bin/sh"
,
"readline"
);
AttachPoint
ap3
(
"uprobe"
,
"/bin/sh"
,
"readline"
,
true
);
AttachPointList
attach_points
=
{
&
ap1
,
&
ap2
,
&
ap3
};
Probe
kprobe
(
&
attach_points
,
nullptr
,
nullptr
);
EXPECT_EQ
(
ap2
.
name
(
"sys_thisone"
),
"kprobe:sys_thisone"
);
...
...
tests/bpftrace.cpp
View file @
d1233156
...
...
@@ -240,7 +240,7 @@ TEST(bpftrace, add_probes_wildcard_no_matches)
TEST
(
bpftrace
,
add_probes_uprobe
)
{
ast
::
AttachPoint
a
(
"uprobe"
,
"/bin/sh"
,
"foo"
);
ast
::
AttachPoint
a
(
"uprobe"
,
"/bin/sh"
,
"foo"
,
true
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
...
...
@@ -254,7 +254,7 @@ TEST(bpftrace, add_probes_uprobe)
TEST
(
bpftrace
,
add_probes_usdt
)
{
ast
::
AttachPoint
a
(
"usdt"
,
"/bin/sh"
,
"foo"
);
ast
::
AttachPoint
a
(
"usdt"
,
"/bin/sh"
,
"foo"
,
true
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
...
...
@@ -268,7 +268,7 @@ TEST(bpftrace, add_probes_usdt)
TEST
(
bpftrace
,
add_probes_uprobe_wildcard
)
{
ast
::
AttachPoint
a
(
"uprobe"
,
"/bin/sh"
,
"foo*"
);
ast
::
AttachPoint
a
(
"uprobe"
,
"/bin/sh"
,
"foo*"
,
true
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
...
...
@@ -279,9 +279,23 @@ TEST(bpftrace, add_probes_uprobe_wildcard)
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
}
TEST
(
bpftrace
,
add_probes_uprobe_string_literal
)
{
ast
::
AttachPoint
a
(
"uprobe"
,
"/bin/sh"
,
"foo*"
,
false
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
EXPECT_EQ
(
1
,
bpftrace
.
get_probes
().
size
());
EXPECT_EQ
(
0
,
bpftrace
.
get_special_probes
().
size
());
check_uprobe
(
bpftrace
.
get_probes
().
at
(
0
),
"/bin/sh"
,
"foo*"
,
"uprobe:/bin/sh:foo*"
);
}
TEST
(
bpftrace
,
add_probes_tracepoint
)
{
ast
::
AttachPoint
a
(
"tracepoint"
,
"sched"
,
"sched_switch"
);
ast
::
AttachPoint
a
(
"tracepoint"
,
"sched"
,
"sched_switch"
,
true
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
...
...
@@ -297,7 +311,7 @@ TEST(bpftrace, add_probes_tracepoint)
TEST
(
bpftrace
,
add_probes_tracepoint_wildcard
)
{
ast
::
AttachPoint
a
(
"tracepoint"
,
"sched"
,
"sched_*"
);
ast
::
AttachPoint
a
(
"tracepoint"
,
"sched"
,
"sched_*"
,
true
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
...
...
@@ -321,7 +335,7 @@ TEST(bpftrace, add_probes_tracepoint_wildcard)
TEST
(
bpftrace
,
add_probes_tracepoint_wildcard_no_matches
)
{
ast
::
AttachPoint
a
(
"tracepoint"
,
"typo"
,
"typo_*"
);
ast
::
AttachPoint
a
(
"tracepoint"
,
"typo"
,
"typo_*"
,
true
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
...
...
tests/parser.cpp
View file @
d1233156
...
...
@@ -457,6 +457,10 @@ TEST(Parser, uprobe)
"Program
\n
"
" uprobe:/my/program:func
\n
"
" int: 1
\n
"
);
test
(
"uprobe:/my/go/program:
\"
pkg.func\u2C51
\"
{ 1; }"
,
"Program
\n
"
" uprobe:/my/go/program:pkg.func\u2C51
\n
"
" int: 1
\n
"
);
}
TEST
(
Parser
,
usdt
)
...
...
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