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
96c1b8e0
Commit
96c1b8e0
authored
Jun 27, 2017
by
Vicent Marti
Committed by
Brenden Blanco
Jun 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usdt: Use ProcMountNS
parent
8600ffcb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
src/cc/usdt.cc
src/cc/usdt.cc
+11
-5
src/cc/usdt.h
src/cc/usdt.h
+4
-1
No files found.
src/cc/usdt.cc
View file @
96c1b8e0
...
...
@@ -39,16 +39,19 @@ Location::Location(uint64_t addr, const char *arg_fmt) : address_(addr) {
}
Probe
::
Probe
(
const
char
*
bin_path
,
const
char
*
provider
,
const
char
*
name
,
uint64_t
semaphore
,
const
optional
<
int
>
&
pid
)
uint64_t
semaphore
,
const
optional
<
int
>
&
pid
,
ProcMountNS
*
ns
)
:
bin_path_
(
bin_path
),
provider_
(
provider
),
name_
(
name
),
semaphore_
(
semaphore
),
pid_
(
pid
)
{}
pid_
(
pid
),
mount_ns_
(
ns
)
{}
bool
Probe
::
in_shared_object
()
{
if
(
!
in_shared_object_
)
if
(
!
in_shared_object_
)
{
ProcMountNSGuard
g
(
mount_ns_
);
in_shared_object_
=
bcc_elf_is_shared_obj
(
bin_path_
.
c_str
());
}
return
in_shared_object_
.
value
();
}
...
...
@@ -205,6 +208,7 @@ int Context::_each_module(const char *modpath, uint64_t, uint64_t, bool, void *p
// executable region. We are going to parse the ELF on disk anyway, so we
// don't need these duplicates.
if
(
ctx
->
modules_
.
insert
(
modpath
).
second
/*inserted new?*/
)
{
ProcMountNSGuard
g
(
ctx
->
mount_ns_instance_
.
get
());
bcc_elf_foreach_usdt
(
modpath
,
_each_probe
,
p
);
}
return
0
;
...
...
@@ -219,7 +223,8 @@ void Context::add_probe(const char *binpath, const struct bcc_elf_usdt *probe) {
}
probes_
.
emplace_back
(
new
Probe
(
binpath
,
probe
->
provider
,
probe
->
name
,
probe
->
semaphore
,
pid_
));
new
Probe
(
binpath
,
probe
->
provider
,
probe
->
name
,
probe
->
semaphore
,
pid_
,
mount_ns_instance_
.
get
()));
probes_
.
back
()
->
add_location
(
probe
->
pc
,
probe
->
arg_fmt
);
}
...
...
@@ -296,7 +301,8 @@ Context::Context(const std::string &bin_path) : loaded_(false) {
}
}
Context
::
Context
(
int
pid
)
:
pid_
(
pid
),
pid_stat_
(
pid
),
loaded_
(
false
)
{
Context
::
Context
(
int
pid
)
:
pid_
(
pid
),
pid_stat_
(
pid
),
mount_ns_instance_
(
new
ProcMountNS
(
pid
)),
loaded_
(
false
)
{
if
(
bcc_procutils_each_module
(
pid
,
_each_module
,
this
)
==
0
)
loaded_
=
true
;
}
...
...
src/cc/usdt.h
View file @
96c1b8e0
...
...
@@ -20,6 +20,7 @@
#include <unordered_map>
#include <vector>
#include "ns_guard.h"
#include "syms.h"
#include "vendor/optional.hpp"
...
...
@@ -149,6 +150,7 @@ class Probe {
std
::
vector
<
Location
>
locations_
;
optional
<
int
>
pid_
;
ProcMountNS
*
mount_ns_
;
optional
<
bool
>
in_shared_object_
;
optional
<
std
::
string
>
attached_to_
;
...
...
@@ -163,7 +165,7 @@ class Probe {
public:
Probe
(
const
char
*
bin_path
,
const
char
*
provider
,
const
char
*
name
,
uint64_t
semaphore
,
const
optional
<
int
>
&
pid
);
uint64_t
semaphore
,
const
optional
<
int
>
&
pid
,
ProcMountNS
*
ns
);
size_t
num_locations
()
const
{
return
locations_
.
size
();
}
size_t
num_arguments
()
const
{
return
locations_
.
front
().
arguments_
.
size
();
}
...
...
@@ -195,6 +197,7 @@ class Context {
optional
<
int
>
pid_
;
optional
<
ProcStat
>
pid_stat_
;
std
::
unique_ptr
<
ProcMountNS
>
mount_ns_instance_
;
bool
loaded_
;
static
void
_each_probe
(
const
char
*
binpath
,
const
struct
bcc_elf_usdt
*
probe
,
...
...
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