Commit 75103640 authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #80 from iovisor/bug

fix 64-bit integer constants
parents 217d6017 6d87525d
......@@ -31,8 +31,8 @@ using ExpressionList = std::vector<Expression *>;
class Integer : public Expression {
public:
explicit Integer(int n) : n(n) { is_literal = true; }
int n;
explicit Integer(long n) : n(n) { is_literal = true; }
long n;
void accept(Visitor &v) override;
};
......
......@@ -78,7 +78,7 @@ void yyerror(bpftrace::Driver &driver, const char *s);
%token <std::string> STRING "string"
%token <std::string> MAP "map"
%token <std::string> VAR "variable"
%token <int> INT "integer"
%token <long> INT "integer"
%type <std::string> c_definitions
%type <ast::ProbeList *> probes
......
......@@ -126,6 +126,22 @@ TEST(Parser, variable_assign)
" int: 1\n");
}
TEST(Parser, integer_sizes)
{
test("kprobe:do_nanosleep { $x = 0x12345678; }",
"Program\n"
" kprobe:do_nanosleep\n"
" =\n"
" variable: $x\n"
" int: 305419896\n");
test("kprobe:do_nanosleep { $x = 0x4444444412345678; }",
"Program\n"
" kprobe:do_nanosleep\n"
" =\n"
" variable: $x\n"
" int: 4919131752149309048\n");
}
TEST(Parser, map_key)
{
test("kprobe:sys_open { @x[0] = 1; @x[0,1,2] = 1; }",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment