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
cbb6ea5b
Commit
cbb6ea5b
authored
Oct 17, 2018
by
Brendan Gregg
Committed by
GitHub
Oct 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #193 from cneira/issue20
Add file globbing search semantics to list_probes()
parents
dac74162
e1311ed0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
13 deletions
+30
-13
src/list.cpp
src/list.cpp
+30
-13
No files found.
src/list.cpp
View file @
cbb6ea5b
...
...
@@ -16,22 +16,39 @@ namespace bpftrace {
const
std
::
string
kprobe_path
=
"/sys/kernel/debug/tracing/available_filter_functions"
;
const
std
::
string
tp_path
=
"/sys/kernel/debug/tracing/events"
;
bool
search_probe
(
const
std
::
string
&
probe
,
const
std
::
string
search
)
std
::
string
replace_all
(
const
std
::
string
&
str
,
const
std
::
string
&
from
,
const
std
::
string
&
to
)
{
std
::
string
s
=
search
;
char
remove
[]
=
"*.?"
;
unsigned
int
i
;
std
::
string
result
(
str
);
std
::
string
::
size_type
index
=
0
,
from_len
=
from
.
size
(),
to_len
=
to
.
size
();
while
((
index
=
result
.
find
(
from
,
index
))
!=
std
::
string
::
npos
)
{
result
.
replace
(
index
,
from_len
,
to
);
index
+=
to_len
;
}
return
result
;
}
// TODO: glob searching instead of discarding wildcards
for
(
i
=
0
;
i
<
strlen
(
remove
);
++
i
)
{
s
.
erase
(
std
::
remove
(
s
.
begin
(),
s
.
end
(),
remove
[
i
]),
s
.
end
());
bool
search_probe
(
const
std
::
string
&
probe
,
const
std
::
string
&
search
)
{
try
{
std
::
string
glob
=
"*"
;
std
::
string
regex
=
".*"
;
std
::
string
s
=
replace_all
(
search
,
glob
,
regex
);
glob
=
"?"
;
regex
=
"."
;
s
=
replace_all
(
s
,
glob
,
regex
);
s
=
"^"
+
s
+
"$"
;
std
::
regex
re
(
s
,
std
::
regex
::
icase
|
std
::
regex
::
grep
|
std
::
regex
::
nosubs
);
if
(
std
::
regex_search
(
probe
,
re
))
return
false
;
else
return
true
;
}
catch
(
std
::
regex_error
&
e
)
{
return
true
;
}
if
(
probe
.
find
(
s
)
==
std
::
string
::
npos
)
return
true
;
return
false
;
}
void
list_dir
(
const
std
::
string
path
,
std
::
vector
<
std
::
string
>
&
files
)
...
...
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