Commit 01491c63 authored by Alex Birch's avatar Alex Birch

implement review feedback: pass vector by const ref, use reinterpret cast,...

implement review feedback: pass vector by const ref, use reinterpret cast, remove move() of returned string
parent f88ae0c3
...@@ -343,7 +343,7 @@ void perf_event_printer(void *cb_cookie, void *data, int size) ...@@ -343,7 +343,7 @@ void perf_event_printer(void *cb_cookie, void *data, int size)
} }
} }
std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(std::vector<Field> args, uint8_t* arg_data) std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(const std::vector<Field> &args, uint8_t* arg_data)
{ {
std::vector<std::unique_ptr<IPrintable>> arg_values; std::vector<std::unique_ptr<IPrintable>> arg_values;
...@@ -357,22 +357,22 @@ std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(std::vector<Fi ...@@ -357,22 +357,22 @@ std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(std::vector<Fi
case 8: case 8:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableInt>( std::make_unique<PrintableInt>(
*(uint64_t*)(arg_data+arg.offset))); *reinterpret_cast<uint64_t*>(arg_data+arg.offset)));
break; break;
case 4: case 4:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableInt>( std::make_unique<PrintableInt>(
*(uint32_t*)(arg_data+arg.offset))); *reinterpret_cast<uint32_t*>(arg_data+arg.offset)));
break; break;
case 2: case 2:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableInt>( std::make_unique<PrintableInt>(
*(uint16_t*)(arg_data+arg.offset))); *reinterpret_cast<uint16_t*>(arg_data+arg.offset)));
break; break;
case 1: case 1:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableInt>( std::make_unique<PrintableInt>(
*(uint8_t*)(arg_data+arg.offset))); *reinterpret_cast<uint8_t*>(arg_data+arg.offset)));
break; break;
default: default:
abort(); abort();
...@@ -381,61 +381,54 @@ std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(std::vector<Fi ...@@ -381,61 +381,54 @@ std::vector<std::unique_ptr<IPrintable>> BPFtrace::get_arg_values(std::vector<Fi
case Type::string: case Type::string:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableCString>( std::make_unique<PrintableCString>(
(char *) arg_data+arg.offset)); reinterpret_cast<char *>(arg_data+arg.offset)));
break; break;
case Type::sym: case Type::sym:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move( resolve_sym(*reinterpret_cast<uint64_t*>(arg_data+arg.offset))));
resolve_sym(*(uint64_t*)(arg_data+arg.offset)))));
break; break;
case Type::usym: case Type::usym:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move(
resolve_usym( resolve_usym(
*(uint64_t*)(arg_data+arg.offset), *reinterpret_cast<uint64_t*>(arg_data+arg.offset),
*(uint64_t*)(arg_data+arg.offset + 8))))); *reinterpret_cast<uint64_t*>(arg_data+arg.offset + 8))));
break; break;
case Type::inet: case Type::inet:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move(
resolve_inet( resolve_inet(
*(uint64_t*)(arg_data+arg.offset), *reinterpret_cast<uint64_t*>(arg_data+arg.offset),
*(uint64_t*)(arg_data+arg.offset+8))))); *reinterpret_cast<uint64_t*>(arg_data+arg.offset+8))));
break; break;
case Type::username: case Type::username:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move(
resolve_uid( resolve_uid(
*(uint64_t*)(arg_data+arg.offset))))); *reinterpret_cast<uint64_t*>(arg_data+arg.offset))));
break; break;
case Type::probe: case Type::probe:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move(
resolve_probe( resolve_probe(
*(uint64_t*)(arg_data+arg.offset))))); *reinterpret_cast<uint64_t*>(arg_data+arg.offset))));
break; break;
case Type::stack: case Type::stack:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move(
get_stack( get_stack(
*(uint64_t*)(arg_data+arg.offset), *reinterpret_cast<uint64_t*>(arg_data+arg.offset),
false, false,
8)))); 8)));
break; break;
case Type::ustack: case Type::ustack:
arg_values.push_back( arg_values.push_back(
std::make_unique<PrintableString>( std::make_unique<PrintableString>(
std::move(
get_stack( get_stack(
*(uint64_t*)(arg_data+arg.offset), *reinterpret_cast<uint64_t*>(arg_data+arg.offset),
true, true,
8)))); 8)));
break; break;
default: default:
abort(); abort();
......
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
std::string extract_func_symbols_from_path(const std::string &path); std::string extract_func_symbols_from_path(const std::string &path);
std::string resolve_probe(uint64_t probe_id); std::string resolve_probe(uint64_t probe_id);
uint64_t resolve_cgroupid(const std::string &path); uint64_t resolve_cgroupid(const std::string &path);
std::vector<std::unique_ptr<IPrintable>> get_arg_values(std::vector<Field> args, uint8_t* arg_data); std::vector<std::unique_ptr<IPrintable>> get_arg_values(const std::vector<Field> &args, uint8_t* arg_data);
void add_param(const std::string &param); void add_param(const std::string &param);
bool is_numeric(std::string str); bool is_numeric(std::string str);
std::string get_param(int index); std::string get_param(int index);
......
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