Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/runtime/Backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,10 +1176,10 @@ _swift_spawnBacktracer(CrashInfo *crashInfo)
backtracer_argv[16] = "preset";
break;
case ThreadsToShow::All:
backtracer_argv[16] = "all";
backtracer_argv[16] = "true";
break;
case ThreadsToShow::Crashed:
backtracer_argv[16] = "crashed";
backtracer_argv[16] = "false";
break;
}

Expand Down
50 changes: 50 additions & 0 deletions test/Backtracing/CrashWithThreads.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// RUN: %target-build-swift %s -Onone -g -o %t/CrashWithThreads
// RUN: %target-codesign %t/CrashWithThreads
// RUN: (env SWIFT_BACKTRACE=enable=yes,cache=no,swift-backtrace=%backtracer %target-run %t/CrashWithThreads 2>&1 || true) | %FileCheck -vv %s -dump-input-filter=all
// RUN: (env SWIFT_BACKTRACE=enable=yes,cache=no,swift-backtrace=%backtracer,threads=all %target-run %t/CrashWithThreads 2>&1 || true) | %FileCheck -vv %s -dump-input-filter=all --check-prefix WITHTHREADSOPT

// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
Expand Down Expand Up @@ -80,8 +81,57 @@ while (true) {
// CHECK-NEXT: 2 [ra] 0x{{[0-9a-f]+}} closure #{{[0-9]}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// CHECK-NEXT: 3 [ra] [thunk] 0x{{[0-9a-f]+}} @objc closure #{{[0-9]}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at {{.*}}<compiler-generated>

// CHECK: Thread 0{{( ".*")?}}:

// CHECK: 0 0x{{[0-9a-f]+}} __semwait_signal + {{[0-9]+}} in libsystem_kernel.dylib
// CHECK-NEXT: 1 [ra] 0x{{[0-9a-f]+}} main + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// CHECK-NEXT: 2 [ra] [system] 0x{{[0-9a-f]+}} start + {{[0-9]+}} in dyld

// CHECK: Thread {{[1-9][0-9]*( ".*")?}}:

// CHECK: 0 0x{{[0-9a-f]+}} __semwait_signal + {{[0-9]+}} in libsystem_kernel.dylib
// CHECK-NEXT: 1 [ra] 0x{{[0-9a-f]+}} closure #{{[0-9]*}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// CHECK-NEXT: 2 [ra] [thunk] 0x{{[0-9a-f]+}} @objc closure #{{[0-9]*}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at /<compiler-generated>
// CHECK-NEXT: 3 [ra] 0x{{[0-9a-f]+}} _pthread_start + {{[0-9]+}} in libsystem_pthread.dylib


// CHECK: Registers:

// CHECK: Images ({{[0-9]+}} omitted):

// CHECK: {{0x[0-9a-f]+}}–{{0x[0-9a-f]+}}{{ +}}{{([0-9a-f]+|<no build ID>)}}{{ +}}CrashWithThreads{{ +}}{{.*}}/CrashWithThreads

// WITHTHREADSOPT: *** Program crashed: Bad pointer dereference at 0x{{0+}}4 ***

// make sure there are no threads before the crashing thread (rdar://164566321)

// we expect the first thread not to be thread 0, it should be the crashing thread instead
// WITHTHREADSOPT-NOT: Thread 0{{( ".*")?}}:

// we expect a crash on a thread other than 0
// WITHTHREADSOPT: Thread {{[1-9][0-9]*}} {{(".*" )?}}crashed:

// WITHTHREADSOPT: 0 0x{{[0-9a-f]+}} reallyCrashMe() + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// WITHTHREADSOPT-NEXT: 1 [ra] 0x{{[0-9a-f]+}} crashMe() + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// WITHTHREADSOPT-NEXT: 2 [ra] 0x{{[0-9a-f]+}} closure #{{[0-9]}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// WITHTHREADSOPT-NEXT: 3 [ra] [thunk] 0x{{[0-9a-f]+}} @objc closure #{{[0-9]}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at {{.*}}<compiler-generated>

// WITHTHREADSOPT: Thread 0{{( ".*")?}}:

// WITHTHREADSOPT: 0 0x{{[0-9a-f]+}} __semwait_signal + {{[0-9]+}} in libsystem_kernel.dylib
// WITHTHREADSOPT-NEXT: 1 [ra] 0x{{[0-9a-f]+}} main + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// WITHTHREADSOPT-NEXT: 2 [ra] [system] 0x{{[0-9a-f]+}} start + {{[0-9]+}} in dyld

// WITHTHREADSOPT: Thread {{[1-9][0-9]*( ".*")?}}:

// WITHTHREADSOPT: 0 0x{{[0-9a-f]+}} __semwait_signal + {{[0-9]+}} in libsystem_kernel.dylib
// WITHTHREADSOPT-NEXT: 1 [ra] 0x{{[0-9a-f]+}} closure #{{[0-9]*}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at {{.*}}/CrashWithThreads
// WITHTHREADSOPT-NEXT: 2 [ra] [thunk] 0x{{[0-9a-f]+}} @objc closure #{{[0-9]*}} in spawnThread(_:) + {{[0-9]+}} in CrashWithThreads at /<compiler-generated>
// WITHTHREADSOPT-NEXT: 3 [ra] 0x{{[0-9a-f]+}} _pthread_start + {{[0-9]+}} in libsystem_pthread.dylib

// WITHTHREADSOPT: Registers:

// WITHTHREADSOPT: Images ({{[0-9]+}} omitted):

// WITHTHREADSOPT: {{0x[0-9a-f]+}}–{{0x[0-9a-f]+}}{{ +}}{{([0-9a-f]+|<no build ID>)}}{{ +}}CrashWithThreads{{ +}}{{.*}}/CrashWithThreads