Skip to content

Commit

Permalink
fix: Agent testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
rvql committed Nov 13, 2024
1 parent d46d63f commit 5d953ba
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
12 changes: 10 additions & 2 deletions agent/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5276,7 +5276,7 @@ header_fields_flag: "invalid"
}

#[test]
fn parse_process_matcher() {
fn parse_proc_config() {
let yaml = r#"
process_matcher:
- match_regex: python[2|3].* (.*)\.py
Expand All @@ -5288,7 +5288,15 @@ process_matcher:
ignore: false
enabled_features: [ebpf.socket.uprobe.golang, ebpf.profile.on_cpu]
"#;

let _proc: Proc = serde_yaml::from_str(yaml).unwrap();

let default_matcher_yaml = r#"
enabled: true
"#;
let proc: Proc = serde_yaml::from_str(default_matcher_yaml).unwrap();
assert_eq!(
proc.process_matcher.get(0),
Some(&ProcessMatcher::default())
);
}
}
2 changes: 1 addition & 1 deletion agent/src/ebpf/user/profile/stringifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ char *resolve_and_gen_stack_trace_str(struct bpf_tracer *t,
len += strlen(uprobe_str) + 1;
}

if (v->intpstack >= 0) {
if (v->intpstack != 0) {
i_trace_str = folded_stack_trace_string(t, v->intpstack, v->tgid, custom_stack_map_name, h, new_cache, info_p, v->timestamp, ignore_libs, true);
if (i_trace_str != NULL) {
len += strlen(i_trace_str) + strlen(INCOMPLETE_PYTHON_STACK) + 2;
Expand Down
2 changes: 1 addition & 1 deletion agent/src/ebpf/user/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void insert_prog_to_map(struct bpf_tracer *tracer, const char *map_name,
map_name, key, prog_name);
}

int bpf_table_fd(struct bpf_tracer *tracer, const char *tb_name)
int bpf_table_get_fd(struct bpf_tracer *tracer, const char *tb_name)
{
struct ebpf_map *map = ebpf_obj__get_map_by_name(tracer->obj, tb_name);
if (map == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion agent/src/ebpf/user/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ bool bpf_table_delete_key(struct bpf_tracer * tracer,
void insert_prog_to_map(struct bpf_tracer *tracer, const char *map_name,
const char *prog_name, int key);

int bpf_table_fd(struct bpf_tracer *tracer, const char *tb_name);
int bpf_table_get_fd(struct bpf_tracer *tracer, const char *tb_name);
#endif /* DF_BPF_TABLE_H */
8 changes: 4 additions & 4 deletions agent/src/ebpf/user/unwind_tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ int unwind_tracer_init(struct bpf_tracer *tracer) {
ebpf_warning("unwinder may not handle in kernel perf events correctly");
}

int process_map_fd = bpf_table_fd(tracer, MAP_PROCESS_SHARD_LIST_NAME);
int shard_map_fd = bpf_table_fd(tracer, MAP_UNWIND_ENTRY_SHARD_NAME);
int process_map_fd = bpf_table_get_fd(tracer, MAP_PROCESS_SHARD_LIST_NAME);
int shard_map_fd = bpf_table_get_fd(tracer, MAP_UNWIND_ENTRY_SHARD_NAME);
if (process_map_fd < 0) {
ebpf_warning("create unwind table failed: map %s not found", MAP_PROCESS_SHARD_LIST_NAME);
return -1;
Expand All @@ -218,8 +218,8 @@ int unwind_tracer_init(struct bpf_tracer *tracer) {
g_unwind_table = table;
pthread_mutex_unlock(&g_unwind_table_lock);

int unwind_info_map_fd = bpf_table_fd(tracer, MAP_PYTHON_UNWIND_INFO_NAME);
int offsets_map_fd = bpf_table_fd(tracer, MAP_PYTHON_OFFSETS_NAME);
int unwind_info_map_fd = bpf_table_get_fd(tracer, MAP_PYTHON_UNWIND_INFO_NAME);
int offsets_map_fd = bpf_table_get_fd(tracer, MAP_PYTHON_OFFSETS_NAME);
if (unwind_info_map_fd < 0 || offsets_map_fd < 0) {
ebpf_warning("Failed to get unwind info map fd or offsets map fd\n");
return -1;
Expand Down

0 comments on commit 5d953ba

Please sign in to comment.