Re: bcc tools open procmap fails

Yonghong Song

// always fails, with errno = 2
procmap = fopen(procmap_filename, "r");
errno 2 (ENOENT) means file does not exist. You can add additional
print to check whether the file truly exists or not.

On Sat, Aug 12, 2017 at 5:14 AM, Fenggang Wu via iovisor-dev
<iovisor-dev@...> wrote:
Hi there,

I am trying out bcc tools from, more
specificaly and However in the tracing result,
user functions are shown as "[unknown]", whereas kernel functions such as
"sys_*" are interpreted well. Any ideas?

Thank you very much!


Here are more details (I use as the example). If there are more
details that are necessary please feel free to let me know.

1) how to reproduce the issue:
#~> cat Makefile
g++ -o spin
objcopy --only-keep-debug spin spin.debug
objcopy --add-gnu-debuglink=spin.debug spin

rm spin spin.debug
#~> cat
using namespace std;
void myfunc() {
int i, j, cnt;
cout << "my func" << endl;
for (i = 0; i < 4; i++) {
for ( j = 0; j < 500000000; j++) {
cnt ^= i + j;
cout << i << " " << cnt;

int main() {
cout << "hello" << endl;
#~> cat
sudo make

sudo -- bash -c "./spin & PID=\$!; echo PID=\$PID; cat /proc/\$PID/maps;
(trap - SIGINT; profile -U -p \$PID > spin.profile)& wait \$PID;"; sudo kill
-SIGINT `pgrep -x profile`; sleep 1; cat spin.profile;
sleep 1
sudo make clean


Here, in my server, spin.profile cannot resolve user-level symbols (i.e.
symbols in It only shows userland symbol names as "[unknown]".

I am using Ubuntu 16.04.3 LTS with Linux Kernel ver. 4.10.0-28-generic. I've
tried both installing by apt-get or building from source (latest pull from
github). the results are the same: user-land functions names cannot be

2) What I've tried/found:

- perf_event works well under my environment in resolving both the kernel
and userspace symbols.
- bcc/test/python/ pass all tests. Showing that build-id
and debug-link both methods work in bcc.
- [MAJOR PROBLEM] I found the failed statement:
int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback, void
*payload) {

// always fails, with errno = 2
procmap = fopen(procmap_filename, "r");


- Afterwards, I've written a similar little c++ program to read
"/proc/pid/maps", and it can open/read the proc map file successfully.
Besides, I can also cat the proc map file in the shell, the file can be read
successfully too.

the little testing c++ program to open and read the procmap file is as
follows (very similar to bcc_procutils_each_module):

#~> cat
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <errno.h>

int main(int argc, char*argv[]) {
char procmap_filename[128];
FILE *procmap;
int ret;

printf("%d\n", argc);

if (argc != 2) return -1;


snprintf(procmap_filename, sizeof(procmap_filename),
"/proc/%s/maps", argv[1]);
procmap = fopen(procmap_filename, "r");

printf("mytest: fopen <%s>\n", procmap_filename);

if (!procmap) {
printf("mytest: ... failed errno=%d\n", errno);
return -1;

printf("mytest: ... success <%s>\n", procmap_filename);

do {
char endline[4096];
char perm[8], dev[8];
long long begin, end, size, inode;

ret = fscanf(procmap, "%llx-%llx %s %llx %s %lld", &begin, &end, perm,
&size, dev, &inode);

if (!fgets(endline, sizeof(endline), procmap))

if (ret == 6) {
char *mapname = endline;
char *newline = strchr(endline, '\n');

if (newline)
newline[0] = '\0';

while (isspace(mapname[0])) mapname++;

printf("%s, %llx, %llx\n", mapname, begin, end);
} while (ret && ret != EOF);

printf("mytest: fclosed %s\n", procmap_filename);
return 0;


iovisor-dev mailing list

Join { to automatically receive all group messages.