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
454cdd08
Commit
454cdd08
authored
Mar 06, 2018
by
Brendan Gregg
Committed by
Alastair Robertson
Mar 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support printf() format widths
parent
d5d5acd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
src/printf.cpp
src/printf.cpp
+10
-2
No files found.
src/printf.cpp
View file @
454cdd08
...
...
@@ -7,7 +7,7 @@ namespace bpftrace {
std
::
string
verify_format_string
(
const
std
::
string
&
fmt
,
std
::
vector
<
SizedType
>
args
)
{
std
::
stringstream
message
;
std
::
regex
re
(
"%[a-zA-Z]"
);
std
::
regex
re
(
"%
-?[0-9]*
[a-zA-Z]"
);
auto
tokens_begin
=
std
::
sregex_iterator
(
fmt
.
begin
(),
fmt
.
end
(),
re
);
auto
tokens_end
=
std
::
sregex_iterator
();
...
...
@@ -33,7 +33,15 @@ std::string verify_format_string(const std::string &fmt, std::vector<SizedType>
Type
arg_type
=
args
.
at
(
i
).
type
;
if
(
arg_type
==
Type
::
sym
||
arg_type
==
Type
::
usym
)
arg_type
=
Type
::
string
;
// Symbols should be printed as strings
char
token
=
token_iter
->
str
()[
1
];
int
offset
=
1
;
// skip over format widths during verification
if
(
token_iter
->
str
()[
offset
]
==
'-'
)
offset
++
;
while
(
token_iter
->
str
()[
offset
]
>=
'0'
&&
token_iter
->
str
()[
offset
]
<=
'9'
)
offset
++
;
char
token
=
token_iter
->
str
()[
offset
];
Type
token_type
;
switch
(
token
)
...
...
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