-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proc: Simplify eBPF backend implementation
* Remove standard C headers since we have vmlinux.h already * Simplify get_goroutine_id() implementation, this reduces a map and thus reduces runtime memory comsumption. While at it, unify all indention using 4 spaces. Signed-off-by: Hengqi Chen <[email protected]>
- Loading branch information
1 parent
4c40e81
commit 9cb3e29
Showing
6 changed files
with
115 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,41 @@ | ||
#include <stdbool.h> | ||
|
||
// function_parameter stores information about a single parameter to a function. | ||
typedef struct function_parameter { | ||
// Type of the parameter as defined by the reflect.Kind enum. | ||
unsigned int kind; | ||
// Size of the variable in bytes. | ||
unsigned int size; | ||
|
||
// Offset from stack pointer. This should only be set from the Go side. | ||
int offset; | ||
|
||
// If true, the parameter is passed in a register. | ||
bool in_reg; | ||
// The number of register pieces the parameter is passed in. | ||
int n_pieces; | ||
// If in_reg is true, this represents the registers that the parameter is passed in. | ||
// This is an array because the number of registers may vary and the parameter may be | ||
// passed in multiple registers. | ||
int reg_nums[6]; | ||
|
||
// The following are filled in by the eBPF program. | ||
size_t daddr; // Data address. | ||
char val[0x30]; // Value of the parameter. | ||
char deref_val[0x30]; // Dereference value of the parameter. | ||
// Type of the parameter as defined by the reflect.Kind enum. | ||
unsigned int kind; | ||
// Size of the variable in bytes. | ||
unsigned int size; | ||
|
||
// Offset from stack pointer. This should only be set from the Go side. | ||
int offset; | ||
|
||
// If true, the parameter is passed in a register. | ||
bool in_reg; | ||
// The number of register pieces the parameter is passed in. | ||
int n_pieces; | ||
// If in_reg is true, this represents the registers that the parameter is passed in. | ||
// This is an array because the number of registers may vary and the parameter may be | ||
// passed in multiple registers. | ||
int reg_nums[6]; | ||
|
||
// The following are filled in by the eBPF program. | ||
size_t daddr; // Data address. | ||
char val[0x30]; // Value of the parameter. | ||
char deref_val[0x30]; // Dereference value of the parameter. | ||
} function_parameter_t; | ||
|
||
// function_parameter_list holds info about the function parameters and | ||
// stores information on up to 6 parameters. | ||
typedef struct function_parameter_list { | ||
unsigned int goid_offset; // Offset of the `goid` struct member. | ||
long long g_addr_offset; // Offset of the Goroutine struct from the TLS segment. | ||
int goroutine_id; | ||
unsigned int goid_offset; // Offset of the `goid` struct member. | ||
long long g_addr_offset; // Offset of the Goroutine struct from the TLS segment. | ||
int goroutine_id; | ||
|
||
unsigned long long int fn_addr; | ||
bool is_ret; | ||
unsigned long long int fn_addr; | ||
bool is_ret; | ||
|
||
unsigned int n_parameters; // number of parameters. | ||
function_parameter_t params[6]; // list of parameters. | ||
unsigned int n_parameters; // number of parameters. | ||
function_parameter_t params[6]; // list of parameters. | ||
|
||
unsigned int n_ret_parameters; // number of return parameters. | ||
function_parameter_t ret_params[6]; // list of return parameters. | ||
unsigned int n_ret_parameters; // number of return parameters. | ||
function_parameter_t ret_params[6]; // list of return parameters. | ||
} function_parameter_list_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.