Commit 86848e6e authored by Peter Sanford's avatar Peter Sanford

Support printf("%s") for stack and ustack

This works similarly to how printf'ing a Type::usym works.

When verifying the printf format string we treat stack and ustack as
Type::string. BPFtrace:get_arg_values now knows how to resolve these.

Fixes #10
parent b84eca1e
......@@ -354,6 +354,14 @@ std::vector<uint64_t> BPFtrace::get_arg_values(std::vector<Field> args, uint8_t*
name = strdup(resolve_name(*(uint64_t*)(arg_data+arg.offset)).c_str());
arg_values.push_back((uint64_t)name);
break;
case Type::stack:
name = strdup(get_stack(*(uint64_t*)(arg_data+arg.offset), false, 8).c_str());
arg_values.push_back((uint64_t)name);
break;
case Type::ustack:
name = strdup(get_stack(*(uint64_t*)(arg_data+arg.offset), true, 8).c_str());
arg_values.push_back((uint64_t)name);
break;
default:
abort();
}
......
......@@ -33,7 +33,8 @@ std::string verify_format_string(const std::string &fmt, std::vector<Field> args
for (int i=0; i<num_args; i++, token_iter++)
{
Type arg_type = args.at(i).type.type;
if (arg_type == Type::sym || arg_type == Type::usym || arg_type == Type::name || arg_type == Type::username)
if (arg_type == Type::sym || arg_type == Type::usym || arg_type == Type::name ||
arg_type == Type::username || arg_type == Type::stack || arg_type == Type::ustack)
arg_type = Type::string; // Symbols should be printed as strings
int offset = 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