Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbpf-tools: javagc: Hints for more information #5154

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions libbpf-tools/javagc.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,39 @@ static int get_jvmso_path(char *path)
size_t seg_start, seg_end, seg_off;
FILE *f;
int i = 0;
bool found = false;

if (env.pid == -1) {
fprintf(stderr, "not specify pid, see --pid.\n");
return -1;
}

sprintf(buf, "/proc/%d/maps", env.pid);
f = fopen(buf, "r");
if (!f)
if (!f) {
fprintf(stderr, "open %s failed: %m\n", buf);
return -1;
}

while (fscanf(f, "%zx-%zx %s %zx %*s %*d%[^\n]\n",
&seg_start, &seg_end, mode, &seg_off, line) == 5) {
i = 0;
while (isblank(line[i]))
i++;
if (strstr(line + i, "libjvm.so")) {
found = true;
strcpy(path, line + i);
break;
}
}

strcpy(path, line + i);
fclose(f);

if (!found) {
fprintf(stderr, "Not found libjvm.so.\n");
return -ENOENT;
}

return 0;
}

Expand Down
Loading