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
796f9c9a
Commit
796f9c9a
authored
Feb 05, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code out of parser driver back into main.cpp
parent
918e4c82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
38 deletions
+23
-38
src/driver.cpp
src/driver.cpp
+0
-21
src/driver.h
src/driver.h
+0
-5
src/main.cpp
src/main.cpp
+23
-12
No files found.
src/driver.cpp
View file @
796f9c9a
#include <iostream>
#include "codegen_llvm.h"
#include "driver.h"
#include "printer.h"
#include "semantic_analyser.h"
namespace
ebpf
{
namespace
bpftrace
{
...
...
@@ -22,23 +19,5 @@ int Driver::parse(const std::string &f)
return
parser_
.
parse
();
}
void
Driver
::
dump_ast
(
std
::
ostream
&
out
)
{
ast
::
Printer
p
=
ebpf
::
bpftrace
::
ast
::
Printer
(
out
);
root_
->
accept
(
p
);
}
int
Driver
::
analyse
()
{
ast
::
SemanticAnalyser
semantics
(
root_
,
bpftrace_
);
return
semantics
.
analyse
();
}
int
Driver
::
compile
()
{
ast
::
CodegenLLVM
llvm
(
root_
,
bpftrace_
);
return
llvm
.
compile
();
}
}
// namespace bpftrace
}
// namespace ebpf
src/driver.h
View file @
796f9c9a
#pragma once
#include "ast.h"
#include "bpftrace.h"
#include "parser.tab.hh"
#define YY_DECL ebpf::bpftrace::Parser::symbol_type yylex(ebpf::bpftrace::Driver &driver)
...
...
@@ -18,9 +17,6 @@ public:
int
parse
();
int
parse
(
const
std
::
string
&
f
);
void
dump_ast
(
std
::
ostream
&
out
);
int
analyse
();
int
compile
();
void
error
(
const
location
&
l
,
const
std
::
string
&
m
)
{
...
...
@@ -36,7 +32,6 @@ public:
private:
Parser
parser_
;
BPFtrace
bpftrace_
;
};
}
// namespace bpftrace
...
...
src/main.cpp
View file @
796f9c9a
#include <iostream>
#include "bpftrace.h"
#include "codegen_llvm.h"
#include "driver.h"
#include "printer.h"
#include "semantic_analyser.h"
using
namespace
ebpf
::
bpftrace
;
int
main
(
int
argc
,
char
*
argv
[])
{
int
result
;
ebpf
::
bpftrace
::
Driver
driver
;
if
(
argc
==
1
)
{
Driver
driver
;
if
(
argc
==
1
)
result
=
driver
.
parse
();
}
else
{
else
result
=
driver
.
parse
(
argv
[
1
]);
}
if
(
result
)
{
if
(
result
)
return
result
;
}
driver
.
dump_ast
(
std
::
cout
);
BPFtrace
bpftrace
;
ast
::
Printer
p
=
ebpf
::
bpftrace
::
ast
::
Printer
(
std
::
cout
);
driver
.
root_
->
accept
(
p
);
ast
::
SemanticAnalyser
semantics
(
driver
.
root_
,
bpftrace
);
result
=
semantics
.
analyse
();
if
(
result
)
return
result
;
result
=
driver
.
analyse
();
if
(
result
)
{
ast
::
CodegenLLVM
llvm
(
driver
.
root_
,
bpftrace
);
result
=
llvm
.
compile
();
if
(
result
)
return
result
;
}
driver
.
compile
();
bpftrace
.
attach_probes
();
return
0
;
}
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