Commit e8b99cd2 authored by williangaspar's avatar williangaspar
parent e73f69c9
#pragma once #pragma once
#include <iostream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
...@@ -56,7 +57,13 @@ public: ...@@ -56,7 +57,13 @@ public:
class Builtin : public Expression { class Builtin : public Expression {
public: public:
explicit Builtin(std::string ident) : ident(ident) { } explicit Builtin(std::string ident) : ident(ident) {
if (ident == "stack") {
std::cout << "\033[33m warning: \033[0m";
std::cout << "stack is deprecated and will be removed in the future. Use kstack instead" << std::endl;
this->ident = "kstack";
}
}
std::string ident; std::string ident;
int probe_id; int probe_id;
......
...@@ -49,7 +49,7 @@ void CodegenLLVM::visit(Builtin &builtin) ...@@ -49,7 +49,7 @@ void CodegenLLVM::visit(Builtin &builtin)
{ {
expr_ = b_.CreateGetNs(); expr_ = b_.CreateGetNs();
} }
else if (builtin.ident == "stack" || builtin.ident == "ustack") else if (builtin.ident == "kstack" || builtin.ident == "ustack")
{ {
Value *stackid = b_.CreateGetStackId(ctx_, builtin.ident == "ustack"); Value *stackid = b_.CreateGetStackId(ctx_, builtin.ident == "ustack");
// Kernel stacks should not be differentiated by tid, since the kernel // Kernel stacks should not be differentiated by tid, since the kernel
......
...@@ -60,8 +60,8 @@ void SemanticAnalyser::visit(Builtin &builtin) ...@@ -60,8 +60,8 @@ void SemanticAnalyser::visit(Builtin &builtin)
builtin.ident == "retval") { builtin.ident == "retval") {
builtin.type = SizedType(Type::integer, 8); builtin.type = SizedType(Type::integer, 8);
} }
else if (builtin.ident == "stack") { else if (builtin.ident == "kstack") {
builtin.type = SizedType(Type::stack, 8); builtin.type = SizedType(Type::kstack, 8);
needs_stackid_map_ = true; needs_stackid_map_ = true;
} }
else if (builtin.ident == "ustack") { else if (builtin.ident == "ustack") {
......
...@@ -423,7 +423,7 @@ std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(const std::vec ...@@ -423,7 +423,7 @@ std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(const std::vec
resolve_probe( resolve_probe(
*reinterpret_cast<uint64_t*>(arg_data+arg.offset)))); *reinterpret_cast<uint64_t*>(arg_data+arg.offset))));
break; break;
case Type::stack: case Type::kstack:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
get_stack( get_stack(
...@@ -881,7 +881,7 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div) ...@@ -881,7 +881,7 @@ int BPFtrace::print_map(IMap &map, uint32_t top, uint32_t div)
std::cout << map.name_ << map.key_.argument_value_list(*this, key) << ": "; std::cout << map.name_ << map.key_.argument_value_list(*this, key) << ": ";
if (map.type_.type == Type::stack) if (map.type_.type == Type::kstack)
std::cout << get_stack(*(uint64_t*)value.data(), false, 8); std::cout << get_stack(*(uint64_t*)value.data(), false, 8);
else if (map.type_.type == Type::ustack) else if (map.type_.type == Type::ustack)
std::cout << get_stack(*(uint64_t*)value.data(), true, 8); std::cout << get_stack(*(uint64_t*)value.data(), true, 8);
......
...@@ -49,7 +49,7 @@ path :(\\.|[_\-\./a-zA-Z0-9])*: ...@@ -49,7 +49,7 @@ path :(\\.|[_\-\./a-zA-Z0-9])*:
<COMMENT>"*/" BEGIN(INITIAL); <COMMENT>"*/" BEGIN(INITIAL);
<COMMENT>"EOF" driver.error(loc, std::string("end of file during comment")); <COMMENT>"EOF" driver.error(loc, std::string("end of file during comment"));
pid|tid|cgroup|uid|gid|nsecs|cpu|comm|stack|ustack|arg[0-9]|retval|func|probe|curtask|rand|ctx|username|args { pid|tid|cgroup|uid|gid|nsecs|cpu|comm|kstack|stack|ustack|arg[0-9]|retval|func|probe|curtask|rand|ctx|username|args {
return Parser::make_BUILTIN(yytext, loc); } return Parser::make_BUILTIN(yytext, loc); }
{path} { return Parser::make_PATH(yytext, loc); } {path} { return Parser::make_PATH(yytext, loc); }
{map} { return Parser::make_MAP(yytext, loc); } {map} { return Parser::make_MAP(yytext, loc); }
......
...@@ -71,7 +71,7 @@ std::string MapKey::argument_value(BPFtrace &bpftrace, ...@@ -71,7 +71,7 @@ std::string MapKey::argument_value(BPFtrace &bpftrace,
return std::to_string(*(int64_t*)data); return std::to_string(*(int64_t*)data);
break; break;
} }
case Type::stack: case Type::kstack:
return bpftrace.get_stack(*(uint64_t*)data, false); return bpftrace.get_stack(*(uint64_t*)data, false);
case Type::ustack: case Type::ustack:
return bpftrace.get_stack(*(uint64_t*)data, true); return bpftrace.get_stack(*(uint64_t*)data, true);
......
...@@ -34,7 +34,7 @@ std::string verify_format_string(const std::string &fmt, std::vector<Field> args ...@@ -34,7 +34,7 @@ std::string verify_format_string(const std::string &fmt, std::vector<Field> args
{ {
Type arg_type = args.at(i).type.type; Type arg_type = args.at(i).type.type;
if (arg_type == Type::sym || arg_type == Type::usym || arg_type == Type::probe || if (arg_type == Type::sym || arg_type == Type::usym || arg_type == Type::probe ||
arg_type == Type::username || arg_type == Type::stack || arg_type == Type::ustack || arg_type == Type::username || arg_type == Type::kstack || arg_type == Type::ustack ||
arg_type == Type::inet) arg_type == Type::inet)
arg_type = Type::string; // Symbols should be printed as strings arg_type = Type::string; // Symbols should be printed as strings
int offset = 1; int offset = 1;
......
...@@ -43,7 +43,7 @@ std::string typestr(Type t) ...@@ -43,7 +43,7 @@ std::string typestr(Type t)
case Type::max: return "max"; break; case Type::max: return "max"; break;
case Type::avg: return "avg"; break; case Type::avg: return "avg"; break;
case Type::stats: return "stats"; break; case Type::stats: return "stats"; break;
case Type::stack: return "stack"; break; case Type::kstack: return "kstack"; break;
case Type::ustack: return "ustack"; break; case Type::ustack: return "ustack"; break;
case Type::string: return "string"; break; case Type::string: return "string"; break;
case Type::sym: return "sym"; break; case Type::sym: return "sym"; break;
......
...@@ -24,7 +24,7 @@ enum class Type ...@@ -24,7 +24,7 @@ enum class Type
max, max,
avg, avg,
stats, stats,
stack, kstack,
ustack, ustack,
string, string,
sym, sym,
......
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