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
c6d04218
Commit
c6d04218
authored
Dec 10, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Differentiate between system headers and relative paths
parent
c2c9ade8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
9 deletions
+14
-9
src/ast/ast.h
src/ast/ast.h
+3
-1
src/ast/printer.cpp
src/ast/printer.cpp
+4
-1
src/parser.yy
src/parser.yy
+2
-2
tests/parser.cpp
tests/parser.cpp
+5
-5
No files found.
src/ast/ast.h
View file @
c6d04218
...
...
@@ -178,8 +178,10 @@ using ProbeList = std::vector<Probe *>;
class
Include
:
public
Node
{
public:
explicit
Include
(
const
std
::
string
&
file
)
:
file
(
file
)
{
}
explicit
Include
(
const
std
::
string
&
file
,
bool
system_header
)
:
file
(
file
),
system_header
(
system_header
)
{
}
std
::
string
file
;
bool
system_header
;
void
accept
(
Visitor
&
v
)
override
;
};
...
...
src/ast/printer.cpp
View file @
c6d04218
...
...
@@ -148,7 +148,10 @@ void Printer::visit(Probe &probe)
void
Printer
::
visit
(
Include
&
include
)
{
std
::
string
indent
(
depth_
,
' '
);
out_
<<
indent
<<
"#include "
<<
include
.
file
<<
std
::
endl
;
if
(
include
.
system_header
)
out_
<<
indent
<<
"#include <"
<<
include
.
file
<<
">"
<<
std
::
endl
;
else
out_
<<
indent
<<
"#include
\"
"
<<
include
.
file
<<
"
\"
"
<<
std
::
endl
;
}
void
Printer
::
visit
(
Program
&
program
)
...
...
src/parser.yy
View file @
c6d04218
...
...
@@ -115,8 +115,8 @@ includes : includes include { $$ = $1; $1->push_back($2); }
| { $$ = new ast::IncludeList; }
;
include : INCLUDE STRING { $$ = new ast::Include($2); }
| INCLUDE HEADER { $$ = new ast::Include($2.substr(1, $2.size()-2)); }
include : INCLUDE STRING { $$ = new ast::Include($2
, false
); }
| INCLUDE HEADER { $$ = new ast::Include($2.substr(1, $2.size()-2)
, true
); }
;
probes : probes probe { $$ = $1; $1->push_back($2); }
...
...
tests/parser.cpp
View file @
c6d04218
...
...
@@ -304,7 +304,7 @@ TEST(Parser, include)
{
test
(
"#include <stdio.h> kprobe:sys_read { @x = 1 }"
,
"Program
\n
"
" #include
stdio.h
\n
"
" #include
<stdio.h>
\n
"
" kprobe:sys_read
\n
"
" =
\n
"
" map: @x
\n
"
...
...
@@ -315,7 +315,7 @@ TEST(Parser, include_quote)
{
test
(
"#include
\"
stdio.h
\"
kprobe:sys_read { @x = 1 }"
,
"Program
\n
"
" #include
stdio.h
\n
"
" #include
\"
stdio.h
\"
\n
"
" kprobe:sys_read
\n
"
" =
\n
"
" map: @x
\n
"
...
...
@@ -326,9 +326,9 @@ TEST(Parser, include_multiple)
{
test
(
"#include <stdio.h> #include
\"
blah
\"
#include <foo.h> kprobe:sys_read { @x = 1 }"
,
"Program
\n
"
" #include
stdio.h
\n
"
" #include
blah
\n
"
" #include
foo.h
\n
"
" #include
<stdio.h>
\n
"
" #include
\"
blah
\"
\n
"
" #include
<foo.h>
\n
"
" kprobe:sys_read
\n
"
" =
\n
"
" map: @x
\n
"
...
...
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