[Lldb-commits] [PATCH] D34776: Make i386-*-freebsd expression work on JIT path
karnajitw created this revision. Herald added a subscriber: emaste. Expression evaluation which takes the non IRInterpreter::Interpret path fails on i386-*-freebsd. Following changes are done to enable it. 1. Enable i386 ABI creation for freebsd 2. Added an extra argument in ABISysV_i386::PrepareTrivialCall for mmap syscall 3. Unlike linux, the last argument of mmap is actually 64-bit(off_t). This requires us to push an additional word for the higher order bits. 4. Prior to this change, ktrace dump will show mmap failures due to invalid argument coming from the 6th mmap argument. Prior Fix: (lldb) expression printf("%d", d1) error: Can't run the expression locally: Interpreter doesn't handle one of the expression's opcodes (lldb) expression d1 + 5 << IRInterpreter path (int) $0 = 10 (lldb) expression d1 + 5.0 error: Can't run the expression locally: Interpreter doesn't handle one of the expression's opcodes (lldb) expression f1 * 5 error: Can't run the expression locally: Interpreter doesn't handle one of the expression's opcodes (lldb) expression f1 / 5 error: Can't run the expression locally: Interpreter doesn't handle one of the expression's opcodes With Fix: (lldb) expression printf("%d", d1) (int) $0 = 1 (lldb) expression printf("%2.3f", f1) (int) $2 = 5 (lldb) expression d1 + 5 (int) $3 = 10 (lldb) expression d1 + 5.0 (double) $4 = 10 (lldb) expression f1 * 5 (float) $7 = 25.5 (lldb) expression f1 / 5 (float) $8 = 1.0198 NOTE: Expression involving floating point arithmetic will result in NaN on i386-*-freebsd11.0. Patch https://svnweb.freebsd.org/base?view=revision&revision=320051 is required to make it work. Repository: rL LLVM https://reviews.llvm.org/D34776 Files: source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Index: source/Plugins/Process/Utility/InferiorCallPOSIX.cpp === --- source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -89,7 +89,11 @@ process->GetTarget().GetScratchClangASTContext(); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); -lldb::addr_t args[] = {addr, length, prot_arg, flags_arg, fd, offset}; +llvm::SmallVector args({ addr, length, prot_arg, +flags_arg, fd, offset }); +if (arch.GetTriple().getOS() == llvm::Triple::FreeBSD +&& arch.GetTriple().getArch() == llvm::Triple::x86) + args.push_back(0); lldb::ThreadPlanSP call_plan_sp( new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(), clang_void_ptr_type, args, options)); Index: source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp === --- source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -206,7 +206,7 @@ ABISysV_i386::CreateInstance(const ArchSpec &arch) { static ABISP g_abi_sp; if ((arch.GetTriple().getArch() == llvm::Triple::x86) && - arch.GetTriple().isOSLinux()) { + (arch.GetTriple().isOSLinux() || arch.GetTriple().isOSFreeBSD())) { if (!g_abi_sp) g_abi_sp.reset(new ABISysV_i386); return g_abi_sp; Index: source/Plugins/Process/Utility/InferiorCallPOSIX.cpp === --- source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -89,7 +89,11 @@ process->GetTarget().GetScratchClangASTContext(); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); -lldb::addr_t args[] = {addr, length, prot_arg, flags_arg, fd, offset}; +llvm::SmallVector args({ addr, length, prot_arg, +flags_arg, fd, offset }); +if (arch.GetTriple().getOS() == llvm::Triple::FreeBSD +&& arch.GetTriple().getArch() == llvm::Triple::x86) + args.push_back(0); lldb::ThreadPlanSP call_plan_sp( new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(), clang_void_ptr_type, args, options)); Index: source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp === --- source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -206,7 +206,7 @@ ABISysV_i386::CreateInstance(const ArchSpec &arch) { static ABISP g_abi_sp; if ((arch.GetTriple().getArch() == llvm::Triple::x86) && - arch.GetTriple().isOSLinux()) { + (arch.GetTriple().isOSLinux() || arch.GetTriple().isOSFreeBSD())) { if (!g_abi_sp) g_abi_sp.reset(new ABISysV_i386); return g_abi_sp; ___
[Lldb-commits] [PATCH] D34776: Make i386-*-freebsd expression work on JIT path
karnajitw added a comment. Adding the corresponing reference discussions with freebsd folks. mmap - https://lists.freebsd.org/pipermail/freebsd-hackers/2017-May/051072.html x87 tag- https://lists.freebsd.org/pipermail/freebsd-hackers/2017-June/051166.html Repository: rL LLVM https://reviews.llvm.org/D34776 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D34776: Make i386-*-freebsd expression work on JIT path
karnajitw added a comment. Looks like the right thing to do. I will make the changes accordingly. Repository: rL LLVM https://reviews.llvm.org/D34776 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D34776: Make i386-*-freebsd expression work on JIT path
karnajitw updated this revision to Diff 104984. karnajitw added a comment. Done the changes. Please verify. Tried with RefArray but looks like they don't work well with copy. https://reviews.llvm.org/D34776 Files: include/lldb/Target/Platform.h source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h source/Plugins/Platform/Linux/PlatformLinux.cpp source/Plugins/Platform/Linux/PlatformLinux.h source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp source/Plugins/Platform/NetBSD/PlatformNetBSD.h source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h source/Plugins/Process/Utility/InferiorCallPOSIX.cpp source/Target/Platform.cpp Index: source/Target/Platform.cpp === --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -1316,14 +1316,18 @@ return error; } -uint64_t Platform::ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) { +MmapArgList Platform::GetMmapArgumentList(const ArchSpec &arch, addr_t addr, + addr_t length, unsigned prot, + unsigned flags, addr_t fd, + addr_t offset) { uint64_t flags_platform = 0; if (flags & eMmapFlagsPrivate) flags_platform |= MAP_PRIVATE; if (flags & eMmapFlagsAnon) flags_platform |= MAP_ANON; - return flags_platform; + + MmapArgList args({addr, length, prot, flags_platform, fd, offset}); + return args; } lldb_private::Status Platform::RunShellCommand( Index: source/Plugins/Process/Utility/InferiorCallPOSIX.cpp === --- source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -64,7 +64,7 @@ options.SetTimeout(std::chrono::milliseconds(500)); options.SetTrapExceptions(false); - addr_t prot_arg, flags_arg = 0; + addr_t prot_arg; if (prot == eMmapProtNone) prot_arg = PROT_NONE; else { @@ -77,11 +77,6 @@ prot_arg |= PROT_WRITE; } - const ArchSpec arch = process->GetTarget().GetArchitecture(); - flags_arg = - process->GetTarget().GetPlatform()->ConvertMmapFlagsToPlatform(arch, - flags); - AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) { @@ -89,7 +84,10 @@ process->GetTarget().GetScratchClangASTContext(); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); -lldb::addr_t args[] = {addr, length, prot_arg, flags_arg, fd, offset}; +const ArchSpec arch = process->GetTarget().GetArchitecture(); +MmapArgList args = +process->GetTarget().GetPlatform()->GetMmapArgumentList( +arch, addr, length, prot_arg, flags, fd, offset); lldb::ThreadPlanSP call_plan_sp( new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(), clang_void_ptr_type, args, options)); Index: source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h === --- source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h +++ source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h @@ -53,8 +53,10 @@ void CalculateTrapHandlerSymbolNames() override; - uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) override; + MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, + lldb::addr_t length, unsigned prot, + unsigned flags, lldb::addr_t fd, + lldb::addr_t offset) override; private: DISALLOW_COPY_AND_ASSIGN(PlatformOpenBSD); Index: source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp === --- source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -211,8 +211,10 @@ m_trap_handlers.push_back(ConstString("_sigtramp")); } -uint64_t PlatformOpenBSD::ConvertMmapFlagsToPlatform(const ArchSpec &arch, -unsigned flags) { +MmapArgList PlatformOpenBSD::GetMmapArgumentList(const ArchSpec &arch, + addr_t addr, addr_t length, + unsigned prot, unsigned flags, + addr_t fd, addr_t offset) { uint64_t f
[Lldb-commits] [PATCH] D34776: Make i386-*-freebsd expression work on JIT path
karnajitw marked an inline comment as done. karnajitw added a comment. With my test setup on i386-*-freebsd-11.0 (freebsd patched).. There seems to be quite a good improvement in the number of test failures. [BEFORE lldb patch] === Test Result Summary === Test Methods: 1276 Reruns:2 Success: 490 Expected Failure: 57 Failure: 61 Error: 2 Exceptional Exit: 1 Unexpected Success:5 Skip:658 Timeout: 2 Expected Timeout: 0 [After lldb patch] == Test Result Summary === Test Methods: 1276 Reruns:0 Success: 545 Expected Failure: 55 Failure: 6 Error: 2 Exceptional Exit: 1 Unexpected Success:7 Skip:658 Timeout: 2 Expected Timeout: 0 https://reviews.llvm.org/D34776 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd
karnajitw created this revision. Herald added a subscriber: emaste. This is the freebsd equivalent of https://reviews.llvm.org/rL238549. The fix serves 2 purpose 1. LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/SIGFPE the way it is suppose to be handled. Prior to this fix these signals will neither create a coredump, nor exit from the debugger or work for signal handling scenario. 2. eInvalidCrashReason need not report "unknown crash reason" if we have a valid si_signo Repository: rL LLVM https://reviews.llvm.org/D35223 Files: FreeBSD/FreeBSDThread.cpp FreeBSD/POSIXStopInfo.cpp FreeBSD/POSIXStopInfo.h FreeBSD/ProcessMonitor.cpp Index: FreeBSD/ProcessMonitor.cpp === --- FreeBSD/ProcessMonitor.cpp +++ FreeBSD/ProcessMonitor.cpp @@ -1204,7 +1204,9 @@ case SIGBUS: lldb::addr_t fault_addr = reinterpret_cast(info->si_addr); const auto reason = GetCrashReason(*info); -return ProcessMessage::Crash(tid, reason, signo, fault_addr); +if (reason != CrashReason::eInvalidCrashReason) { + return ProcessMessage::Crash(tid, reason, signo, fault_addr); +} // else; Use atleast si_signo info for other si_code } // Everything else is "normal" and does not require any special action on Index: FreeBSD/POSIXStopInfo.h === --- FreeBSD/POSIXStopInfo.h +++ FreeBSD/POSIXStopInfo.h @@ -45,19 +45,6 @@ }; //===--===// -/// @class POSIXCrashStopInfo -/// @brief Represents the stop state of process that is ready to crash. -/// -class POSIXCrashStopInfo : public POSIXStopInfo { -public: - POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, CrashReason reason, - lldb::addr_t fault_addr); - ~POSIXCrashStopInfo(); - - lldb::StopReason GetStopReason() const; -}; - -//===--===// /// @class POSIXNewThreadStopInfo /// @brief Represents the stop state of process when a new thread is spawned. /// Index: FreeBSD/POSIXStopInfo.cpp === --- FreeBSD/POSIXStopInfo.cpp +++ FreeBSD/POSIXStopInfo.cpp @@ -28,22 +28,6 @@ bool POSIXLimboStopInfo::ShouldNotify(Event *event_ptr) { return false; } //===--===// -// POSIXCrashStopInfo - -POSIXCrashStopInfo::POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, - CrashReason reason, - lldb::addr_t fault_addr) -: POSIXStopInfo(thread, status) { - m_description = ::GetCrashReasonString(reason, fault_addr); -} - -POSIXCrashStopInfo::~POSIXCrashStopInfo() {} - -lldb::StopReason POSIXCrashStopInfo::GetStopReason() const { - return lldb::eStopReasonException; -} - -//===--===// // POSIXNewThreadStopInfo POSIXNewThreadStopInfo::~POSIXNewThreadStopInfo() {} Index: FreeBSD/FreeBSDThread.cpp === --- FreeBSD/FreeBSDThread.cpp +++ FreeBSD/FreeBSDThread.cpp @@ -375,6 +375,7 @@ LimboNotify(message); break; + case ProcessMessage::eCrashMessage: case ProcessMessage::eSignalMessage: SignalNotify(message); break; @@ -395,10 +396,6 @@ WatchNotify(message); break; - case ProcessMessage::eCrashMessage: -CrashNotify(message); -break; - case ProcessMessage::eExecMessage: ExecNotify(message); break; @@ -577,7 +574,15 @@ void FreeBSDThread::SignalNotify(const ProcessMessage &message) { int signo = message.GetSignal(); - SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); + if (message.GetKind() == ProcessMessage::eCrashMessage) { +std::string stop_description = GetCrashReasonString( +message.GetCrashReason(), +reinterpret_cast(message.GetFaultAddress())); +SetStopInfo(StopInfo::CreateStopReasonWithSignal( +*this, signo, stop_description.c_str())); + } else { +SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); + } } void FreeBSDThread::SignalDeliveredNotify(const ProcessMessage &message) { @@ -585,21 +590,6 @@ SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); } -void FreeBSDThread::CrashNotify(const ProcessMessage &message) { - // FIXME: Update stop reason as per bugzilla 14598 - int signo = message.GetSignal(); - - assert(message.GetKind() == ProcessMessage::eCrashMessage); - - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); - if (log) -log->Printf("FreeBSDThread::%s () signo = %i, reason = '%s'", __FUNCTION__, -signo, message.PrintCrashReason()); - - SetStopInfo(lldb::StopInfoSP(new POSIXCrashStopInfo( - *this, sig
[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd
karnajitw added a comment. Adding the associated bugzilla link for this issue https://bugs.llvm.org/show_bug.cgi?id=23699 [Before Fix] [/home/karnajitw/llvm_50_public/build.symbol] $ bin/lldb ~/lldb_test_execs/sigsegv (lldb) target create "/home/karnajitw/lldb_test_execs/sigsegv" Current executable set to '/home/karnajitw/lldb_test_execs/sigsegv' (x86_64). (lldb) run Process 19312 launching Process 19312 launched: '/home/karnajitw/lldb_test_execs/sigsegv' (x86_64) Trying to write on a read only memory... Process 19312 stopped - thread #1, name = 'sigsegv', stop reason = signal SIGSEGV: address access protected (fault address: 0x4007e6) frame #0: 0x0040077c sigsegv`main at sigsegv.c:9 6 7 printf("Trying to write on a read only memory...\n"); 8 -> 9 *s = 'h'; 10 11 printf("Exited normally...\n"); 12 (lldb) c Process 19312 resuming Process 19312 stopped - thread #1, name = 'sigsegv', stop reason = signal SIGSEGV: address access protected (fault address: 0x4007e6) frame #0: 0x0040077c sigsegv`main at sigsegv.c:9 6 7 printf("Trying to write on a read only memory...\n"); 8 -> 9 *s = 'h'; 10 11 printf("Exited normally...\n"); 12 [/home/karnajitw/llvm_50_public/build.symbol] $ bin/lldb ~/lldb_test_execs/sigill (lldb) target create "/home/karnajitw/lldb_test_execs/sigill" Current executable set to '/home/karnajitw/lldb_test_execs/sigill' (x86_64). (lldb) run Process 19141 launching Process 19141 launched: '/home/karnajitw/lldb_test_execs/sigill' (x86_64) Trying to trigger SIGILL Process 19141 stopped - thread #1, name = 'sigill', stop reason = unknown crash reason frame #0: 0x0008008e45ca libc.so.7`__sys_thr_kill + 10 libc.so.7`__sys_thr_kill: -> 0x8008e45ca <+10>: jb 0x800975474 0x8008e45d0 <+16>: retq 0x8008e45d1: nop 0x8008e45d2: nop [After Fix] [/usr/home/karnajitw/llvm_50_public/build.symbol] $ bin/lldb ~/lldb_test_execs/a.out (lldb) target create "/home/karnajitw/lldb_test_execs/a.out" Current executable set to '/home/karnajitw/lldb_test_execs/a.out' (x86_64). (lldb) run Process 17945 launching Process 17945 launched: '/home/karnajitw/lldb_test_execs/a.out' (x86_64) Trying to write on a read only memory... Process 17945 stopped - thread #1, name = 'a.out', stop reason = signal SIGSEGV frame #0: 0x0040077c a.out`main at sigsegv.c:9 6 7printf("Trying to write on a read only memory...\n"); 8 -> 9*s = 'h'; 10 11 printf("Exited normally...\n"); 12 (lldb) c Process 17945 resuming Process 17945 exited with status = -1 (0x) [/home/karnajitw/llvm_50_public/build.symbol] $ bin/lldb ~/lldb_test_execs/sigill (lldb) target create "/home/karnajitw/lldb_test_execs/sigill" Current executable set to '/home/karnajitw/lldb_test_execs/sigill' (x86_64). (lldb) run Process 18529 launching Process 18529 launched: '/home/karnajitw/lldb_test_execs/sigill' (x86_64) Trying to trigger SIGILL Process 18529 stopped - thread #1, name = 'sigill', stop reason = signal SIGILL frame #0: 0x0008008e45ca libc.so.7`__sys_thr_kill + 10 libc.so.7`__sys_thr_kill: -> 0x8008e45ca <+10>: jb 0x800975474 0x8008e45d0 <+16>: retq 0x8008e45d1: nop 0x8008e45d2: nop Repository: rL LLVM https://reviews.llvm.org/D35223 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd
karnajitw updated this revision to Diff 106423. karnajitw added a comment. Updated the patch. While referring to the linux implementation, looks like I have added a reinterpret_cast on message.GetFaultAddress which is not required in the freebsd scenario. Repository: rL LLVM https://reviews.llvm.org/D35223 Files: FreeBSD/FreeBSDThread.cpp FreeBSD/POSIXStopInfo.cpp FreeBSD/POSIXStopInfo.h FreeBSD/ProcessMonitor.cpp Index: FreeBSD/ProcessMonitor.cpp === --- FreeBSD/ProcessMonitor.cpp +++ FreeBSD/ProcessMonitor.cpp @@ -1204,7 +1204,9 @@ case SIGBUS: lldb::addr_t fault_addr = reinterpret_cast(info->si_addr); const auto reason = GetCrashReason(*info); -return ProcessMessage::Crash(tid, reason, signo, fault_addr); +if (reason != CrashReason::eInvalidCrashReason) { + return ProcessMessage::Crash(tid, reason, signo, fault_addr); +} // else; Use atleast si_signo info for other si_code } // Everything else is "normal" and does not require any special action on Index: FreeBSD/POSIXStopInfo.h === --- FreeBSD/POSIXStopInfo.h +++ FreeBSD/POSIXStopInfo.h @@ -45,19 +45,6 @@ }; //===--===// -/// @class POSIXCrashStopInfo -/// @brief Represents the stop state of process that is ready to crash. -/// -class POSIXCrashStopInfo : public POSIXStopInfo { -public: - POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, CrashReason reason, - lldb::addr_t fault_addr); - ~POSIXCrashStopInfo(); - - lldb::StopReason GetStopReason() const; -}; - -//===--===// /// @class POSIXNewThreadStopInfo /// @brief Represents the stop state of process when a new thread is spawned. /// Index: FreeBSD/POSIXStopInfo.cpp === --- FreeBSD/POSIXStopInfo.cpp +++ FreeBSD/POSIXStopInfo.cpp @@ -28,22 +28,6 @@ bool POSIXLimboStopInfo::ShouldNotify(Event *event_ptr) { return false; } //===--===// -// POSIXCrashStopInfo - -POSIXCrashStopInfo::POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, - CrashReason reason, - lldb::addr_t fault_addr) -: POSIXStopInfo(thread, status) { - m_description = ::GetCrashReasonString(reason, fault_addr); -} - -POSIXCrashStopInfo::~POSIXCrashStopInfo() {} - -lldb::StopReason POSIXCrashStopInfo::GetStopReason() const { - return lldb::eStopReasonException; -} - -//===--===// // POSIXNewThreadStopInfo POSIXNewThreadStopInfo::~POSIXNewThreadStopInfo() {} Index: FreeBSD/FreeBSDThread.cpp === --- FreeBSD/FreeBSDThread.cpp +++ FreeBSD/FreeBSDThread.cpp @@ -375,6 +375,7 @@ LimboNotify(message); break; + case ProcessMessage::eCrashMessage: case ProcessMessage::eSignalMessage: SignalNotify(message); break; @@ -395,10 +396,6 @@ WatchNotify(message); break; - case ProcessMessage::eCrashMessage: -CrashNotify(message); -break; - case ProcessMessage::eExecMessage: ExecNotify(message); break; @@ -577,7 +574,14 @@ void FreeBSDThread::SignalNotify(const ProcessMessage &message) { int signo = message.GetSignal(); - SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); + if (message.GetKind() == ProcessMessage::eCrashMessage) { +std::string stop_description = GetCrashReasonString( +message.GetCrashReason(), message.GetFaultAddress()); +SetStopInfo(StopInfo::CreateStopReasonWithSignal( +*this, signo, stop_description.c_str())); + } else { +SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); + } } void FreeBSDThread::SignalDeliveredNotify(const ProcessMessage &message) { @@ -585,21 +589,6 @@ SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); } -void FreeBSDThread::CrashNotify(const ProcessMessage &message) { - // FIXME: Update stop reason as per bugzilla 14598 - int signo = message.GetSignal(); - - assert(message.GetKind() == ProcessMessage::eCrashMessage); - - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); - if (log) -log->Printf("FreeBSDThread::%s () signo = %i, reason = '%s'", __FUNCTION__, -signo, message.PrintCrashReason()); - - SetStopInfo(lldb::StopInfoSP(new POSIXCrashStopInfo( - *this, signo, message.GetCrashReason(), message.GetFaultAddress(; -} - unsigned FreeBSDThread::GetRegisterIndexFromOffset(unsigned offset) { unsigned reg = LLDB_INVALID_REGNUM; ArchSpec arch = HostInfo::GetArchitecture(); __
[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd
karnajitw updated this revision to Diff 110438. karnajitw added a comment. Herald added a subscriber: krytarowski. Updated the diff to include the changes that were required in the test part. Please verify. Repository: rL LLVM https://reviews.llvm.org/D35223 Files: packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py source/Plugins/Process/FreeBSD/FreeBSDThread.cpp source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp source/Plugins/Process/FreeBSD/POSIXStopInfo.h source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Index: source/Plugins/Process/FreeBSD/ProcessMonitor.cpp === --- source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -1204,7 +1204,9 @@ case SIGBUS: lldb::addr_t fault_addr = reinterpret_cast(info->si_addr); const auto reason = GetCrashReason(*info); -return ProcessMessage::Crash(tid, reason, signo, fault_addr); +if (reason != CrashReason::eInvalidCrashReason) { + return ProcessMessage::Crash(tid, reason, signo, fault_addr); +} // else; Use atleast si_signo info for other si_code } // Everything else is "normal" and does not require any special action on Index: source/Plugins/Process/FreeBSD/POSIXStopInfo.h === --- source/Plugins/Process/FreeBSD/POSIXStopInfo.h +++ source/Plugins/Process/FreeBSD/POSIXStopInfo.h @@ -45,19 +45,6 @@ }; //===--===// -/// @class POSIXCrashStopInfo -/// @brief Represents the stop state of process that is ready to crash. -/// -class POSIXCrashStopInfo : public POSIXStopInfo { -public: - POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, CrashReason reason, - lldb::addr_t fault_addr); - ~POSIXCrashStopInfo(); - - lldb::StopReason GetStopReason() const; -}; - -//===--===// /// @class POSIXNewThreadStopInfo /// @brief Represents the stop state of process when a new thread is spawned. /// Index: source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp === --- source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp +++ source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp @@ -28,22 +28,6 @@ bool POSIXLimboStopInfo::ShouldNotify(Event *event_ptr) { return false; } //===--===// -// POSIXCrashStopInfo - -POSIXCrashStopInfo::POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, - CrashReason reason, - lldb::addr_t fault_addr) -: POSIXStopInfo(thread, status) { - m_description = ::GetCrashReasonString(reason, fault_addr); -} - -POSIXCrashStopInfo::~POSIXCrashStopInfo() {} - -lldb::StopReason POSIXCrashStopInfo::GetStopReason() const { - return lldb::eStopReasonException; -} - -//===--===// // POSIXNewThreadStopInfo POSIXNewThreadStopInfo::~POSIXNewThreadStopInfo() {} Index: source/Plugins/Process/FreeBSD/FreeBSDThread.cpp === --- source/Plugins/Process/FreeBSD/FreeBSDThread.cpp +++ source/Plugins/Process/FreeBSD/FreeBSDThread.cpp @@ -375,6 +375,7 @@ LimboNotify(message); break; + case ProcessMessage::eCrashMessage: case ProcessMessage::eSignalMessage: SignalNotify(message); break; @@ -395,10 +396,6 @@ WatchNotify(message); break; - case ProcessMessage::eCrashMessage: -CrashNotify(message); -break; - case ProcessMessage::eExecMessage: ExecNotify(message); break; @@ -577,7 +574,14 @@ void FreeBSDThread::SignalNotify(const ProcessMessage &message) { int signo = message.GetSignal(); - SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); + if (message.GetKind() == ProcessMessage::eCrashMessage) { +std::string stop_description = GetCrashReasonString( +message.GetCrashReason(), message.GetFaultAddress()); +SetStopInfo(StopInfo::CreateStopReasonWithSignal( +*this, signo, stop_description.c_str())); + } else { +SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); + } } void FreeBSDThread::SignalDeliveredNotify(const ProcessMessage &message) { @@ -585,21 +589,6 @@ SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo)); } -void FreeBSDThread::CrashNotify(const ProcessMessage &message) { - // FIXME: Update stop reason as per bugzilla 14598 - int signo = message.GetSignal(); - - assert(message.Ge
[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd
karnajitw added a comment. Thanks for the info. I will make sure of it in future. Repository: rL LLVM https://reviews.llvm.org/D35223 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits