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
c2c6bf3d
Commit
c2c6bf3d
authored
Sep 15, 2018
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support negative integers
parent
97001f83
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
1 deletion
+11
-1
src/ast/ast.cpp
src/ast/ast.cpp
+1
-0
src/ast/codegen_llvm.cpp
src/ast/codegen_llvm.cpp
+1
-0
src/lexer.l
src/lexer.l
+1
-1
src/parser.yy
src/parser.yy
+1
-0
tests/parser.cpp
tests/parser.cpp
+7
-0
No files found.
src/ast/ast.cpp
View file @
c2c6bf3d
...
...
@@ -106,6 +106,7 @@ std::string opstr(Unop &unop)
switch
(
unop
.
op
)
{
case
bpftrace
:
:
Parser
::
token
::
LNOT
:
return
"!"
;
case
bpftrace
:
:
Parser
::
token
::
BNOT
:
return
"~"
;
case
bpftrace
:
:
Parser
::
token
::
MINUS
:
return
"-"
;
case
bpftrace
:
:
Parser
::
token
::
MUL
:
return
"dereference"
;
default:
abort
();
}
...
...
src/ast/codegen_llvm.cpp
View file @
c2c6bf3d
...
...
@@ -625,6 +625,7 @@ void CodegenLLVM::visit(Unop &unop)
switch
(
unop
.
op
)
{
case
bpftrace
:
:
Parser
::
token
::
LNOT
:
expr_
=
b_
.
CreateNot
(
expr_
);
break
;
case
bpftrace
:
:
Parser
::
token
::
BNOT
:
expr_
=
b_
.
CreateNeg
(
expr_
);
break
;
case
bpftrace
:
:
Parser
::
token
::
MINUS
:
expr_
=
b_
.
CreateNeg
(
expr_
);
break
;
case
bpftrace
:
:
Parser
::
token
::
MUL
:
{
int
size
=
type
.
size
;
...
...
src/lexer.l
View file @
c2c6bf3d
...
...
@@ -53,7 +53,7 @@ pid|tid|uid|gid|nsecs|cpu|comm|stack|ustack|arg[0-9]|retval|func|name|curtask|ra
{path} { return Parser::make_PATH(yytext, loc); }
{map} { return Parser::make_MAP(yytext, loc); }
{var} { return Parser::make_VAR(yytext, loc); }
{int} { return Parser::make_INT(strto
u
l(yytext, NULL, 0), loc); }
{int} { return Parser::make_INT(strto
l
l(yytext, NULL, 0), loc); }
":" { return Parser::make_COLON(loc); }
";" { return Parser::make_SEMI(loc); }
"{" { return Parser::make_LBRACE(loc); }
...
...
src/parser.yy
View file @
c2c6bf3d
...
...
@@ -198,6 +198,7 @@ expr : INT { $$ = new ast::Integer($1); }
| expr BXOR expr { $$ = new ast::Binop($1, token::BXOR, $3); }
| LNOT expr { $$ = new ast::Unop(token::LNOT, $2); }
| BNOT expr { $$ = new ast::Unop(token::BNOT, $2); }
| MINUS expr { $$ = new ast::Unop(token::MINUS, $2); }
| MUL expr %prec DEREF { $$ = new ast::Unop(token::MUL, $2); }
| expr DOT ident { $$ = new ast::FieldAccess($1, $3); }
| expr PTR ident { $$ = new ast::FieldAccess(new ast::Unop(token::MUL, $1), $3); }
...
...
tests/parser.cpp
View file @
c2c6bf3d
...
...
@@ -125,6 +125,13 @@ TEST(Parser, variable_assign)
" =
\n
"
" variable: $x
\n
"
" int: 1
\n
"
);
test
(
"kprobe:sys_open { $x = -1; }"
,
"Program
\n
"
" kprobe:sys_open
\n
"
" =
\n
"
" variable: $x
\n
"
" -
\n
"
" int: 1
\n
"
);
}
TEST
(
Parser
,
integer_sizes
)
...
...
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