Skip to content

Commit 416d325

Browse files
committed
Remove unused regular tracepoint attachment code from userspace codegen.
1 parent c940f45 commit 416d325

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

src/userspace_codegen.ml

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,64 +3297,6 @@ static int add_attachment(int prog_fd, const char *target, uint32_t flags,
32973297
32983298
return 0;
32993299
}
3300-
case BPF_PROG_TYPE_TRACEPOINT: {
3301-
// For regular tracepoint programs, target is in libbpf format "category:name" (converted from KernelScript "category/name")
3302-
// Use libbpf high-level API for tracepoint attachment
3303-
3304-
// Get the bpf_program struct from the object and file descriptor
3305-
struct bpf_program *prog = NULL;
3306-
3307-
// Find the program object corresponding to this fd
3308-
// We need to get the program from the skeleton object
3309-
if (!obj) {
3310-
fprintf(stderr, "eBPF skeleton not loaded for tracepoint attachment\n");
3311-
return -1;
3312-
}
3313-
3314-
bpf_object__for_each_program(prog, obj->obj) {
3315-
if (bpf_program__fd(prog) == prog_fd) {
3316-
break;
3317-
}
3318-
}
3319-
3320-
if (!prog) {
3321-
fprintf(stderr, "Failed to find bpf_program for fd %d\n", prog_fd);
3322-
return -1;
3323-
}
3324-
3325-
// Parse the target string to extract category and name
3326-
// Internal format: "category:name" (converted from KernelScript "category/name")
3327-
char *target_copy = strdup(target);
3328-
char *category = strtok(target_copy, ":");
3329-
char *name = strtok(NULL, ":");
3330-
3331-
if (!category || !name) {
3332-
fprintf(stderr, "Invalid tracepoint target format: '%s'. Expected 'category:name' format (converted from KernelScript 'category/name')\n", target);
3333-
free(target_copy);
3334-
return -1;
3335-
}
3336-
3337-
// Use libbpf's high-level tracepoint attachment API
3338-
struct bpf_link *link = bpf_program__attach_tracepoint(prog, category, name);
3339-
if (!link) {
3340-
fprintf(stderr, "Failed to attach tracepoint to '%s:%s': %s\n", category, name, strerror(errno));
3341-
free(target_copy);
3342-
return -1;
3343-
}
3344-
3345-
// Store tracepoint attachment for later cleanup
3346-
if (add_attachment(prog_fd, target, flags, link, 0, BPF_PROG_TYPE_TRACEPOINT) != 0) {
3347-
// If storage fails, destroy link and return error
3348-
bpf_link__destroy(link);
3349-
free(target_copy);
3350-
return -1;
3351-
}
3352-
3353-
printf("Tracepoint attached to: %s:%s\n", category, name);
3354-
3355-
free(target_copy);
3356-
return 0;
3357-
}
33583300
case BPF_PROG_TYPE_RAW_TRACEPOINT: {
33593301
// For raw tracepoint programs, target should be just the event name (e.g., "sched_switch")
33603302
// Extract event name from "category:event" format if needed
@@ -3446,15 +3388,6 @@ static int add_attachment(int prog_fd, const char *target, uint32_t flags,
34463388
}
34473389
break;
34483390
}
3449-
case BPF_PROG_TYPE_TRACEPOINT: {
3450-
if (entry->link) {
3451-
bpf_link__destroy(entry->link);
3452-
printf("Tracepoint detached from: %s\n", entry->target);
3453-
} else {
3454-
fprintf(stderr, "Invalid tracepoint link for program fd %d\n", prog_fd);
3455-
}
3456-
break;
3457-
}
34583391
case BPF_PROG_TYPE_RAW_TRACEPOINT: {
34593392
if (entry->link) {
34603393
bpf_link__destroy(entry->link);

0 commit comments

Comments
 (0)