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
8cc8fc3c
Commit
8cc8fc3c
authored
Oct 05, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Kernel symbols loading
parent
782b34f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
16 deletions
+30
-16
src/cc/bcc_proc.c
src/cc/bcc_proc.c
+28
-16
src/cc/bcc_proc.h
src/cc/bcc_proc.h
+2
-0
No files found.
src/cc/bcc_proc.c
View file @
8cc8fc3c
...
...
@@ -17,20 +17,28 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <ctype.h>
#include <fcntl.h>
#include <
unistd
.h>
#include <
stdlib
.h>
#include <
limits
.h>
#include <
math
.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "bcc_perf_map.h"
#include "bcc_proc.h"
#include "bcc_elf.h"
#ifdef __x86_64__
// https://www.kernel.org/doc/Documentation/x86/x86_64/mm.txt
const
unsigned
long
long
kernelAddrSpace
=
0x00ffffffffffffff
;
#else
const
unsigned
long
long
kernelAddrSpace
=
0x0
;
#endif
char
*
bcc_procutils_which
(
const
char
*
binpath
)
{
char
buffer
[
4096
];
const
char
*
PATH
;
...
...
@@ -139,7 +147,9 @@ int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback,
int
bcc_procutils_each_ksym
(
bcc_procutils_ksymcb
callback
,
void
*
payload
)
{
char
line
[
2048
];
char
*
symname
,
*
endsym
;
FILE
*
kallsyms
;
unsigned
long
long
addr
;
/* root is needed to list ksym addresses */
if
(
geteuid
()
!=
0
)
...
...
@@ -149,21 +159,23 @@ int bcc_procutils_each_ksym(bcc_procutils_ksymcb callback, void *payload) {
if
(
!
kallsyms
)
return
-
1
;
if
(
!
fgets
(
line
,
sizeof
(
line
),
kallsyms
))
{
fclose
(
kallsyms
);
return
-
1
;
}
while
(
fgets
(
line
,
sizeof
(
line
),
kallsyms
))
{
char
*
symname
,
*
endsym
;
unsigned
long
long
addr
;
addr
=
strtoull
(
line
,
&
symname
,
16
);
endsym
=
symname
=
symname
+
3
;
if
(
addr
==
0
||
addr
==
ULLONG_MAX
)
continue
;
if
(
addr
<
kernelAddrSpace
)
continue
;
symname
++
;
// Ignore data symbols
if
(
*
symname
==
'b'
||
*
symname
==
'B'
||
*
symname
==
'd'
||
*
symname
==
'D'
||
*
symname
==
'r'
||
*
symname
==
'R'
)
continue
;
endsym
=
(
symname
=
symname
+
2
);
while
(
*
endsym
&&
!
isspace
(
*
endsym
))
endsym
++
;
*
endsym
=
'\0'
;
callback
(
symname
,
addr
,
payload
);
}
...
...
src/cc/bcc_proc.h
View file @
8cc8fc3c
...
...
@@ -41,6 +41,8 @@ int bcc_mapping_is_file_backed(const char *mapname);
// Returns -1 on error, and 0 on success
int
bcc_procutils_each_module
(
int
pid
,
bcc_procutils_modulecb
callback
,
void
*
payload
);
// Iterate over all non-data Kernel symbols.
// Returns -1 on error, and 0 on success
int
bcc_procutils_each_ksym
(
bcc_procutils_ksymcb
callback
,
void
*
payload
);
void
bcc_procutils_free
(
const
char
*
ptr
);
const
char
*
bcc_procutils_language
(
int
pid
);
...
...
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