Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
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
bpftrace
Commits
2ee7b564
Commit
2ee7b564
authored
Jun 08, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop running and print out maps on ctrl-c
parent
9bedb630
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
10 deletions
+30
-10
src/attached_probe.cpp
src/attached_probe.cpp
+1
-0
src/attached_probe.h
src/attached_probe.h
+1
-1
src/bpftrace.cpp
src/bpftrace.cpp
+7
-7
src/bpftrace.h
src/bpftrace.h
+5
-1
src/main.cpp
src/main.cpp
+16
-1
No files found.
src/attached_probe.cpp
View file @
2ee7b564
#include <iostream>
#include <iostream>
#include <tuple>
#include <sys/utsname.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <unistd.h>
...
...
src/attached_probe.h
View file @
2ee7b564
#pragma once
#pragma once
#include "
bpftrace
.h"
#include "
types
.h"
namespace
bpftrace
{
namespace
bpftrace
{
...
...
src/bpftrace.cpp
View file @
2ee7b564
...
@@ -22,9 +22,8 @@ int BPFtrace::add_probe(ast::Probe &p)
...
@@ -22,9 +22,8 @@ int BPFtrace::add_probe(ast::Probe &p)
return
0
;
return
0
;
}
}
int
BPFtrace
::
run
()
int
BPFtrace
::
start
()
{
{
std
::
vector
<
std
::
unique_ptr
<
AttachedProbe
>>
attached_probes
;
for
(
Probe
&
probe
:
probes_
)
for
(
Probe
&
probe
:
probes_
)
{
{
auto
func
=
sections_
.
find
(
probe
.
name
);
auto
func
=
sections_
.
find
(
probe
.
name
);
...
@@ -35,7 +34,7 @@ int BPFtrace::run()
...
@@ -35,7 +34,7 @@ int BPFtrace::run()
}
}
try
try
{
{
attached_probes
.
push_back
(
std
::
make_unique
<
AttachedProbe
>
(
probe
,
func
->
second
));
attached_probes
_
.
push_back
(
std
::
make_unique
<
AttachedProbe
>
(
probe
,
func
->
second
));
}
}
catch
(
std
::
runtime_error
e
)
catch
(
std
::
runtime_error
e
)
{
{
...
@@ -43,13 +42,14 @@ int BPFtrace::run()
...
@@ -43,13 +42,14 @@ int BPFtrace::run()
return
-
1
;
return
-
1
;
}
}
}
}
// TODO wait here while script is running
getchar
();
return
0
;
return
0
;
}
}
void
BPFtrace
::
stop
()
{
attached_probes_
.
clear
();
}
int
BPFtrace
::
print_maps
()
int
BPFtrace
::
print_maps
()
{
{
for
(
auto
&
mapmap
:
maps_
)
for
(
auto
&
mapmap
:
maps_
)
...
...
src/bpftrace.h
View file @
2ee7b564
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <vector>
#include <vector>
#include "ast.h"
#include "ast.h"
#include "attached_probe.h"
#include "map.h"
#include "map.h"
#include "types.h"
#include "types.h"
...
@@ -15,7 +16,8 @@ class BPFtrace
...
@@ -15,7 +16,8 @@ class BPFtrace
public:
public:
virtual
~
BPFtrace
()
{
}
virtual
~
BPFtrace
()
{
}
virtual
int
add_probe
(
ast
::
Probe
&
p
);
virtual
int
add_probe
(
ast
::
Probe
&
p
);
int
run
();
int
start
();
void
stop
();
int
print_maps
();
int
print_maps
();
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
Map
>>
maps_
;
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
Map
>>
maps_
;
...
@@ -23,6 +25,8 @@ public:
...
@@ -23,6 +25,8 @@ public:
private:
private:
std
::
vector
<
Probe
>
probes_
;
std
::
vector
<
Probe
>
probes_
;
std
::
vector
<
std
::
unique_ptr
<
AttachedProbe
>>
attached_probes_
;
int
print_map
(
Map
&
map
);
int
print_map
(
Map
&
map
);
int
print_map_quantize
(
Map
&
map
);
int
print_map_quantize
(
Map
&
map
);
int
print_quantize
(
std
::
vector
<
uint64_t
>
values
);
int
print_quantize
(
std
::
vector
<
uint64_t
>
values
);
...
...
src/main.cpp
View file @
2ee7b564
#include <iostream>
#include <iostream>
#include <signal.h>
#include <unistd.h>
#include <unistd.h>
#include "bpftrace.h"
#include "bpftrace.h"
#include "codegen_llvm.h"
#include "codegen_llvm.h"
#include "driver.h"
#include "driver.h"
...
@@ -89,10 +91,23 @@ int main(int argc, char *argv[])
...
@@ -89,10 +91,23 @@ int main(int argc, char *argv[])
if
(
debug
)
if
(
debug
)
return
0
;
return
0
;
err
=
bpftrace
.
run
();
// Empty signal handler just to break out of the sleep below
struct
sigaction
act
;
act
.
sa_handler
=
[](
int
)
{
};
sigaction
(
SIGINT
,
&
act
,
NULL
);
std
::
cout
<<
"Running... press Ctrl-C to stop"
<<
std
::
endl
;
err
=
bpftrace
.
start
();
if
(
err
)
if
(
err
)
return
err
;
return
err
;
sleep
(
99999999
);
bpftrace
.
stop
();
std
::
cout
<<
"
\n\n
"
;
err
=
bpftrace
.
print_maps
();
err
=
bpftrace
.
print_maps
();
if
(
err
)
if
(
err
)
return
err
;
return
err
;
...
...
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