Commit 17117141 authored by Alastair Robertson's avatar Alastair Robertson

Add retval builtin

parent fb4c1733
...@@ -61,6 +61,7 @@ Variables: ...@@ -61,6 +61,7 @@ Variables:
- `nsecs` - Nanosecond timestamp - `nsecs` - Nanosecond timestamp
- `stack` - Kernel stack trace - `stack` - Kernel stack trace
- `arg0`, `arg1`, ... etc. - Arguments to the function being traced - `arg0`, `arg1`, ... etc. - Arguments to the function being traced
- `retval` - Return value from function being traced
Functions: Functions:
- `quantize(int n)` - produce a log2 histogram of values of `n` - `quantize(int n)` - produce a log2 histogram of values of `n`
......
...@@ -62,6 +62,14 @@ void CodegenLLVM::visit(Builtin &builtin) ...@@ -62,6 +62,14 @@ void CodegenLLVM::visit(Builtin &builtin)
b_.CreateProbeRead(dst, b_.getInt64(8), src); b_.CreateProbeRead(dst, b_.getInt64(8), src);
expr_ = b_.CreateLoad(dst); expr_ = b_.CreateLoad(dst);
} }
else if (builtin.ident == "retval")
{
AllocaInst *dst = b_.CreateAllocaBPF();
int offset = arch::ret_offset() * sizeof(uintptr_t);
Value *src = b_.CreateGEP(ctx_, b_.getInt64(offset));
b_.CreateProbeRead(dst, b_.getInt64(8), src);
expr_ = b_.CreateLoad(dst);
}
else else
{ {
abort(); abort();
......
...@@ -19,7 +19,8 @@ void SemanticAnalyser::visit(Builtin &builtin) ...@@ -19,7 +19,8 @@ void SemanticAnalyser::visit(Builtin &builtin)
builtin.ident == "pid" || builtin.ident == "pid" ||
builtin.ident == "tid" || builtin.ident == "tid" ||
builtin.ident == "uid" || builtin.ident == "uid" ||
builtin.ident == "gid") { builtin.ident == "gid" ||
builtin.ident == "retval") {
type_ = Type::integer; type_ = Type::integer;
} }
else if (builtin.ident == "stack") else if (builtin.ident == "stack")
......
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