-
Notifications
You must be signed in to change notification settings - Fork 2
/
prefix_path.patch
204 lines (180 loc) · 7.81 KB
/
prefix_path.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
diff -rN -u a/divine/cc/driver.cpp b/divine/cc/driver.cpp
--- a/divine/cc/driver.cpp 2019-11-01 15:57:40.145739566 +0100
+++ b/divine/cc/driver.cpp 2019-11-01 15:57:40.145739566 +0100
@@ -211,7 +211,7 @@
compiler.allowIncludePath( "." ); // TODO: necessary?
compiler.allowIncludePath( brq::dirname( lib ) );
- dirs.insert( dirs.begin(), "/dios/lib" );
+ dirs.insert( dirs.begin(), "/opt/divine/include/dios/lib" );
for ( auto p : dirs )
for ( auto suf : suffixes )
for ( auto pref : { "lib", "" } )
@@ -225,7 +225,7 @@
std::string Driver::find_object( std::string name )
{
- return brq::join_path( "/dios/lib", name + ".bc"s );
+ return brq::join_path( "/opt/divine/include/dios/lib", name + ".bc"s );
}
Driver::ModulePtr Driver::load_object( std::string path )
diff -rN -u a/dbg/info.cpp b/divine/dbg/info.cpp
--- a/divine/dbg/info.cpp 2019-11-01 15:57:40.145739566 +0100
+++ b/divine/dbg/info.cpp 2019-11-01 15:57:40.145739566 +0100
@@ -59,28 +59,28 @@
if ( comp & component::libc )
{
- if ( brq::starts_with( file, "/dios/libc/" ) ||
- brq::starts_with( file, "/dios/arch/" ) ||
- brq::starts_with( file, "/dios/include/sys/" ) )
+ if ( brq::starts_with( file, "/opt/divine/include/dios/libc/" ) ||
+ brq::starts_with( file, "/opt/divine/include/dios/arch/" ) ||
+ brq::starts_with( file, "/opt/divine/include/dios/include/sys/" ) )
return true;
- if ( brq::starts_with( file, "/dios/include/" ) && file.substr( 14 ).find( '/' ) == file.npos )
+ if ( brq::starts_with( file, "/opt/divine/include/dios/include/" ) && file.substr( 33 ).find( '/' ) == file.npos )
return true;
}
if ( comp & component::libcxx )
- if ( brq::starts_with( file, "/dios/libcxx" ) )
+ if ( brq::starts_with( file, "/opt/divine/include/dios/libcxx" ) )
return true;
if ( comp & component::librst )
- if ( brq::starts_with( file, "/dios/rst/" ) ||
- brq::starts_with( file, "/dios/include/rst/" ) )
+ if ( brq::starts_with( file, "/opt/divine/include/dios/rst/" ) ||
+ brq::starts_with( file, "/opt/divine/include/dios/include/rst/" ) )
return true;
if ( comp & component::dios )
- if ( brq::starts_with( file, "/dios/sys/" ) || brq::starts_with( file, "/dios/vfs/" ) )
+ if ( brq::starts_with( file, "/opt/divine/include/dios/sys/" ) || brq::starts_with( file, "/opt/divine/include/dios/vfs/" ) )
return true;
- if ( comp & component::program && !brq::starts_with( file, "/dios/" ) )
+ if ( comp & component::program && !brq::starts_with( file, "/opt/divine/include/dios/" ) )
return true;
return false;
diff -rN -u a/divine/rt/dios-cc.cpp b/divine/rt/dios-cc.cpp
--- a/divine/rt/dios-cc.cpp 2019-11-01 15:57:40.145739566 +0100
+++ b/divine/rt/dios-cc.cpp 2019-11-01 15:57:40.145739566 +0100
@@ -30,10 +30,10 @@
void add_dios_header_paths( std::vector< std::string >& paths )
{
paths.insert( paths.end(),
- { "-isystem", "/dios/libcxx/include"
- , "-isystem", "/dios/libcxxabi/include"
- , "-isystem", "/dios/libunwind/include"
- , "-isystem", "/dios/include" } );
+ { "-isystem", "/opt/divine/include/dios/libcxx/include"
+ , "-isystem", "/opt/divine/include/dios/libcxxabi/include"
+ , "-isystem", "/opt/divine/include/dios/libunwind/include"
+ , "-isystem", "/opt/divine/include/dios/include" } );
}
void add_dios_defines( std::vector< std::string >& flags )
diff -rN -u a/divine/rt/runtime.cpp b/divine/rt/runtime.cpp
--- a/divine/rt/runtime.cpp 2019-11-01 15:57:40.145739566 +0100
+++ b/divine/rt/runtime.cpp 2019-11-01 15:57:40.145739566 +0100
@@ -33,9 +33,9 @@
if ( n == "libcxx.a" ) n = "libc++.a";
if ( n == "libcxxabi.a" ) n = "libc++abi.a";
if ( brq::ends_with( n, ".bc" ) || brq::ends_with( n, ".a" ) )
- return "/dios/lib/" + n;
+ return "/opt/divine/include/dios/lib/" + n;
else
- return "/dios/" + n;
+ return "/opt/divine/include/dios/" + n;
}
void each( std::function< void( std::string, std::string_view ) > yield )
diff -rN -u a/tools/runtime-cc.cpp b/tools/runtime-cc.cpp
--- a/tools/runtime-cc.cpp 2019-11-01 15:57:40.145739566 +0100
+++ b/tools/runtime-cc.cpp 2019-11-01 15:57:40.145739566 +0100
@@ -48,6 +48,7 @@
n = p.substr( srcDir.size() );
if ( brq::starts_with( p, binDir ) )
n = p.substr( binDir.size() );
+ n = "/opt/divine/include" + n;
TRACE( "rewrite", p, "to", n );
return n;
} );
diff -rN -u a/test/lang-cpp/can-catch.cpp b/test/lang-cpp/can-catch.cpp
--- a/test/lang-cpp/can-catch.cpp
+++ b/test/lang-cpp/can-catch.cpp
@@ -1,5 +1,5 @@
/* TAGS: min c++ */
-/* CC_OPTS: -I/dios */
+/* CC_OPTS: -I/opt/divine/include/dios */
#include <libcxxabi/src/private_typeinfo.h>
#include <memory>
#include <exception>
diff -rN -u a/test/sim/call-dbg.sh b/test/sim/call-dbg.sh
--- a/test/sim/call-dbg.sh
+++ b/test/sim/call-dbg.sh
@@ -15,7 +15,7 @@
int main() {}
EOF
-sim -std=c++17 -C,-I/,-I$SRCDIR/bricks file.cpp <<EOF
+sim -std=c++17 -C,-I/opt/divine/include,-I$SRCDIR/bricks file.cpp <<EOF
+ ^# executing __boot at
> start
> call use_debug
# assert
diff -u a/dios/libc/_PDCLIB/assert.c b/dios/libc/_PDCLIB/assert.c
--- a/dios/libc/_PDCLIB/assert.c 2019-11-21 15:21:35.671767809 +0100
+++ b/dios/libc/_PDCLIB/assert.c 2019-11-21 15:21:35.675101152 +0100
@@ -19,7 +19,20 @@
{
int masked = __dios_mask( 1 );
char buffer[ 200 ];
- snprintf( buffer, 200, "%s:%u: %s: assertion '%s' failed", file, line, fun, stmt );
+
+ const char * prefix = "/opt/divine/include";
+ const int prefix_len = strlen( prefix );
+
+ int shift = 0;
+ const char * bgn = strstr( file, "/dios/" );
+ if ( bgn != NULL ) {
+ file = bgn;
+ strcpy( buffer, prefix );
+ shift += prefix_len;
+ }
+
+ snprintf( buffer + shift, 200 - shift,
+ "%s:%u: %s: assertion '%s' failed", file, line, fun, stmt );
__dios_fault( _VM_F_Assert, buffer );
__dios_mask( masked );
}
diff --git a/divine/dbg/info.cpp b/divine/dbg/info.cpp
index 98b884d6d..db894ae9f 100644
--- a/divine/dbg/info.cpp
+++ b/divine/dbg/info.cpp
@@ -18,19 +18,33 @@
#include <divine/dbg/info.hpp>
+DIVINE_RELAX_WARNINGS
+#include <llvm/Support/Path.h>
+DIVINE_UNRELAX_WARNINGS
+
namespace divine::dbg
{
std::pair< llvm::StringRef, int > fileline( const llvm::Instruction &insn )
{
auto loc = insn.getDebugLoc().get();
- if ( loc && loc->getNumOperands() )
- return std::make_pair( loc->getFilename(),
+ if ( loc && loc->getNumOperands() ) {
+ llvm::SmallString<PATH_MAX> path( loc->getDirectory() );
+ llvm::sys::path::append( path, loc->getFilename() );
+ return std::make_pair( brq::starts_with( loc->getFilename().str(),
+ "/opt/divine" )
+ ? loc->getFilename() : path.str(),
loc->getLine() );
+ }
auto prog = insn.getParent()->getParent()->getSubprogram();
- if ( prog )
- return std::make_pair( prog->getFilename(),
+ if ( prog ) {
+ llvm::SmallString<PATH_MAX> path( prog->getDirectory() );
+ llvm::sys::path::append( path, prog->getFilename() );
+ return std::make_pair( brq::starts_with( prog->getFilename().str(),
+ "/opt/divine" )
+ ? prog->getFilename() : path.str(),
prog->getScopeLine() );
+ }
return std::make_pair( "", 0 );
}