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
613f19a2
Commit
613f19a2
authored
Nov 07, 2018
by
Jon Haslam
Committed by
Alastair Robertson
Nov 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gracefully handle invalid probe names
parent
56fdbc0a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
15 deletions
+39
-15
src/types.cpp
src/types.cpp
+27
-14
src/types.h
src/types.h
+1
-1
tests/bpftrace.cpp
tests/bpftrace.cpp
+11
-0
No files found.
src/types.cpp
View file @
613f19a2
#include <iostream>
#include <iostream>
#include <algorithm>
#include "types.h"
#include "types.h"
...
@@ -53,24 +54,36 @@ std::string typestr(Type t)
...
@@ -53,24 +54,36 @@ std::string typestr(Type t)
}
}
}
}
ProbeType
probetype
(
const
std
::
string
&
typ
e
)
ProbeType
probetype
(
const
std
::
string
&
probeNam
e
)
{
{
for
(
int
i
=
0
;
i
<
sizeof
(
PROBE_LIST
);
i
++
)
ProbeType
retType
=
ProbeType
::
invalid
;
{
if
(
type
==
PROBE_LIST
[
i
].
name
||
type
==
PROBE_LIST
[
i
].
abbr
)
auto
v
=
std
::
find_if
(
PROBE_LIST
.
begin
(),
PROBE_LIST
.
end
(),
return
PROBE_LIST
[
i
].
type
;
[
&
probeName
]
(
const
ProbeItem
&
p
)
{
}
return
(
p
.
name
==
probeName
||
abort
();
p
.
abbr
==
probeName
);
});
if
(
v
!=
PROBE_LIST
.
end
())
retType
=
v
->
type
;
return
retType
;
}
}
std
::
string
probetypeName
(
const
std
::
string
&
typ
e
)
std
::
string
probetypeName
(
const
std
::
string
&
probeNam
e
)
{
{
for
(
int
i
=
0
;
i
<
sizeof
(
PROBE_LIST
);
i
++
)
std
::
string
res
=
probeName
;
{
if
(
type
==
PROBE_LIST
[
i
].
name
||
type
==
PROBE_LIST
[
i
].
abbr
)
auto
v
=
std
::
find_if
(
PROBE_LIST
.
begin
(),
PROBE_LIST
.
end
(),
return
PROBE_LIST
[
i
].
name
;
[
&
probeName
]
(
const
ProbeItem
&
p
)
{
}
return
(
p
.
name
==
probeName
||
return
type
;
p
.
abbr
==
probeName
);
});
if
(
v
!=
PROBE_LIST
.
end
())
res
=
v
->
name
;
return
res
;
}
}
uint64_t
asyncactionint
(
AsyncAction
a
)
uint64_t
asyncactionint
(
AsyncAction
a
)
...
...
src/types.h
View file @
613f19a2
...
@@ -79,7 +79,7 @@ struct ProbeItem
...
@@ -79,7 +79,7 @@ struct ProbeItem
ProbeType
type
;
ProbeType
type
;
};
};
const
ProbeItem
PROBE_LIST
[]
=
const
std
::
vector
<
ProbeItem
>
PROBE_LIST
=
{
{
{
"kprobe"
,
"k"
,
ProbeType
::
kprobe
},
{
"kprobe"
,
"k"
,
ProbeType
::
kprobe
},
{
"kretprobe"
,
"kr"
,
ProbeType
::
kretprobe
},
{
"kretprobe"
,
"kr"
,
ProbeType
::
kretprobe
},
...
...
tests/bpftrace.cpp
View file @
613f19a2
...
@@ -417,6 +417,17 @@ TEST(bpftrace, add_probes_hardware)
...
@@ -417,6 +417,17 @@ TEST(bpftrace, add_probes_hardware)
check_hardware
(
bpftrace
.
get_probes
().
at
(
0
),
"cache-references"
,
1000000
,
probe_orig_name
);
check_hardware
(
bpftrace
.
get_probes
().
at
(
0
),
"cache-references"
,
1000000
,
probe_orig_name
);
}
}
TEST
(
bpftrace
,
invalid_provider
)
{
ast
::
AttachPoint
a
(
"lookatme"
,
"invalid"
);
ast
::
AttachPointList
attach_points
=
{
&
a
};
ast
::
Probe
probe
(
&
attach_points
,
nullptr
,
nullptr
);
StrictMock
<
MockBPFtrace
>
bpftrace
;
EXPECT_EQ
(
0
,
bpftrace
.
add_probe
(
probe
));
}
std
::
pair
<
std
::
vector
<
uint8_t
>
,
std
::
vector
<
uint8_t
>>
key_value_pair_int
(
std
::
vector
<
uint64_t
>
key
,
int
val
)
std
::
pair
<
std
::
vector
<
uint8_t
>
,
std
::
vector
<
uint8_t
>>
key_value_pair_int
(
std
::
vector
<
uint64_t
>
key
,
int
val
)
{
{
std
::
pair
<
std
::
vector
<
uint8_t
>
,
std
::
vector
<
uint8_t
>>
pair
;
std
::
pair
<
std
::
vector
<
uint8_t
>
,
std
::
vector
<
uint8_t
>>
pair
;
...
...
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