1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <stdlib.h>
18 
19 #include <memory>
20 #include <string>
21 
22 #include <gtest/gtest.h>
23 #include <base/file.h>
24 
25 #include "utility.h"
26 
27 #include "BacktraceMock.h"
28 #include "elf_fake.h"
29 #include "host_signal_fixup.h"
30 #include "log_fake.h"
31 #include "ptrace_fake.h"
32 
33 // In order to test this code, we need to include the tombstone.cpp code.
34 // Including it, also allows us to override the ptrace function.
35 #define ptrace ptrace_fake
36 
37 #include "tombstone.cpp"
38 
dump_registers(log_t *,pid_t)39 void dump_registers(log_t*, pid_t) {
40 }
41 
dump_memory_and_code(log_t *,Backtrace *)42 void dump_memory_and_code(log_t*, Backtrace*) {
43 }
44 
dump_backtrace_to_log(Backtrace *,log_t *,char const *)45 void dump_backtrace_to_log(Backtrace*, log_t*, char const*) {
46 }
47 
48 class DumpMapsTest : public ::testing::Test {
49  protected:
SetUp()50   virtual void SetUp() {
51     map_mock_.reset(new BacktraceMapMock());
52     backtrace_mock_.reset(new BacktraceMock(map_mock_.get()));
53 
54     char tmp_file[256];
55     const char data_template[] = "/data/local/tmp/debuggerd_memory_testXXXXXX";
56     memcpy(tmp_file, data_template, sizeof(data_template));
57     int tombstone_fd = mkstemp(tmp_file);
58     if (tombstone_fd == -1) {
59       const char tmp_template[] = "/tmp/debuggerd_memory_testXXXXXX";
60       memcpy(tmp_file, tmp_template, sizeof(tmp_template));
61       tombstone_fd = mkstemp(tmp_file);
62       if (tombstone_fd == -1) {
63         abort();
64       }
65     }
66     if (unlink(tmp_file) == -1) {
67       abort();
68     }
69 
70     log_.tfd = tombstone_fd;
71     log_.amfd = -1;
72     log_.crashed_tid = 12;
73     log_.current_tid = 12;
74     log_.should_retrieve_logcat = false;
75 
76     resetLogs();
77     elf_set_fake_build_id("");
78     siginfo_t si;
79     si.si_signo = SIGPIPE;
80     ptrace_set_fake_getsiginfo(si);
81   }
82 
TearDown()83   virtual void TearDown() {
84     if (log_.tfd >= 0) {
85       close(log_.tfd);
86     }
87   }
88 
89   std::unique_ptr<BacktraceMapMock> map_mock_;
90   std::unique_ptr<BacktraceMock> backtrace_mock_;
91 
92   log_t log_;
93 };
94 
TEST_F(DumpMapsTest,single_map)95 TEST_F(DumpMapsTest, single_map) {
96   backtrace_map_t map;
97 #if defined(__LP64__)
98   map.start = 0x123456789abcd000UL;
99   map.end = 0x123456789abdf000UL;
100 #else
101   map.start = 0x1234000;
102   map.end = 0x1235000;
103 #endif
104   map_mock_->AddMap(map);
105 
106   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
107 
108   std::string tombstone_contents;
109   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
110   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
111   const char* expected_dump = \
112 "\nmemory map:\n"
113 #if defined(__LP64__)
114 "    12345678'9abcd000-12345678'9abdefff ---         0     12000\n";
115 #else
116 "    01234000-01234fff ---         0      1000\n";
117 #endif
118   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
119 
120   // Verify that the log buf is empty, and no error messages.
121   ASSERT_STREQ("", getFakeLogBuf().c_str());
122   ASSERT_STREQ("", getFakeLogPrint().c_str());
123 }
124 
TEST_F(DumpMapsTest,single_map_elf_build_id)125 TEST_F(DumpMapsTest, single_map_elf_build_id) {
126   backtrace_map_t map;
127 #if defined(__LP64__)
128   map.start = 0x123456789abcd000UL;
129   map.end = 0x123456789abdf000UL;
130 #else
131   map.start = 0x1234000;
132   map.end = 0x1235000;
133 #endif
134   map.flags = PROT_READ;
135   map.name = "/system/lib/libfake.so";
136   map_mock_->AddMap(map);
137 
138   elf_set_fake_build_id("abcdef1234567890abcdef1234567890");
139   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
140 
141   std::string tombstone_contents;
142   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
143   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
144   const char* expected_dump = \
145 "\nmemory map:\n"
146 #if defined(__LP64__)
147 "    12345678'9abcd000-12345678'9abdefff r--         0     12000  /system/lib/libfake.so (BuildId: abcdef1234567890abcdef1234567890)\n";
148 #else
149 "    01234000-01234fff r--         0      1000  /system/lib/libfake.so (BuildId: abcdef1234567890abcdef1234567890)\n";
150 #endif
151   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
152 
153   // Verify that the log buf is empty, and no error messages.
154   ASSERT_STREQ("", getFakeLogBuf().c_str());
155   ASSERT_STREQ("", getFakeLogPrint().c_str());
156 }
157 
158 // Even though build id is present, it should not be printed in either of
159 // these cases.
TEST_F(DumpMapsTest,single_map_no_build_id)160 TEST_F(DumpMapsTest, single_map_no_build_id) {
161   backtrace_map_t map;
162 #if defined(__LP64__)
163   map.start = 0x123456789abcd000UL;
164   map.end = 0x123456789abdf000UL;
165 #else
166   map.start = 0x1234000;
167   map.end = 0x1235000;
168 #endif
169   map.flags = PROT_WRITE;
170   map_mock_->AddMap(map);
171 
172   map.name = "/system/lib/libfake.so";
173   map_mock_->AddMap(map);
174 
175   elf_set_fake_build_id("abcdef1234567890abcdef1234567890");
176   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
177 
178   std::string tombstone_contents;
179   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
180   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
181   const char* expected_dump = \
182 "\nmemory map:\n"
183 #if defined(__LP64__)
184 "    12345678'9abcd000-12345678'9abdefff -w-         0     12000\n"
185 "    12345678'9abcd000-12345678'9abdefff -w-         0     12000  /system/lib/libfake.so\n";
186 #else
187 "    01234000-01234fff -w-         0      1000\n"
188 "    01234000-01234fff -w-         0      1000  /system/lib/libfake.so\n";
189 #endif
190   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
191 
192   // Verify that the log buf is empty, and no error messages.
193   ASSERT_STREQ("", getFakeLogBuf().c_str());
194   ASSERT_STREQ("", getFakeLogPrint().c_str());
195 }
196 
TEST_F(DumpMapsTest,multiple_maps)197 TEST_F(DumpMapsTest, multiple_maps) {
198   backtrace_map_t map;
199 
200   map.start = 0xa234000;
201   map.end = 0xa235000;
202   map_mock_->AddMap(map);
203 
204   map.start = 0xa334000;
205   map.end = 0xa335000;
206   map.offset = 0xf000;
207   map.flags = PROT_READ;
208   map_mock_->AddMap(map);
209 
210   map.start = 0xa434000;
211   map.end = 0xa435000;
212   map.offset = 0x1000;
213   map.load_base = 0xd000;
214   map.flags = PROT_WRITE;
215   map_mock_->AddMap(map);
216 
217   map.start = 0xa534000;
218   map.end = 0xa535000;
219   map.offset = 0x3000;
220   map.load_base = 0x2000;
221   map.flags = PROT_EXEC;
222   map_mock_->AddMap(map);
223 
224   map.start = 0xa634000;
225   map.end = 0xa635000;
226   map.offset = 0;
227   map.load_base = 0;
228   map.flags = PROT_READ | PROT_WRITE | PROT_EXEC;
229   map.name = "/system/lib/fake.so";
230   map_mock_->AddMap(map);
231 
232   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
233 
234   std::string tombstone_contents;
235   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
236   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
237   const char* expected_dump = \
238 "\nmemory map:\n"
239 #if defined(__LP64__)
240 "    00000000'0a234000-00000000'0a234fff ---         0      1000\n"
241 "    00000000'0a334000-00000000'0a334fff r--      f000      1000\n"
242 "    00000000'0a434000-00000000'0a434fff -w-      1000      1000  (load base 0xd000)\n"
243 "    00000000'0a534000-00000000'0a534fff --x      3000      1000  (load base 0x2000)\n"
244 "    00000000'0a634000-00000000'0a634fff rwx         0      1000  /system/lib/fake.so\n";
245 #else
246 "    0a234000-0a234fff ---         0      1000\n"
247 "    0a334000-0a334fff r--      f000      1000\n"
248 "    0a434000-0a434fff -w-      1000      1000  (load base 0xd000)\n"
249 "    0a534000-0a534fff --x      3000      1000  (load base 0x2000)\n"
250 "    0a634000-0a634fff rwx         0      1000  /system/lib/fake.so\n";
251 #endif
252   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
253 
254   // Verify that the log buf is empty, and no error messages.
255   ASSERT_STREQ("", getFakeLogBuf().c_str());
256   ASSERT_STREQ("", getFakeLogPrint().c_str());
257 }
258 
TEST_F(DumpMapsTest,multiple_maps_fault_address_before)259 TEST_F(DumpMapsTest, multiple_maps_fault_address_before) {
260   backtrace_map_t map;
261 
262   map.start = 0xa434000;
263   map.end = 0xa435000;
264   map.offset = 0x1000;
265   map.load_base = 0xd000;
266   map.flags = PROT_WRITE;
267   map_mock_->AddMap(map);
268 
269   map.start = 0xa534000;
270   map.end = 0xa535000;
271   map.offset = 0x3000;
272   map.load_base = 0x2000;
273   map.flags = PROT_EXEC;
274   map_mock_->AddMap(map);
275 
276   map.start = 0xa634000;
277   map.end = 0xa635000;
278   map.offset = 0;
279   map.load_base = 0;
280   map.flags = PROT_READ | PROT_WRITE | PROT_EXEC;
281   map.name = "/system/lib/fake.so";
282   map_mock_->AddMap(map);
283 
284   siginfo_t si;
285   si.si_signo = SIGBUS;
286   si.si_addr = reinterpret_cast<void*>(0x1000);
287   ptrace_set_fake_getsiginfo(si);
288   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
289 
290   std::string tombstone_contents;
291   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
292   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
293   const char* expected_dump = \
294 "\nmemory map: (fault address prefixed with --->)\n"
295 #if defined(__LP64__)
296 "--->Fault address falls at 00000000'00001000 before any mapped regions\n"
297 "    00000000'0a434000-00000000'0a434fff -w-      1000      1000  (load base 0xd000)\n"
298 "    00000000'0a534000-00000000'0a534fff --x      3000      1000  (load base 0x2000)\n"
299 "    00000000'0a634000-00000000'0a634fff rwx         0      1000  /system/lib/fake.so\n";
300 #else
301 "--->Fault address falls at 00001000 before any mapped regions\n"
302 "    0a434000-0a434fff -w-      1000      1000  (load base 0xd000)\n"
303 "    0a534000-0a534fff --x      3000      1000  (load base 0x2000)\n"
304 "    0a634000-0a634fff rwx         0      1000  /system/lib/fake.so\n";
305 #endif
306   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
307 
308   // Verify that the log buf is empty, and no error messages.
309   ASSERT_STREQ("", getFakeLogBuf().c_str());
310   ASSERT_STREQ("", getFakeLogPrint().c_str());
311 }
312 
TEST_F(DumpMapsTest,multiple_maps_fault_address_between)313 TEST_F(DumpMapsTest, multiple_maps_fault_address_between) {
314   backtrace_map_t map;
315 
316   map.start = 0xa434000;
317   map.end = 0xa435000;
318   map.offset = 0x1000;
319   map.load_base = 0xd000;
320   map.flags = PROT_WRITE;
321   map_mock_->AddMap(map);
322 
323   map.start = 0xa534000;
324   map.end = 0xa535000;
325   map.offset = 0x3000;
326   map.load_base = 0x2000;
327   map.flags = PROT_EXEC;
328   map_mock_->AddMap(map);
329 
330   map.start = 0xa634000;
331   map.end = 0xa635000;
332   map.offset = 0;
333   map.load_base = 0;
334   map.flags = PROT_READ | PROT_WRITE | PROT_EXEC;
335   map.name = "/system/lib/fake.so";
336   map_mock_->AddMap(map);
337 
338   siginfo_t si;
339   si.si_signo = SIGBUS;
340   si.si_addr = reinterpret_cast<void*>(0xa533000);
341   ptrace_set_fake_getsiginfo(si);
342   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
343 
344   std::string tombstone_contents;
345   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
346   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
347   const char* expected_dump = \
348 "\nmemory map: (fault address prefixed with --->)\n"
349 #if defined(__LP64__)
350 "    00000000'0a434000-00000000'0a434fff -w-      1000      1000  (load base 0xd000)\n"
351 "--->Fault address falls at 00000000'0a533000 between mapped regions\n"
352 "    00000000'0a534000-00000000'0a534fff --x      3000      1000  (load base 0x2000)\n"
353 "    00000000'0a634000-00000000'0a634fff rwx         0      1000  /system/lib/fake.so\n";
354 #else
355 "    0a434000-0a434fff -w-      1000      1000  (load base 0xd000)\n"
356 "--->Fault address falls at 0a533000 between mapped regions\n"
357 "    0a534000-0a534fff --x      3000      1000  (load base 0x2000)\n"
358 "    0a634000-0a634fff rwx         0      1000  /system/lib/fake.so\n";
359 #endif
360   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
361 
362   // Verify that the log buf is empty, and no error messages.
363   ASSERT_STREQ("", getFakeLogBuf().c_str());
364   ASSERT_STREQ("", getFakeLogPrint().c_str());
365 }
366 
TEST_F(DumpMapsTest,multiple_maps_fault_address_in_map)367 TEST_F(DumpMapsTest, multiple_maps_fault_address_in_map) {
368   backtrace_map_t map;
369 
370   map.start = 0xa434000;
371   map.end = 0xa435000;
372   map.offset = 0x1000;
373   map.load_base = 0xd000;
374   map.flags = PROT_WRITE;
375   map_mock_->AddMap(map);
376 
377   map.start = 0xa534000;
378   map.end = 0xa535000;
379   map.offset = 0x3000;
380   map.load_base = 0x2000;
381   map.flags = PROT_EXEC;
382   map_mock_->AddMap(map);
383 
384   map.start = 0xa634000;
385   map.end = 0xa635000;
386   map.offset = 0;
387   map.load_base = 0;
388   map.flags = PROT_READ | PROT_WRITE | PROT_EXEC;
389   map.name = "/system/lib/fake.so";
390   map_mock_->AddMap(map);
391 
392   siginfo_t si;
393   si.si_signo = SIGBUS;
394   si.si_addr = reinterpret_cast<void*>(0xa534040);
395   ptrace_set_fake_getsiginfo(si);
396   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
397 
398   std::string tombstone_contents;
399   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
400   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
401   const char* expected_dump = \
402 "\nmemory map: (fault address prefixed with --->)\n"
403 #if defined(__LP64__)
404 "    00000000'0a434000-00000000'0a434fff -w-      1000      1000  (load base 0xd000)\n"
405 "--->00000000'0a534000-00000000'0a534fff --x      3000      1000  (load base 0x2000)\n"
406 "    00000000'0a634000-00000000'0a634fff rwx         0      1000  /system/lib/fake.so\n";
407 #else
408 "    0a434000-0a434fff -w-      1000      1000  (load base 0xd000)\n"
409 "--->0a534000-0a534fff --x      3000      1000  (load base 0x2000)\n"
410 "    0a634000-0a634fff rwx         0      1000  /system/lib/fake.so\n";
411 #endif
412   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
413 
414   // Verify that the log buf is empty, and no error messages.
415   ASSERT_STREQ("", getFakeLogBuf().c_str());
416   ASSERT_STREQ("", getFakeLogPrint().c_str());
417 }
418 
TEST_F(DumpMapsTest,multiple_maps_fault_address_after)419 TEST_F(DumpMapsTest, multiple_maps_fault_address_after) {
420   backtrace_map_t map;
421 
422   map.start = 0xa434000;
423   map.end = 0xa435000;
424   map.offset = 0x1000;
425   map.load_base = 0xd000;
426   map.flags = PROT_WRITE;
427   map_mock_->AddMap(map);
428 
429   map.start = 0xa534000;
430   map.end = 0xa535000;
431   map.offset = 0x3000;
432   map.load_base = 0x2000;
433   map.flags = PROT_EXEC;
434   map_mock_->AddMap(map);
435 
436   map.start = 0xa634000;
437   map.end = 0xa635000;
438   map.offset = 0;
439   map.load_base = 0;
440   map.flags = PROT_READ | PROT_WRITE | PROT_EXEC;
441   map.name = "/system/lib/fake.so";
442   map_mock_->AddMap(map);
443 
444   siginfo_t si;
445   si.si_signo = SIGBUS;
446 #if defined(__LP64__)
447   si.si_addr = reinterpret_cast<void*>(0x12345a534040UL);
448 #else
449   si.si_addr = reinterpret_cast<void*>(0xf534040UL);
450 #endif
451   ptrace_set_fake_getsiginfo(si);
452   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
453 
454   std::string tombstone_contents;
455   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
456   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
457   const char* expected_dump = \
458 "\nmemory map: (fault address prefixed with --->)\n"
459 #if defined(__LP64__)
460 "    00000000'0a434000-00000000'0a434fff -w-      1000      1000  (load base 0xd000)\n"
461 "    00000000'0a534000-00000000'0a534fff --x      3000      1000  (load base 0x2000)\n"
462 "    00000000'0a634000-00000000'0a634fff rwx         0      1000  /system/lib/fake.so\n"
463 "--->Fault address falls at 00001234'5a534040 after any mapped regions\n";
464 #else
465 "    0a434000-0a434fff -w-      1000      1000  (load base 0xd000)\n"
466 "    0a534000-0a534fff --x      3000      1000  (load base 0x2000)\n"
467 "    0a634000-0a634fff rwx         0      1000  /system/lib/fake.so\n"
468 "--->Fault address falls at 0f534040 after any mapped regions\n";
469 #endif
470   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
471 
472   // Verify that the log buf is empty, and no error messages.
473   ASSERT_STREQ("", getFakeLogBuf().c_str());
474   ASSERT_STREQ("", getFakeLogPrint().c_str());
475 }
476 
TEST_F(DumpMapsTest,multiple_maps_getsiginfo_fail)477 TEST_F(DumpMapsTest, multiple_maps_getsiginfo_fail) {
478   backtrace_map_t map;
479 
480   map.start = 0xa434000;
481   map.end = 0xa435000;
482   map.offset = 0x1000;
483   map.load_base = 0xd000;
484   map.flags = PROT_WRITE;
485   map_mock_->AddMap(map);
486 
487   siginfo_t si;
488   si.si_signo = 0;
489   ptrace_set_fake_getsiginfo(si);
490   dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
491 
492   std::string tombstone_contents;
493   ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
494   ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
495   const char* expected_dump = \
496 "Cannot get siginfo for 100: Bad address\n"
497 "\nmemory map:\n"
498 #if defined(__LP64__)
499 "    00000000'0a434000-00000000'0a434fff -w-      1000      1000  (load base 0xd000)\n";
500 #else
501 "    0a434000-0a434fff -w-      1000      1000  (load base 0xd000)\n";
502 #endif
503   ASSERT_STREQ(expected_dump, tombstone_contents.c_str());
504 
505   // Verify that the log buf is empty, and no error messages.
506   ASSERT_STREQ("DEBUG Cannot get siginfo for 100: Bad address\n",
507                getFakeLogBuf().c_str());
508   ASSERT_STREQ("", getFakeLogPrint().c_str());
509 }
510 
TEST_F(DumpMapsTest,multiple_maps_check_signal_has_si_addr)511 TEST_F(DumpMapsTest, multiple_maps_check_signal_has_si_addr) {
512   backtrace_map_t map;
513 
514   map.start = 0xa434000;
515   map.end = 0xa435000;
516   map.flags = PROT_WRITE;
517   map_mock_->AddMap(map);
518 
519   for (int i = 1; i < 255; i++) {
520     ASSERT_TRUE(ftruncate(log_.tfd, 0) == 0);
521     ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
522 
523     siginfo_t si;
524     si.si_signo = i;
525     si.si_addr = reinterpret_cast<void*>(0x1000);
526     ptrace_set_fake_getsiginfo(si);
527     dump_all_maps(backtrace_mock_.get(), map_mock_.get(), &log_, 100);
528 
529     std::string tombstone_contents;
530     ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);
531     ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents));
532     bool has_addr = false;
533     switch (si.si_signo) {
534     case SIGBUS:
535     case SIGFPE:
536     case SIGILL:
537     case SIGSEGV:
538     case SIGTRAP:
539       has_addr = true;
540       break;
541     }
542 
543     const char* expected_addr_dump = \
544 "\nmemory map: (fault address prefixed with --->)\n"
545 #if defined(__LP64__)
546 "--->Fault address falls at 00000000'00001000 before any mapped regions\n"
547 "    00000000'0a434000-00000000'0a434fff -w-         0      1000\n";
548 #else
549 "--->Fault address falls at 00001000 before any mapped regions\n"
550 "    0a434000-0a434fff -w-         0      1000\n";
551 #endif
552     const char* expected_dump = \
553 "\nmemory map:\n"
554 #if defined(__LP64__)
555 "    00000000'0a434000-00000000'0a434fff -w-         0      1000\n";
556 #else
557 "    0a434000-0a434fff -w-         0      1000\n";
558 #endif
559     if (has_addr) {
560       ASSERT_STREQ(expected_addr_dump, tombstone_contents.c_str())
561         << "Signal " << si.si_signo << " expected to include an address.";
562     } else {
563       ASSERT_STREQ(expected_dump, tombstone_contents.c_str())
564         << "Signal " << si.si_signo << " is not expected to include an address.";
565     }
566 
567     // Verify that the log buf is empty, and no error messages.
568     ASSERT_STREQ("", getFakeLogBuf().c_str());
569     ASSERT_STREQ("", getFakeLogPrint().c_str());
570   }
571 }
572