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
7c965b31
Commit
7c965b31
authored
Feb 22, 2017
by
4ast
Committed by
GitHub
Feb 22, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #999 from markdrayton/perf-map-anon
Improve matching of file-backed memory mappings
parents
02884a02
13685088
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
src/cc/bcc_proc.c
src/cc/bcc_proc.c
+11
-1
src/cc/bcc_proc.h
src/cc/bcc_proc.h
+1
-0
tests/cc/test_c_api.cc
tests/cc/test_c_api.cc
+12
-0
No files found.
src/cc/bcc_proc.c
View file @
7c965b31
...
...
@@ -70,6 +70,16 @@ char *bcc_procutils_which(const char *binpath) {
return
0
;
}
int
bcc_mapping_is_file_backed
(
const
char
*
mapname
)
{
return
mapname
[
0
]
&&
strncmp
(
mapname
,
"//anon"
,
sizeof
(
"//anon"
)
-
1
)
&&
strncmp
(
mapname
,
"/dev/zero"
,
sizeof
(
"/dev/zero"
)
-
1
)
&&
strncmp
(
mapname
,
"/anon_hugepage"
,
sizeof
(
"/anon_hugepage"
)
-
1
)
&&
strncmp
(
mapname
,
"[stack"
,
sizeof
(
"[stack"
)
-
1
)
&&
strncmp
(
mapname
,
"/SYSV"
,
sizeof
(
"/SYSV"
)
-
1
)
&&
strncmp
(
mapname
,
"[heap]"
,
sizeof
(
"[heap]"
)
-
1
);
}
int
bcc_procutils_each_module
(
int
pid
,
bcc_procutils_modulecb
callback
,
void
*
payload
)
{
char
procmap_filename
[
128
];
...
...
@@ -102,7 +112,7 @@ int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback,
while
(
isspace
(
mapname
[
0
]))
mapname
++
;
if
(
strchr
(
perm
,
'x'
)
&&
mapname
[
0
]
&&
mapname
[
0
]
!=
'['
)
{
if
(
strchr
(
perm
,
'x'
)
&&
bcc_mapping_is_file_backed
(
mapname
)
)
{
if
(
callback
(
mapname
,
(
uint64_t
)
begin
,
(
uint64_t
)
end
,
payload
)
<
0
)
break
;
}
...
...
src/cc/bcc_proc.h
View file @
7c965b31
...
...
@@ -29,6 +29,7 @@ typedef void (*bcc_procutils_ksymcb)(const char *, uint64_t, void *);
char
*
bcc_procutils_which_so
(
const
char
*
libname
,
int
pid
);
char
*
bcc_procutils_which
(
const
char
*
binpath
);
int
bcc_mapping_is_file_backed
(
const
char
*
mapname
);
int
bcc_procutils_each_module
(
int
pid
,
bcc_procutils_modulecb
callback
,
void
*
payload
);
int
bcc_procutils_each_ksym
(
bcc_procutils_ksymcb
callback
,
void
*
payload
);
...
...
tests/cc/test_c_api.cc
View file @
7c965b31
...
...
@@ -64,6 +64,18 @@ TEST_CASE("list all kernel symbols", "[c_api]") {
bcc_procutils_each_ksym
(
_test_ksym
,
NULL
);
}
TEST_CASE
(
"file-backed mapping identification"
)
{
CHECK
(
bcc_mapping_is_file_backed
(
"/bin/ls"
)
==
1
);
CHECK
(
bcc_mapping_is_file_backed
(
""
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"//anon"
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"/dev/zero"
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"/anon_hugepage"
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"/anon_hugepage (deleted)"
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"[stack"
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"/SYSV"
)
==
0
);
CHECK
(
bcc_mapping_is_file_backed
(
"[heap]"
)
==
0
);
}
TEST_CASE
(
"resolve symbol name in external library"
,
"[c_api]"
)
{
struct
bcc_symbol
sym
;
...
...
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