swift 新手
写了一个 1000 多行的代码, 没有用 xcode 开发, 直接 vscode 撸的,
运行时 直接 ./main.swift (代码首行 #!env swift ) 或者 swiftc main.swift -o main.bin , 然后 ./main.bin 运行
现在程序大体稳定, 但是偶尔会崩溃一下, 崩溃时只是提示 crash 和很少信息, 搞不清楚哪里错误。
也试过 swiftc -g main.swift -o main.bin
然后有 lldb ./main.bin , 再 run, crash 的时候提示
error: No auto repeat.com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
(lldb) me #0: 0x0000000192db0154 CoreFoundationCFGetTypeID + 100
就不会了。。。
有没有可能像 python 那些,crash 了告诉我是哪行因为什么原因错掉的呢??
谢谢各位大佬!
1
butanediol2d 171 天前 via Android
Swift 5.9 不是有这个了吗?
https://www.swift.org/blog/swift-5.9-backtraces/ |
2
chopin1998519 OP @butanediol2d #1 我看到这个文章, 但是实在没搞懂 怎么启动这个?
|
3
chopin1998519 OP MsgType = text;
To = "marco-18149700025"; } msg: success Stack dump: 0. Program arguments: /Library/Developer/CommandLineTools/usr/bin/swift-frontend -frontend -interpret ./main.swift -Xllvm -aarch64-use-tbi -en able-objc-interop -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -color-diagnostics -external-plugin-path /Library/Developer/CommandLineT ools/SDKs/MacOSX.sdk/usr/lib/swift/host/plugins#/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/bin/swift-plugin-server -external-plugin-pa th /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/lib/swift/host/plugins#/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/bin /swift-plugin-server -external-plugin-path /Library/Developer/Developer/usr/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugi n-server -external-plugin-path /Library/Developer/Developer/usr/local/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-serv er -plugin-path /Library/Developer/CommandLineTools/usr/lib/swift/host/plugins -plugin-path /Library/Developer/CommandLineTools/usr/local/lib/swift /host/plugins -target-sdk-version 14.4 -module-name main -- pin 1. Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) 2. Compiling with the current language version 3. While running user code "./main.swift" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x00000001060eff3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x00000001060ef0f8 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x00000001060f0544 SignalHandler(int) + 360 3 libsystem_platform.dylib 0x0000000192d5f584 _sigtramp + 56 4 libsystem_platform.dylib 0xffff80010f473dac _sigtramp + 18446603334014027872 5 libsystem_platform.dylib 0x000000010f473dac _sigtramp + 18446744071502383200 6 libsystem_platform.dylib 0x000000010f478f28 _sigtramp + 18446744071502404060 7 libsystem_platform.dylib 0x000000010f47248c _sigtramp + 18446744071502376768 8 libsystem_platform.dylib 0x000000010f4794d0 _sigtramp + 18446744071502405508 9 libsystem_platform.dylib 0x000000010f47c154 _sigtramp + 18446744071502416904 10 libsystem_platform.dylib 0x000000010f47282c _sigtramp + 18446744071502377696 11 libsystem_platform.dylib 0x000000010f470210 _sigtramp + 18446744071502367940 12 libsystem_platform.dylib 0x000000010f470010 _sigtramp + 18446744071502367428 13 swift-frontend 0x0000000100b17e04 llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__1::basic_string<char, std::__1::cha r_traits<char>, std::__1::allocator<char>>>, llvm::Optional<llvm::StringRef>) + 1344 14 swift-frontend 0x0000000100a4e01c swift::SwiftJIT::runMain(llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, st d::__1::allocator<char>>>) + 168 15 swift-frontend 0x0000000100a5c19c swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::_ _1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocato r<char>>>> const&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SIL Module>>&&) + 1028 16 swift-frontend 0x00000001009f3e90 processCommandLineAndRunImmediately(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>&&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::FrontendObserver*, int&) + 624 17 swift-frontend 0x00000001009ee210 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std:: __1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift ::FrontendObserver*) + 1760 18 swift-frontend 0x00000001009eda18 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2100 19 swift-frontend 0x00000001009f1f0c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3616 20 swift-frontend 0x00000001009ef6d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4968 21 swift-frontend 0x000000010097ee8c swift::mainEntry(int, char const**) + 2612 22 dyld 0x00000001929a60e0 start + 2360 比如一次 crash, 结果是这样的。。并没有看到出错行号 |
4
chopin1998519 OP 我终于会了。。。。谢谢!
|