restrict to 4-8 byte integer types only
This commit is contained in:
parent
433eae3ee8
commit
52710cf7d2
15
src/main.cpp
15
src/main.cpp
@ -69,12 +69,21 @@ int main(int argc, char **argv) {
|
|||||||
auto var_info = symbol.find_global_var(dbg, var_name);
|
auto var_info = symbol.find_global_var(dbg, var_name);
|
||||||
|
|
||||||
if (!var_info) {
|
if (!var_info) {
|
||||||
std::cerr << "Error: Variable '" << var_name << "' not found" << std::endl;
|
std::cerr << "Error: Variable '" << var_name << "' not found or is not a supported integer type" << std::endl;
|
||||||
|
std::cerr << "Supported types: int (32-bit), long (64-bit), and unsigned variants" << std::endl;
|
||||||
dwarf_finish(dbg);
|
dwarf_finish(dbg);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate variable size (only 4 or 8 bytes)
|
||||||
|
if (var_info->size != 4 && var_info->size != 8) {
|
||||||
|
std::cerr << "Error: Variable '" << var_name << "' has unsupported size: " << var_info->size << " bytes" << std::endl;
|
||||||
|
std::cerr << "Supported sizes: 4 bytes (int) or 8 bytes (long)" << std::endl;
|
||||||
|
dwarf_finish(dbg);
|
||||||
|
close(fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Close DWARF resources before forking
|
// Close DWARF resources before forking
|
||||||
dwarf_finish(dbg);
|
dwarf_finish(dbg);
|
||||||
@ -82,8 +91,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Start watching the variable
|
// Start watching the variable
|
||||||
Tracer tracer;
|
Tracer tracer;
|
||||||
tracer.watch_variable(var_info->name, exec_path.string(), var_info->address,
|
int exit_code = tracer.watch_variable(var_info->name, exec_path.string(), var_info->address,
|
||||||
var_info->size, prog_args);
|
var_info->size, prog_args);
|
||||||
|
|
||||||
return 0;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user