[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD
krytarowski created this revision. krytarowski added a project: LLDB. Herald added a subscriber: mgorny. This patch is a stripped down from features a NetBSD process code (patch is kept under 2k LOC). This code has assumption that there is only one thread within a debugged process. The only debugger trap supported is software breakpoint (TRAP_BRKPT). The generic platform code requires to add dummy function for watchpoints etc. These functions are currently empty. This code is not the final platform support as is and it's treated as a base to extend, refactor and address issues afterwards. Supported features: - handle software breakpoints, - correctly attach to a tracee, - support NetBSD specific ptrace(2), - monitor process termination, - monitor SIGTRAP events, - monitor SIGSTOP events, - monitor other signals events, - resume the whole process, - get memory region info perms, - read memory from tracee, - write memory to tracee, - read ELF AUXV, - x86_64 GPR read and write code For the generic framework include: - halt, - detach, - signal, - kill, - allocatememory, - deallocatememory, - update threads, - getarchitecture, - getfileloadaddress, - and others. This code has preliminary AddThread code. Out of interest in this patch: - exec() traps, - hardware debug register traps, - single step trap, - thread creation/termination trap, - process fork(2), vfork(2) and vfork(2) done traps, - syscall entry and exit trap, - threads, - FPR registers, - retrieving tracee's thread name, - non x86_64 support. This code can be used to start a hello world application and trace it. This code can be used by other BSD systems as a starting point to get similar capabilities. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31374 Files: source/Plugins/Process/NetBSD/CMakeLists.txt source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h === --- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -22,6 +22,45 @@ public: NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid); + + // - + // NativeThreadProtocol Interface + // - + std::string GetName() override; + + lldb::StateType GetState() override; + + bool GetStopReason(ThreadStopInfo &stop_info, + std::string &description) override; + + NativeRegisterContextSP GetRegisterContext() override; + + Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, + bool hardware) override; + + Error RemoveWatchpoint(lldb::addr_t addr) override; + + Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override; + + Error RemoveHardwareBreakpoint(lldb::addr_t addr) override; + +private: + // - + // Interface for friend classes + // - + + void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); + void SetStoppedByBreakpoint(); + void SetStopped(); + void SetRunning(); + + // - + // Member Variables + // - + lldb::StateType m_state; + ThreadStopInfo m_stop_info; + NativeRegisterContextSP m_reg_context_sp; + std::string m_stop_description; }; typedef std::shared_ptr NativeThreadNetBSDSP; Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -12,10 +12,145 @@ #include "NativeProcessNetBSD.h" +#include "Plugins/Process/POSIX/CrashReason.h" +#include "Plugins/Process/POSIX/ProcessPOSIXLog.h" +#include "lldb/Core/RegisterValue.h" +#include "lldb/Core/State.h" + using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_netbsd; NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid) -: NativeThreadProtocol(process, tid) {} +: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid), + m_stop_info(), m_reg_context_sp(), m_s
[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support
kettenis added a comment. Can somebody commit this diff for me? https://reviews.llvm.org/D31131 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD
kettenis added a comment. On OpenBSD the register context used in core dumps uses the same layout as ptrace(2). That's not the case on all OSes, but I believe that is the case for NetBSD as well. Would it be possible to re-use the register context data structures defined in the source/Plugins/Process/Utility/ directory? Repository: rL LLVM https://reviews.llvm.org/D31374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support
krytarowski added a comment. In https://reviews.llvm.org/D31131#710862, @kettenis wrote: > Can somebody commit this diff for me? Sure, I'm on it. https://reviews.llvm.org/D31131 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r298810 - [LLDB] OpenBSD support
Author: kamil Date: Sun Mar 26 10:34:57 2017 New Revision: 298810 URL: http://llvm.org/viewvc/llvm-project?rev=298810&view=rev Log: [LLDB] OpenBSD support Summary: Add basic OpenBSD support. This is enough to be able to analyze core dumps for OpenBSD/amd64, OpenBSD/arm, OpenBSD/arm64 and OpenBSD/i386. Note that part of the changes to source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp fix a bug that probably affects other platforms as well. The GetProgramHeaderByIndex() interface use 1-based indices, but in some case when looping over the headers the, the loop starts at 0 and misses the last header. This caused problems on OpenBSD since OpenBSD core dumps have the PT_NOTE segment as the last program header. Reviewers: joerg, labath, krytarowski Reviewed By: krytarowski Subscribers: aemerson, emaste, rengolin, srhines, krytarowski, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D31131 Added: lldb/trunk/include/lldb/Host/openbsd/ lldb/trunk/include/lldb/Host/openbsd/Config.h lldb/trunk/include/lldb/Host/openbsd/HostInfoOpenBSD.h lldb/trunk/source/Host/openbsd/ lldb/trunk/source/Host/openbsd/Host.cpp lldb/trunk/source/Host/openbsd/HostInfoOpenBSD.cpp lldb/trunk/source/Plugins/Platform/OpenBSD/ lldb/trunk/source/Plugins/Platform/OpenBSD/CMakeLists.txt lldb/trunk/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp lldb/trunk/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h Modified: lldb/trunk/include/lldb/Host/Config.h lldb/trunk/include/lldb/Host/Editline.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Host/HostInfo.h lldb/trunk/source/API/SystemInitializerFull.cpp lldb/trunk/source/CMakeLists.txt lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/Platform/CMakeLists.txt lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Modified: lldb/trunk/include/lldb/Host/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h?rev=298810&r1=298809&r2=298810&view=diff == --- lldb/trunk/include/lldb/Host/Config.h (original) +++ lldb/trunk/include/lldb/Host/Config.h Sun Mar 26 10:34:57 2017 @@ -22,8 +22,7 @@ #include "lldb/Host/linux/Config.h" -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ -defined(__OpenBSD__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include "lldb/Host/freebsd/Config.h" @@ -31,6 +30,10 @@ #include "lldb/Host/netbsd/Config.h" +#elif defined(__OpenBSD__) + +#include "lldb/Host/openbsd/Config.h" + #elif defined(__MINGW__) || defined(__MINGW32__) #include "lldb/Host/mingw/Config.h" Modified: lldb/trunk/include/lldb/Host/Editline.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=298810&r1=298809&r2=298810&view=diff == --- lldb/trunk/include/lldb/Host/Editline.h (original) +++ lldb/trunk/include/lldb/Host/Editline.h Sun Mar 26 10:34:57 2017 @@ -43,7 +43,8 @@ // will only be // used in cases where this is true. This is a compile time dependecy, for now // selected per target Platform -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ +defined(__OpenBSD__) #define LLDB_EDITLINE_USE_WCHAR 1 #include #else Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=298810&r1=298809&r2=298810&view=diff == --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Sun Mar 26 10:34:57 2017 @@ -185,7 +185,7 @@ public: static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info); #if (defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || \ - defined(__GLIBC__) || defined(__NetBSD__)) && \ + defined(__GLIBC__) || defined(__NetBSD__) || defined(__OpenBSD__)) && \ !defined(__ANDROID__) static short GetPosixspawnFlags(const ProcessLaunchInfo &launch_info); Modified:
[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD
krytarowski added a comment. In https://reviews.llvm.org/D31374#710864, @kettenis wrote: > On OpenBSD the register context used in core dumps uses the same layout as > ptrace(2). That's not the case on all OSes, but I believe that is the case > for NetBSD as well. Would it be possible to re-use the register context data > structures defined in the source/Plugins/Process/Utility/ directory? I will research it. Repository: rL LLVM https://reviews.llvm.org/D31374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD
krytarowski added a comment. Right now I'm not sure how to optimize reading GPR. If possible I would reschedule it for later. Repository: rL LLVM https://reviews.llvm.org/D31374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31335: Allow getCompiler to return None in the test suite
labath added a comment. This doesn't bother me too much, but i'm curious about how are you getting anything reasonable out of the test suite without a working compiler (?) https://reviews.llvm.org/D31335 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits