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
7c9d8c93
Commit
7c9d8c93
authored
Oct 06, 2017
by
yonghong-song
Committed by
GitHub
Oct 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1378 from palmtenor/ksyms_opt
Improve Kernel symbols loading
parents
66b8eddf
8cc8fc3c
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 @
7c9d8c93
...
...
@@ -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 @
7c9d8c93
...
...
@@ -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