Skip to content

Commit 582946b

Browse files
committed
[Backtracing][Linux] Remove status argument.
The `status` argument to the `_swift_backtrace_demangle()` function isn't especially useful, won't match behaviour on Windows, and we actually don't use it in the Swift code that calls this SPI. Remove it. rdar://110261712
1 parent 8d91384 commit 582946b

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

include/swift/Runtime/Backtrace.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ bool _swift_backtrace_isThunkFunction(const char *mangledName);
146146
/// @param outputBuffer is a pointer to a buffer in which to place the result.
147147
/// @param outputBufferSize points to a variable that contains the size of the
148148
/// output buffer.
149-
/// @param status returns the status codes defined in the C++ ABI.
150149
///
151150
/// If outputBuffer is nullptr, the function will allocate memory for the
152151
/// result using malloc(). In this case, outputBufferSize may be nullptr;
@@ -168,8 +167,7 @@ SWIFT_RUNTIME_STDLIB_SPI
168167
char *_swift_backtrace_demangle(const char *mangledName,
169168
size_t mangledNameLength,
170169
char *outputBuffer,
171-
size_t *outputBufferSize,
172-
int *status);
170+
size_t *outputBufferSize);
173171
#ifdef __cplusplus
174172
} // namespace backtrace
175173
} // namespace runtime

stdlib/public/Backtracing/SymbolicatedBacktrace.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ public struct SymbolicatedBacktrace: CustomStringConvertible {
200200
/// Demangle the raw name, if possible.
201201
private func demangleRawName() -> String {
202202
var length: size_t = 0
203-
var status: CInt = 0
204203
if let demangled = _swift_backtrace_demangle(rawName, rawName.utf8.count,
205-
nil, &length, &status) {
204+
nil, &length) {
206205
defer { free(demangled) }
207206

208207
// length is the size of the buffer that was allocated, *not* the

stdlib/public/runtime/Backtrace.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,7 @@ SWIFT_RUNTIME_STDLIB_SPI char *
855855
_swift_backtrace_demangle(const char *mangledName,
856856
size_t mangledNameLength,
857857
char *outputBuffer,
858-
size_t *outputBufferSize,
859-
int *status) {
858+
size_t *outputBufferSize) {
860859
llvm::StringRef name = llvm::StringRef(mangledName, mangledNameLength);
861860

862861
// You must provide buffer size if you're providing your own output buffer
@@ -884,13 +883,13 @@ _swift_backtrace_demangle(const char *mangledName,
884883
::memcpy(outputBuffer, result.data(), toCopy);
885884
outputBuffer[toCopy] = '\0';
886885

887-
*status = 0;
888886
return outputBuffer;
889887
#ifndef _WIN32
890888
} else if (name.startswith("_Z")) {
891889
// Try C++
892890
size_t resultLen;
893-
char *result = abi::__cxa_demangle(mangledName, nullptr, &resultLen, status);
891+
int status = 0;
892+
char *result = abi::__cxa_demangle(mangledName, nullptr, &resultLen, &status);
894893

895894
if (result) {
896895
size_t bufferSize;
@@ -910,15 +909,12 @@ _swift_backtrace_demangle(const char *mangledName,
910909

911910
free(result);
912911

913-
*status = 0;
914912
return outputBuffer;
915913
}
916914
#else
917915
// On Windows, the mangling is different.
918916
// ###TODO: Call __unDName()
919917
#endif
920-
} else {
921-
*status = -2;
922918
}
923919

924920
return nullptr;

0 commit comments

Comments
 (0)