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
5b40420a
Commit
5b40420a
authored
May 24, 2017
by
4ast
Committed by
GitHub
May 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1196 from palmtenor/cpp_sym_option
Support symbol option in C++ API stack table
parents
2631f6dc
5703ccc1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
11 deletions
+29
-11
src/cc/BPF.cc
src/cc/BPF.cc
+5
-3
src/cc/BPF.h
src/cc/BPF.h
+3
-1
src/cc/BPFTable.cc
src/cc/BPFTable.cc
+13
-1
src/cc/BPFTable.h
src/cc/BPFTable.h
+5
-2
src/cc/bcc_syms.cc
src/cc/bcc_syms.cc
+0
-4
src/cc/bcc_syms.h
src/cc/bcc_syms.h
+3
-0
No files found.
src/cc/BPF.cc
View file @
5b40420a
...
@@ -504,11 +504,13 @@ BPFProgTable BPF::get_prog_table(const std::string& name) {
...
@@ -504,11 +504,13 @@ BPFProgTable BPF::get_prog_table(const std::string& name) {
return
BPFProgTable
({});
return
BPFProgTable
({});
}
}
BPFStackTable
BPF
::
get_stack_table
(
const
std
::
string
&
name
)
{
BPFStackTable
BPF
::
get_stack_table
(
const
std
::
string
&
name
,
bool
use_debug_file
,
bool
check_debug_file_crc
)
{
TableStorage
::
iterator
it
;
TableStorage
::
iterator
it
;
if
(
bpf_module_
->
table_storage
().
Find
(
Path
({
bpf_module_
->
id
(),
name
}),
it
))
if
(
bpf_module_
->
table_storage
().
Find
(
Path
({
bpf_module_
->
id
(),
name
}),
it
))
return
BPFStackTable
(
it
->
second
);
return
BPFStackTable
(
it
->
second
,
use_debug_file
,
check_debug_file_crc
);
return
BPFStackTable
({});
return
BPFStackTable
({}
,
use_debug_file
,
check_debug_file_crc
);
}
}
std
::
string
BPF
::
get_uprobe_event
(
const
std
::
string
&
binary_path
,
std
::
string
BPF
::
get_uprobe_event
(
const
std
::
string
&
binary_path
,
...
...
src/cc/BPF.h
View file @
5b40420a
...
@@ -115,7 +115,9 @@ public:
...
@@ -115,7 +115,9 @@ public:
BPFProgTable
get_prog_table
(
const
std
::
string
&
name
);
BPFProgTable
get_prog_table
(
const
std
::
string
&
name
);
BPFStackTable
get_stack_table
(
const
std
::
string
&
name
);
BPFStackTable
get_stack_table
(
const
std
::
string
&
name
,
bool
use_debug_file
=
true
,
bool
check_debug_file_crc
=
true
);
StatusTuple
open_perf_buffer
(
const
std
::
string
&
name
,
StatusTuple
open_perf_buffer
(
const
std
::
string
&
name
,
perf_reader_raw_cb
cb
,
perf_reader_raw_cb
cb
,
...
...
src/cc/BPFTable.cc
View file @
5b40420a
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
#include <linux/elf.h>
#include <sys/epoll.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <unistd.h>
#include <cerrno>
#include <cerrno>
...
@@ -86,6 +87,17 @@ StatusTuple BPFTable::remove_value(const std::string& key_str) {
...
@@ -86,6 +87,17 @@ StatusTuple BPFTable::remove_value(const std::string& key_str) {
return
StatusTuple
(
0
);
return
StatusTuple
(
0
);
}
}
BPFStackTable
::
BPFStackTable
(
const
TableDesc
&
desc
,
bool
use_debug_file
,
bool
check_debug_file_crc
)
:
BPFTableBase
<
int
,
stacktrace_t
>
(
desc
)
{
symbol_option_
=
{
.
use_debug_file
=
use_debug_file
,
.
check_debug_file_crc
=
check_debug_file_crc
,
.
use_symbol_type
=
(
1
<<
STT_FUNC
)
|
(
1
<<
STT_GNU_IFUNC
)
};
}
BPFStackTable
::~
BPFStackTable
()
{
BPFStackTable
::~
BPFStackTable
()
{
for
(
auto
it
:
pid_sym_
)
for
(
auto
it
:
pid_sym_
)
bcc_free_symcache
(
it
.
second
,
it
.
first
);
bcc_free_symcache
(
it
.
second
,
it
.
first
);
...
@@ -110,7 +122,7 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
...
@@ -110,7 +122,7 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
if
(
pid
<
0
)
if
(
pid
<
0
)
pid
=
-
1
;
pid
=
-
1
;
if
(
pid_sym_
.
find
(
pid
)
==
pid_sym_
.
end
())
if
(
pid_sym_
.
find
(
pid
)
==
pid_sym_
.
end
())
pid_sym_
[
pid
]
=
bcc_symcache_new
(
pid
,
nullptr
);
pid_sym_
[
pid
]
=
bcc_symcache_new
(
pid
,
&
symbol_option_
);
void
*
cache
=
pid_sym_
[
pid
];
void
*
cache
=
pid_sym_
[
pid
];
bcc_symbol
symbol
;
bcc_symbol
symbol
;
...
...
src/cc/BPFTable.h
View file @
5b40420a
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <vector>
#include <vector>
#include "bcc_exception.h"
#include "bcc_exception.h"
#include "bcc_syms.h"
#include "bpf_module.h"
#include "bpf_module.h"
#include "libbpf.h"
#include "libbpf.h"
#include "perf_reader.h"
#include "perf_reader.h"
...
@@ -205,14 +206,16 @@ struct stacktrace_t {
...
@@ -205,14 +206,16 @@ struct stacktrace_t {
class
BPFStackTable
:
public
BPFTableBase
<
int
,
stacktrace_t
>
{
class
BPFStackTable
:
public
BPFTableBase
<
int
,
stacktrace_t
>
{
public:
public:
BPFStackTable
(
const
TableDesc
&
desc
)
BPFStackTable
(
const
TableDesc
&
desc
,
:
BPFTableBase
<
int
,
stacktrace_t
>
(
desc
)
{}
bool
use_debug_file
,
bool
check_debug_file_crc
);
~
BPFStackTable
();
~
BPFStackTable
();
std
::
vector
<
uintptr_t
>
get_stack_addr
(
int
stack_id
);
std
::
vector
<
uintptr_t
>
get_stack_addr
(
int
stack_id
);
std
::
vector
<
std
::
string
>
get_stack_symbol
(
int
stack_id
,
int
pid
);
std
::
vector
<
std
::
string
>
get_stack_symbol
(
int
stack_id
,
int
pid
);
private:
private:
bcc_symbol_option
symbol_option_
;
std
::
map
<
int
,
void
*>
pid_sym_
;
std
::
map
<
int
,
void
*>
pid_sym_
;
};
};
...
...
src/cc/bcc_syms.cc
View file @
5b40420a
...
@@ -32,10 +32,6 @@
...
@@ -32,10 +32,6 @@
#include "syms.h"
#include "syms.h"
#include "vendor/tinyformat.hpp"
#include "vendor/tinyformat.hpp"
#ifndef STT_GNU_IFUNC
#define STT_GNU_IFUNC 10
#endif
ino_t
ProcStat
::
getinode_
()
{
ino_t
ProcStat
::
getinode_
()
{
struct
stat
s
;
struct
stat
s
;
return
(
!
stat
(
procfs_
.
c_str
(),
&
s
))
?
s
.
st_ino
:
-
1
;
return
(
!
stat
(
procfs_
.
c_str
(),
&
s
))
?
s
.
st_ino
:
-
1
;
...
...
src/cc/bcc_syms.h
View file @
5b40420a
...
@@ -31,6 +31,9 @@ struct bcc_symbol {
...
@@ -31,6 +31,9 @@ struct bcc_symbol {
typedef
int
(
*
SYM_CB
)(
const
char
*
symname
,
uint64_t
addr
);
typedef
int
(
*
SYM_CB
)(
const
char
*
symname
,
uint64_t
addr
);
#ifndef STT_GNU_IFUNC
#define STT_GNU_IFUNC 10
#endif
static
const
uint32_t
BCC_SYM_ALL_TYPES
=
65535
;
static
const
uint32_t
BCC_SYM_ALL_TYPES
=
65535
;
struct
bcc_symbol_option
{
struct
bcc_symbol_option
{
int
use_debug_file
;
int
use_debug_file
;
...
...
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