File: asan-symbolize-partial-report-no-external-symbolizer.cc

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (38 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download | duplicates (2)
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
// UNSUPPORTED: ios
// When `external_symbolizer_path` is empty on Darwin we fallback on using
// dladdr as the symbolizer which means we get the symbol name
// but no source location. The current implementation also doesn't try to
// change the module name so we end up with the full name so we actually don't
// need the module map here.

// RUN: %clangxx_asan -O0 -g %s -o %t.executable
// RUN: %env_asan_opts=symbolize=1,print_module_map=0,external_symbolizer_path= not %run %t.executable > %t2.log 2>&1
// RUN: FileCheck -input-file=%t2.log -check-prefix=CHECK-PS %s
// RUN: %asan_symbolize --force-system-symbolizer < %t2.log > %t2.fully_symbolized
// RUN: FileCheck -input-file=%t2.fully_symbolized -check-prefix=CHECK-FS %s

#include <cstdlib>

// Partially symbolicated back-trace where symbol is available but
// source location is not and instead module name and offset are
// printed.
// CHECK-PS: WRITE of size 4
// CHECK-PS: #0 0x{{.+}} in foo ({{.+}}.executable:{{.+}}+0x{{.+}})
// CHECK-PS: #1 0x{{.+}} in main ({{.+}}.executable:{{.+}}+0x{{.+}})

// CHECK-FS: WRITE of size 4

extern "C" void foo(int* a) {
  // CHECK-FS: #0 0x{{.+}} in foo {{.*}}asan-symbolize-partial-report-no-external-symbolizer.cc:[[@LINE+1]]
  *a = 5;
}

int main() {
  int* a = (int*) malloc(sizeof(int));
  if (!a)
    return 0;
  free(a);
  // CHECK-FS: #1 0x{{.+}} in main {{.*}}asan-symbolize-partial-report-no-external-symbolizer.cc:[[@LINE+1]]
  foo(a);
  return 0;
}