Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
23e0de79
Commit
23e0de79
authored
8 years ago
by
4ast
Committed by
GitHub
8 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #904 from brendangregg/master
add some error hints
parents
68ec110d
3482637a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
src/cc/libbpf.c
src/cc/libbpf.c
+32
-0
No files found.
src/cc/libbpf.c
View file @
23e0de79
...
@@ -137,6 +137,37 @@ int bpf_get_next_key(int fd, void *key, void *next_key)
...
@@ -137,6 +137,37 @@ int bpf_get_next_key(int fd, void *key, void *next_key)
return
syscall
(
__NR_bpf
,
BPF_MAP_GET_NEXT_KEY
,
&
attr
,
sizeof
(
attr
));
return
syscall
(
__NR_bpf
,
BPF_MAP_GET_NEXT_KEY
,
&
attr
,
sizeof
(
attr
));
}
}
void
bpf_print_hints
(
char
*
log
)
{
if
(
log
==
NULL
)
return
;
// The following error strings will need maintenance to match LLVM.
// stack busting
if
(
strstr
(
log
,
"invalid stack off=-"
)
!=
NULL
)
{
fprintf
(
stderr
,
"HINT: Looks like you exceeded the BPF stack limit. "
"This can happen if you allocate too much local variable storage. "
"For example, if you allocated a 1 Kbyte struct (maybe for "
"BPF_PERF_OUTPUT), busting a max stack of 512 bytes.
\n\n
"
);
}
// didn't check NULL on map lookup
if
(
strstr
(
log
,
"invalid mem access 'map_value_or_null'"
)
!=
NULL
)
{
fprintf
(
stderr
,
"HINT: The 'map_value_or_null' error can happen if "
"you dereference a pointer value from a map lookup without first "
"checking if that pointer is NULL.
\n\n
"
);
}
// lacking a bpf_probe_read
if
(
strstr
(
log
,
"invalid mem access 'inv'"
)
!=
NULL
)
{
fprintf
(
stderr
,
"HINT: The invalid mem access 'inv' error can happen "
"if you try to dereference memory without first using "
"bpf_probe_read() to copy it to the BPF stack. Sometimes the "
"bpf_probe_read is automatic by the bcc rewriter, other times "
"you'll need to be explicit.
\n\n
"
);
}
}
#define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
#define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
int
bpf_prog_load
(
enum
bpf_prog_type
prog_type
,
int
bpf_prog_load
(
enum
bpf_prog_type
prog_type
,
...
@@ -221,6 +252,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
...
@@ -221,6 +252,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
}
}
fprintf
(
stderr
,
"bpf: %s
\n
%s
\n
"
,
strerror
(
errno
),
bpf_log_buffer
);
fprintf
(
stderr
,
"bpf: %s
\n
%s
\n
"
,
strerror
(
errno
),
bpf_log_buffer
);
bpf_print_hints
(
bpf_log_buffer
);
free
(
bpf_log_buffer
);
free
(
bpf_log_buffer
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment