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
5703ccc1
Commit
5703ccc1
authored
May 23, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support symbol option in C++ API stack table
parent
4b3d2b08
Changes
6
Hide 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 @
5703ccc1
...
...
@@ -504,11 +504,13 @@ BPFProgTable BPF::get_prog_table(const std::string& name) {
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
;
if
(
bpf_module_
->
table_storage
().
Find
(
Path
({
bpf_module_
->
id
(),
name
}),
it
))
return
BPFStackTable
(
it
->
second
);
return
BPFStackTable
({});
return
BPFStackTable
(
it
->
second
,
use_debug_file
,
check_debug_file_crc
);
return
BPFStackTable
({}
,
use_debug_file
,
check_debug_file_crc
);
}
std
::
string
BPF
::
get_uprobe_event
(
const
std
::
string
&
binary_path
,
...
...
src/cc/BPF.h
View file @
5703ccc1
...
...
@@ -115,7 +115,9 @@ public:
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
,
perf_reader_raw_cb
cb
,
...
...
src/cc/BPFTable.cc
View file @
5703ccc1
...
...
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <linux/elf.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <cerrno>
...
...
@@ -86,6 +87,17 @@ StatusTuple BPFTable::remove_value(const std::string& key_str) {
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
()
{
for
(
auto
it
:
pid_sym_
)
bcc_free_symcache
(
it
.
second
,
it
.
first
);
...
...
@@ -110,7 +122,7 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
if
(
pid
<
0
)
pid
=
-
1
;
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
];
bcc_symbol
symbol
;
...
...
src/cc/BPFTable.h
View file @
5703ccc1
...
...
@@ -26,6 +26,7 @@
#include <vector>
#include "bcc_exception.h"
#include "bcc_syms.h"
#include "bpf_module.h"
#include "libbpf.h"
#include "perf_reader.h"
...
...
@@ -205,14 +206,16 @@ struct stacktrace_t {
class
BPFStackTable
:
public
BPFTableBase
<
int
,
stacktrace_t
>
{
public:
BPFStackTable
(
const
TableDesc
&
desc
)
:
BPFTableBase
<
int
,
stacktrace_t
>
(
desc
)
{}
BPFStackTable
(
const
TableDesc
&
desc
,
bool
use_debug_file
,
bool
check_debug_file_crc
);
~
BPFStackTable
();
std
::
vector
<
uintptr_t
>
get_stack_addr
(
int
stack_id
);
std
::
vector
<
std
::
string
>
get_stack_symbol
(
int
stack_id
,
int
pid
);
private:
bcc_symbol_option
symbol_option_
;
std
::
map
<
int
,
void
*>
pid_sym_
;
};
...
...
src/cc/bcc_syms.cc
View file @
5703ccc1
...
...
@@ -32,10 +32,6 @@
#include "syms.h"
#include "vendor/tinyformat.hpp"
#ifndef STT_GNU_IFUNC
#define STT_GNU_IFUNC 10
#endif
ino_t
ProcStat
::
getinode_
()
{
struct
stat
s
;
return
(
!
stat
(
procfs_
.
c_str
(),
&
s
))
?
s
.
st_ino
:
-
1
;
...
...
src/cc/bcc_syms.h
View file @
5703ccc1
...
...
@@ -31,6 +31,9 @@ struct bcc_symbol {
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
;
struct
bcc_symbol_option
{
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