[Lldb-commits] [PATCH] D52532: Pull GetSoftwareBreakpointPCOffset into base class
krytarowski added a comment. I was wondering whether we want to normalize this inside the kernel and always advance the Program Counter.. but it's easier to manage it in userland. https://reviews.llvm.org/D52532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52532: Pull GetSoftwareBreakpointPCOffset into base class
krytarowski added a comment. In https://reviews.llvm.org/D52532#1250404, @labath wrote: > In https://reviews.llvm.org/D52532#1246173, @krytarowski wrote: > > > I was wondering whether we want to normalize this inside the kernel and > > always advance the Program Counter.. but it's easier to manage it in > > userland. > > > I am generally in favour of keeping the kernel simple, particularly when > ptrace is concerned. However, there is one difference in behaviour that > annoys me. Right now, if an application itself inserts a trap into it's > source code, on intel it will be easy to resume it from debugger simply by > continuing. OTOH, on arm, the user will have to manually update the PC first. > So I am not sure which is better here... Right now I defer this into future. We still need to fixup PC in kernel debuggers... on the other hand in order to advance the register manually on an arbitrary ISA we might need to guess instruction size. It's better to guess it in userland. Repository: rL LLVM https://reviews.llvm.org/D52532 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52941: NativeProcessProtocol: Simplify breakpoint setting code
krytarowski accepted this revision. krytarowski added a comment. This revision is now accepted and ready to land. The NetBSD part looks fine. I will be out of the office soon as I will visit California for GSoC Mentor Summit and MeetBSDCa (until October 23rd). https://reviews.llvm.org/D52941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52941: NativeProcessProtocol: Simplify breakpoint setting code
krytarowski added a comment. This looks fine to me. https://reviews.llvm.org/D52941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54135: Add convenience method in FileSystem to check if a path/filespec is a directory.
krytarowski added a comment. Why? We already put a lot of effort into reusing code from LLVM. Repository: rLLDB LLDB https://reviews.llvm.org/D54135 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54221: Add setting to require hardware breakpoints.
krytarowski added a comment. On NetBSD one has to check PaX MPROTECT property of a traced process. Something like: bool IsMPROTECT(pid_t pid) { #if defined(__NetBSD__) int mib[3]; int paxflags; size_t len = sizeof(paxflags); mib[0] = CTL_PROC; mib[1] = pid; mib[2] = PROC_PID_PAXFLAGS; if (sysctl(mib, 3, &paxflags, &len, NULL, 0) != 0) err(EXIT_FAILURE, "sysctl"); /* or return true */ return !!(paxflags & CTL_PROC_PAXFLAGS_MPROTECT); #else return false; #endif } If IsMPROTECT is true, then we must use hardware assisted/emulated breakpoints. Repository: rLLDB LLDB https://reviews.llvm.org/D54221 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D55706: ELF: more section creation cleanup
krytarowski edited reviewers, added: joerg; removed: krytarowski. krytarowski added a comment. I recommend joerg@ as a reviewer for ELF specifics. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55706/new/ https://reviews.llvm.org/D55706 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D56233: [lldb-server] Add initial support for building lldb-server on Windows
krytarowski added inline comments. Comment at: include/lldb/Host/windows/PosixApi.h:78 +#define WNOHANG 1 +#define WUNTRACED 2 I think that these symbols should not be leaked here in the first place. Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56233/new/ https://reviews.llvm.org/D56233 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47625: [cmake] Detect presence of wide-char libedit at build time
krytarowski added a comment. The original reason to switch NetBSD to wide characters was to unbreak the input parser. It used to mix wide and short characters. Typing unicode characters doesn't work well here too (before applying the patch): `(lldb) za\U+017C\U+0142\U+0107 g\U+0119\U+015Bl\U+0105 ja\U+017A\U+0144` https://reviews.llvm.org/D47625 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49110: [testsuite] Implement a category to skip libstdcxx tests
krytarowski added a comment. NetBSD ships with GCC style and Clang style userland. The former one ships with GNU libstdc++, the latter with libc++. Repository: rL LLVM https://reviews.llvm.org/D49110 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49110: [testsuite] Implement a category to skip libstdcxx tests
krytarowski added a comment. Probably the former with ship GDB at least for long time, the latter will switch to LLDB. Repository: rL LLVM https://reviews.llvm.org/D49110 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49110: [testsuite] Implement a category to skip libstdcxx tests
krytarowski added a comment. Through pkgsrc a user can install LLDB with either style of distribution, including GCC with libstdc++ one (I'm using this myself also for the development of LLVM related code). BTW. NetBSD uses GPLv3 GNU toolchain. Repository: rL LLVM https://reviews.llvm.org/D49110 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D39733: Simplify NativeProcessProtocol::GetArchitecture/GetByteOrder
krytarowski added a comment. The NetBSD part looks good. https://reviews.llvm.org/D39733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D39837: Clean up NativeRegisterContext
krytarowski added a comment. The NetBSD part looks fine. https://reviews.llvm.org/D39837 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D39681: Implement core dump debugging for PPC64le
krytarowski added inline comments. Comment at: source/Plugins/Process/elf-core/elf-core-enums.h:14 +/// Core files PT_NOTE segment descriptor types +enum { + NT_PRSTATUS = 1, No namespace here? https://reviews.llvm.org/D39681 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D39681: Implement core dump debugging for PPC64le
krytarowski added inline comments. Comment at: source/Plugins/Process/elf-core/elf-core-enums.h:14 +/// Core files PT_NOTE segment descriptor types +enum { + NT_PRSTATUS = 1, alexandreyy wrote: > krytarowski wrote: > > No namespace here? > I think these constants are used for multiple OSs. > Am I correct? > Do you have a suggestion for a namespace? There is rumor that they came from SVR4.. but I don't have the specs to make sure. Multiple in this case does not mean "all". This is not true for at least NetBSD. https://reviews.llvm.org/D39681 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D39681: Implement core dump debugging for PPC64le
krytarowski added inline comments. Comment at: source/Plugins/Process/elf-core/elf-core-enums.h:14 +/// Core files PT_NOTE segment descriptor types +enum { + NT_PRSTATUS = 1, alexandreyy wrote: > krytarowski wrote: > > alexandreyy wrote: > > > krytarowski wrote: > > > > No namespace here? > > > I think these constants are used for multiple OSs. > > > Am I correct? > > > Do you have a suggestion for a namespace? > > There is rumor that they came from SVR4.. but I don't have the specs to > > make sure. > > > > Multiple in this case does not mean "all". This is not true for at least > > NetBSD. > I can remove these constants and modify the first "if" in > ParseThreadContextsFromNoteSegment to: > > if (((note.n_type == LINUX::NT_PRSTATUS || > note.n_type == FREEBSD::NT_PRSTATUS) && have_prstatus) || > ((note.n_type == LINUX::NT_PRPSINFO || > note.n_type == FREEBSD::NT_PRPSINFO) && have_prpsinfo)) { > assert(thread_data->gpregset.GetByteSize() > 0); > > What do you think? > But NT_PRSTATUS and NT_PRPSINFO have the same value for Linux and FreeBSD . I propose to put NT_PRSTATUS, NT_PRFPREG, NT_PRPSINFO into this namespace and call it SVR4. SmartOS uses the same values. https://reviews.llvm.org/D39681 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D39681: Implement core dump debugging for PPC64le
krytarowski added inline comments. Comment at: source/Plugins/Process/elf-core/elf-core-enums.h:14 +/// Core files PT_NOTE segment descriptor types +enum { + NT_PRSTATUS = 1, labath wrote: > krytarowski wrote: > > alexandreyy wrote: > > > krytarowski wrote: > > > > alexandreyy wrote: > > > > > krytarowski wrote: > > > > > > No namespace here? > > > > > I think these constants are used for multiple OSs. > > > > > Am I correct? > > > > > Do you have a suggestion for a namespace? > > > > There is rumor that they came from SVR4.. but I don't have the specs to > > > > make sure. > > > > > > > > Multiple in this case does not mean "all". This is not true for at > > > > least NetBSD. > > > I can remove these constants and modify the first "if" in > > > ParseThreadContextsFromNoteSegment to: > > > > > > if (((note.n_type == LINUX::NT_PRSTATUS || > > > note.n_type == FREEBSD::NT_PRSTATUS) && have_prstatus) || > > > ((note.n_type == LINUX::NT_PRPSINFO || > > > note.n_type == FREEBSD::NT_PRPSINFO) && have_prpsinfo)) { > > > assert(thread_data->gpregset.GetByteSize() > 0); > > > > > > What do you think? > > > But NT_PRSTATUS and NT_PRPSINFO have the same value for Linux and FreeBSD > > > . > > I propose to put NT_PRSTATUS, NT_PRFPREG, NT_PRPSINFO into this namespace > > and call it SVR4. > > > > SmartOS uses the same values. > With the addition of all the bsd variants, the note parsing code has grown > pretty big. > > My plan was to refactor it a bit after this is committed. I wanted to split > it into two stages: first we just determine the OS from the notes; and then > we dispatch to an appropriate os-specific function to do the actual parsing > (with each function just using the NT constants from its own namespace). If > you agree with that direction then I propose to go with the > LINUX::NT_PRSTATUS || FREEBSD::NT_PRSTATUS proposed by alexandreyy in the > interim. Sounds good. https://reviews.llvm.org/D39681 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40133: elf-core: Convert remaining register context to use register set maps
krytarowski added a comment. Looks reasonable! I'm just thinking whether change code like `CoreRegset::PPC_VMX` to `CoreRegset::PPC::VMX`. I'm planning to add `CoreRegset::X86_64::XSAVE` in future. https://reviews.llvm.org/D40133 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40311: elf-core: Split up parsing code into os-specific functions
krytarowski added inline comments. Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:735 /// (see ELFNote structure) /// 3) A Thread Context in a core file usually described by 3 NOTE entries. ///a) NT_PRSTATUS - Register context Can we label it as SVR4-style (Linux, FreeBSD, Solaris)? Alternatively move it to other place in order to describe Linux and FreeBSD separately (NetBSD an OpenBSD can be skipped now). https://reviews.llvm.org/D40311 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.
krytarowski added a comment. Personally I prefer the original code as it looks easier to implement FSAVE. https://reviews.llvm.org/D41245 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.
krytarowski added a comment. In https://reviews.llvm.org/D41245#955462, @krytarowski wrote: > Personally I prefer the original code as it looks easier to implement FSAVE. Also naming FPR is more logical, reusing the XSAVE name for 32-bit x86 looks wrong to me. https://reviews.llvm.org/D41245 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.
krytarowski added a comment. I want to support x86 CPUs in 32-bit mode starting from 486. At least to read core dumps. This is the current bare minimum and tested setup by the releng team in NetBSD. OpenBSD used to support 80386 with MMU, but not sure if this is still true after migration to Clang. I've already implemented FPU checks in the existing code: - fpu_present (currently always on) - osfxsr - sse - sse2 - fpu_save (fsave, fxsave, xsave, xsaveopt) - fpu_save_sze - xsave_features Maybe reuse FPR for FXSAVE/FSAVE and add next to it XSAVE/XSAVE_OPT. On NetBSD/i386 FPR registers are for FSAVE through GET_FPREGS/SET_FPREGS. https://reviews.llvm.org/D41245 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.
krytarowski added a comment. In https://reviews.llvm.org/D41245#956644, @labath wrote: > In https://reviews.llvm.org/D41245#97, @krytarowski wrote: > > > Maybe reuse FPR for FXSAVE/FSAVE and add next to it XSAVE/XSAVE_OPT. > > > I am not sure what you mean by that, but I don't think it can work that way, > as xsave area already contains a copy of the fpu registers, so we will end up > having them twice. I have a feeling that for supporting fsave you will need > to define your own register context (or just handle the transformation at a > different layer -- this is how we avoided defining separate register context > for minidumps -- we just rearrange the registers around to match the existing > register context layout). I was thinking about split of FPU into two or more structs/unions. But the newer version on review is better! https://reviews.llvm.org/D41245 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42195: [lldb] Generic base for testing gdb-remote behavior
krytarowski added a comment. yaml2obj looks like a program from LLVM and we build and install it in pkgsrc. https://reviews.llvm.org/D42195 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42195: [lldb] Generic base for testing gdb-remote behavior
krytarowski added a comment. In the standalone build, we put yaml2obj into `$PREFIX/bin/`, so into the default `PATH` of the toolchain. https://reviews.llvm.org/D42195 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42488: Remove ObjectFile usage from HostLinux::GetProcessInfo
krytarowski added a comment. Looks fine. https://reviews.llvm.org/D42488 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42868: Fix a crash in *NetBSD::Factory::Launch
krytarowski created this revision. krytarowski added reviewers: labath, joerg. Herald added a subscriber: llvm-commits. krytarowski edited the summary of this revision. We cannot call process_up->SetState() inside the NativeProcessNetBSD::Factory::Launch function because it triggers a NULL pointer deference. The generic code for launching a process in: GDBRemoteCommunicationServerLLGS::LaunchProcess sets the m_debugged_process_up pointer after a successful call to m_process_factory.Launch(). If we attempt to call process_up->SetState() inside a platform specific Launch function we end up dereferencing a NULL pointer in NativeProcessProtocol::GetCurrentThreadID(). Follow the Linux case and move SetState() to: NativeProcessNetBSD::NativeProcessNetBSD. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D42868 Files: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -113,7 +113,6 @@ for (const auto &thread : process_up->m_threads) static_cast(*thread).SetStoppedBySignal(SIGSTOP); - process_up->SetState(StateType::eStateStopped); return std::move(process_up); } @@ -160,6 +159,8 @@ m_sigchld_handle = mainloop.RegisterSignal( SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status); assert(m_sigchld_handle && status.Success()); + + SetState(StateType::eStateStopped, false); } // Handles all waitpid events from the inferior process. Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -113,7 +113,6 @@ for (const auto &thread : process_up->m_threads) static_cast(*thread).SetStoppedBySignal(SIGSTOP); - process_up->SetState(StateType::eStateStopped); return std::move(process_up); } @@ -160,6 +159,8 @@ m_sigchld_handle = mainloop.RegisterSignal( SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status); assert(m_sigchld_handle && status.Success()); + + SetState(StateType::eStateStopped, false); } // Handles all waitpid events from the inferior process. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42868: Fix a crash in *NetBSD::Factory::Launch
krytarowski added a comment. (gdb) r Starting program: /public/llvm-build/bin/lldb-server g \*:1234 -- /usr/bin/look [New process 15150] Thread 1 received signal SIGSEGV, Segmentation fault. lldb_private::NativeProcessProtocol::GetCurrentThreadID (this=0x0) at /public/llvm/tools/lldb/include/lldb/Host/common/NativeProcessProtocol.h:178 178 lldb::tid_t GetCurrentThreadID() { return m_current_thread_id; } (gdb) bt #0 lldb_private::NativeProcessProtocol::GetCurrentThreadID (this=0x0) at /public/llvm/tools/lldb/include/lldb/Host/common/NativeProcessProtocol.h:178 #1 0x00600fab in lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SendStopReasonForState (this=0x7f7fddc0, process_state=lldb::eStateStopped) at /public/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:1641 #2 0x0060135a in lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped (this=0x7f7fddc0, process=0x7f7ff7b7c000) at /public/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:835 #3 0x006014d1 in lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::ProcessStateChanged (this=0x7f7fddc0, process=0x7f7ff7b7c000, state=lldb::eStateStopped) at /public/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:870 #4 0x005412e1 in lldb_private::NativeProcessProtocol::SynchronouslyNotifyProcessStateChanged (this=0x7f7ff7b7c000, state=lldb::eStateStopped) at /public/llvm/tools/lldb/source/Host/common/NativeProcessProtocol.cpp:336 #5 0x00542e5f in lldb_private::NativeProcessProtocol::SetState (this=0x7f7ff7b7c000, state=lldb::eStateStopped, notify_delegates=true) at /public/llvm/tools/lldb/source/Host/common/NativeProcessProtocol.cpp:422 #6 0x0059fc77 in lldb_private::process_netbsd::NativeProcessNetBSD::Factory::Launch (this=0x7f7fe3a8, launch_info=..., native_delegate=..., mainloop=...) at /public/llvm/tools/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:114 #7 0x005fd82a in lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::LaunchProcess (this=0x7f7fddc0) at /public/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:233 #8 0x00418e16 in handle_launch (gdb_server=..., argc=1, argv=0x7f7fe6f8) at /public/llvm/tools/lldb/tools/lldb-server/lldb-gdbserver.cpp:195 #9 0x0041a228 in main_gdbserver (argc=1, argv=0x7f7fe6f8) at /public/llvm/tools/lldb/tools/lldb-server/lldb-gdbserver.cpp:525 #10 0x0041befd in main (argc=5, argv=0x7f7fe6d8) at /public/llvm/tools/lldb/tools/lldb-server/lldb-server.cpp:58 (gdb) Repository: rL LLVM https://reviews.llvm.org/D42868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42870: Correct recognition of NetBSD images
krytarowski added a comment. Extracted from: https://reviews.llvm.org/D32149. Repository: rL LLVM https://reviews.llvm.org/D42870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42870: Correct recognition of NetBSD images
krytarowski created this revision. krytarowski added reviewers: joerg, labath. Herald added subscribers: llvm-commits, emaste. Split the recognition into NetBSD executables & shared libraries and core(5) files. Introduce new owner type: "NetBSD-CORE", as core(5) files are not tagged in the same way as regular NetBSD executables. Stop using incorrectly ABI_TAG and ABI_SIZE. Introduce IDENT_TAG, IDENT_DECSZ, IDENT_NAMESZ and PROCINFO. The new values detects correctly the NetBSD images. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D42870 Files: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -53,6 +53,7 @@ const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD"; const char *const LLDB_NT_OWNER_GNU = "GNU"; const char *const LLDB_NT_OWNER_NETBSD = "NetBSD"; +const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE"; const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD"; const char *const LLDB_NT_OWNER_CSR = "csr"; const char *const LLDB_NT_OWNER_ANDROID = "Android"; @@ -68,8 +69,10 @@ const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03; -const elf_word LLDB_NT_NETBSD_ABI_TAG = 0x01; -const elf_word LLDB_NT_NETBSD_ABI_SIZE = 4; +const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_TAG = 1; +const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_DESCSZ = 4; +const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_NAMESZ = 7; +const elf_word LLDB_NT_NETBSD_NT_PROCINFO = 1; // GNU ABI note OS constants const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00; @@ -1335,25 +1338,41 @@ // The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); } -// Process NetBSD ELF notes. +// Process NetBSD ELF executables and shared libraries else if ((note.n_name == LLDB_NT_OWNER_NETBSD) && - (note.n_type == LLDB_NT_NETBSD_ABI_TAG) && - (note.n_descsz == LLDB_NT_NETBSD_ABI_SIZE)) { - // Pull out the min version info. + (note.n_type == LLDB_NT_NETBSD_NT_NETBSD_IDENT_TAG) && + (note.n_descsz == LLDB_NT_NETBSD_NT_NETBSD_IDENT_DESCSZ) && + (note.n_namesz == LLDB_NT_NETBSD_NT_NETBSD_IDENT_NAMESZ)) { + // Pull out the version info. uint32_t version_info; if (data.GetU32(&offset, &version_info, 1) == nullptr) { error.SetErrorString("failed to read NetBSD ABI note payload"); return error; } - + // Convert the version info into a major/minor/patch number. + // #define __NetBSD_Version__ MMmmrrpp00 + // + // M = major version + // m = minor version; a minor number of 99 indicates current. + // r = 0 (since NetBSD 3.0 not used) + // p = patchlevel + const uint32_t version_major = version_info / 1; + const uint32_t version_minor = (version_info % 1) / 100; + const uint32_t version_patch = (version_info % 1) / 100; + char os_name[32]; + snprintf(os_name, sizeof(os_name), + "netbsd%" PRIu32 ".%" PRIu32 ".%" PRIu32, version_major, + version_minor, version_patch); + // Set the elf OS version to NetBSD. Also clear the vendor. + arch_spec.GetTriple().setOSName(os_name); + arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor); +} +// Process NetBSD ELF core(5) notes +else if ((note.n_name == LLDB_NT_OWNER_NETBSDCORE) && + (note.n_type == LLDB_NT_NETBSD_NT_PROCINFO)) { // Set the elf OS version to NetBSD. Also clear the vendor. arch_spec.GetTriple().setOS(llvm::Triple::OSType::NetBSD); arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor); - - if (log) -log->Printf( -"ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32, -__FUNCTION__, version_info); } // Process OpenBSD ELF notes. else if (note.n_name == LLDB_NT_OWNER_OPENBSD) { Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -53,6 +53,7 @@ const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD"; const char *const LLDB_NT_OWNER_GNU = "GNU"; const char *const LLDB_NT_OWNER_NETBSD = "NetBSD"; +const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE"; const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD"; const char *const LLDB_NT_OWNER_CSR = "csr"; const char *const LLDB_NT_OWNER_ANDROID = "Android"; @@ -68,8 +69,10 @@ const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03; -const elf_word LLDB_NT_NETBSD_ABI_TAG = 0x01; -const elf_word LLDB_NT_NETBSD_ABI_SIZE = 4; +const elf_word LLDB_NT_NETBSD_NT
[Lldb-commits] [PATCH] D42868: Fix a crash in *NetBSD::Factory::Launch
krytarowski added inline comments. Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:116 static_cast(*thread).SetStoppedBySignal(SIGSTOP); - process_up->SetState(StateType::eStateStopped); Another option is to call: ``` process_up->SetState(StateType::eStateStopped, false); ``` Both work. Repository: rL LLVM https://reviews.llvm.org/D42868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42868: Fix a crash in *NetBSD::Factory::Launch
krytarowski updated this revision to Diff 132689. Repository: rL LLVM https://reviews.llvm.org/D42868 Files: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -113,7 +113,7 @@ for (const auto &thread : process_up->m_threads) static_cast(*thread).SetStoppedBySignal(SIGSTOP); - process_up->SetState(StateType::eStateStopped); + process_up->SetState(StateType::eStateStopped, false); return std::move(process_up); } Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -113,7 +113,7 @@ for (const auto &thread : process_up->m_threads) static_cast(*thread).SetStoppedBySignal(SIGSTOP); - process_up->SetState(StateType::eStateStopped); + process_up->SetState(StateType::eStateStopped, false); return std::move(process_up); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42870: Correct recognition of NetBSD images
krytarowski added a comment. What would the test do? Repository: rL LLVM https://reviews.llvm.org/D42870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42870: Correct recognition of NetBSD images
krytarowski added a comment. Is there a working example of this? I would clone an existing code for Linux or other supported OS and adapt it for NetBSD. Please note that I'm in the process of restoration LLDB (lldb-server) so I cannot execute regular tests, at least in close time. Repository: rL LLVM https://reviews.llvm.org/D42870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42912: Sync PlatformNetBSD.cpp with Linux
krytarowski created this revision. krytarowski added reviewers: labath, joerg. Herald added a subscriber: llvm-commits. Various changes in logging from log->Printf() to generic LLDB_LOG(). Sponsored by Repository: rL LLVM https://reviews.llvm.org/D42912 Files: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp === --- source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -45,19 +45,9 @@ PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); - if (log) { -const char *arch_name; -if (arch && arch->GetArchitectureName()) - arch_name = arch->GetArchitectureName(); -else - arch_name = ""; - -const char *triple_cstr = -arch ? arch->GetTriple().getTriple().c_str() : ""; - -log->Printf("PlatformNetBSD::%s(force=%s, arch={%s,%s})", __FUNCTION__, -force ? "true" : "false", arch_name, triple_cstr); - } + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); bool create = force; if (create == false && arch && arch->IsValid()) { @@ -72,18 +62,10 @@ } } + LLDB_LOG(log, "create = {0}", create); if (create) { -if (log) - log->Printf("PlatformNetBSD::%s() creating remote-netbsd platform", - __FUNCTION__); return PlatformSP(new PlatformNetBSD(false)); } - - if (log) -log->Printf( -"PlatformNetBSD::%s() aborting creation of remote-netbsd platform", -__FUNCTION__); - return PlatformSP(); } @@ -258,19 +240,15 @@ } // For local debugging, NetBSD will override the debug logic to use llgs-launch -// rather than -// lldb-launch, llgs-attach. This differs from current lldb-launch, -// debugserver-attach -// approach on MacOSX. -lldb::ProcessSP PlatformNetBSD::DebugProcess( -ProcessLaunchInfo &launch_info, Debugger &debugger, -Target *target, // Can be NULL, if NULL create a new -// target, else use existing one -Status &error) { +// rather than lldb-launch, llgs-attach. This differs from current lldb-launch, +// debugserver-attach approach on MacOSX. +lldb::ProcessSP +PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, + Target *target, // Can be NULL, if NULL create a new + // target, else use existing one + Status &error) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); - if (log) -log->Printf("PlatformNetBSD::%s entered (target %p)", __FUNCTION__, -static_cast(target)); + LLDB_LOG(log, "target {0}", target); // If we're a remote host, use standard behavior from parent class. if (!IsHost()) @@ -293,79 +271,57 @@ // Ensure we have a target. if (target == nullptr) { -if (log) - log->Printf("PlatformNetBSD::%s creating new target", __FUNCTION__); - +LLDB_LOG(log, "creating new target"); TargetSP new_target_sp; error = debugger.GetTargetList().CreateTarget(debugger, "", "", false, nullptr, new_target_sp); if (error.Fail()) { - if (log) -log->Printf("PlatformNetBSD::%s failed to create new target: %s", -__FUNCTION__, error.AsCString()); + LLDB_LOG(log, "failed to create new target: {0}", error); return process_sp; } target = new_target_sp.get(); if (!target) { error.SetErrorString("CreateTarget() returned nullptr"); - if (log) -log->Printf("PlatformNetBSD::%s failed: %s", __FUNCTION__, -error.AsCString()); + LLDB_LOG(log, "error: {0}", error); return process_sp; } - } else { -if (log) - log->Printf("PlatformNetBSD::%s using provided target", __FUNCTION__); } // Mark target as currently selected target. debugger.GetTargetList().SetSelectedTarget(target); // Now create the gdb-remote process. - if (log) -log->Printf( -"PlatformNetBSD::%s having target create process with gdb-remote plugin", -__FUNCTION__); + LLDB_LOG(log, "having target create process with gdb-remote plugin"); process_sp = target->CreateProcess( launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr); if (!process_sp) { error.SetErrorString("CreateProcess() failed for gdb-remote process"); -if (log) - log->Printf("PlatformNetBSD::%s failed: %s", __FUNCTION__, - error.AsCString()); +LLDB_LOG(log, "error: {0}", error); return process_sp; - } else { -if (log) - log->Printf("PlatformNetBSD::%s successfully created process", -
[Lldb-commits] [PATCH] D42870: Correct recognition of NetBSD images
krytarowski planned changes to this revision. krytarowski added a comment. Herald added a subscriber: arichardson. I will be back to this once I will be done with debugging client-server connectivity issues (unrelated to this patch). Repository: rL LLVM https://reviews.llvm.org/D42870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43698: Plug errno in TCPSocket::Connect()
krytarowski created this revision. krytarowski added reviewers: labath, joerg. krytarowski added a project: LLDB. Herald added a subscriber: llvm-commits. Reset errno to 0 for error branches. Without this, debugging real issues in LLDB is harder as we don't know what and when caused the errno to be set. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D43698 Files: source/Host/common/TCPSocket.cpp Index: source/Host/common/TCPSocket.cpp === --- source/Host/common/TCPSocket.cpp +++ source/Host/common/TCPSocket.cpp @@ -146,14 +146,17 @@ host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); for (auto address : addresses) { error = CreateSocket(address.GetFamily()); -if (error.Fail()) +if (error.Fail()) { + errno = 0; continue; +} address.SetPort(port); if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(), address.GetLength())) { CLOSE_SOCKET(GetNativeSocket()); + errno = 0; continue; } Index: source/Host/common/TCPSocket.cpp === --- source/Host/common/TCPSocket.cpp +++ source/Host/common/TCPSocket.cpp @@ -146,14 +146,17 @@ host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); for (auto address : addresses) { error = CreateSocket(address.GetFamily()); -if (error.Fail()) +if (error.Fail()) { + errno = 0; continue; +} address.SetPort(port); if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(), address.GetLength())) { CLOSE_SOCKET(GetNativeSocket()); + errno = 0; continue; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43698: Plug errno in TCPSocket::Connect()
krytarowski added a comment. This just helps debugging connectivity issues in other unrelated code-parts (I'm debugging why `select`(2) / `recv`(2) don't receive a packet of type `qHostInfo`). Floating errno is annoying. `TCPSocket::Connect()` has no bugs at least I'm not aware of them. Repository: rL LLVM https://reviews.llvm.org/D43698 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43698: Plug errno in TCPSocket::Connect()
krytarowski added a comment. https://github.com/search?l=C&q=save_errno&ref=opensearch&type=Code Here is an approach with `save_errno`, useful in libraries when we preserve errno for public functions in the API of a library as-is, and not leaking it from the internals to unrelated code. Right now I don't volunteer to perform this for LLDB, but it would be nice to not propagate it. Repository: rL LLVM https://reviews.llvm.org/D43698 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43698: Plug errno in TCPSocket::Connect()
krytarowski abandoned this revision. krytarowski added a comment. This is considered to be a local patch. Repository: rL LLVM https://reviews.llvm.org/D43698 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44056: [lldb] Fix "code unreachable" warning in HostThreadPosix::Cancel
krytarowski added a comment. `::pthread_cancel` is available for NetBSD as well. https://reviews.llvm.org/D44056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44379: [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687)
krytarowski added inline comments. Comment at: cmake/modules/LLDBConfig.cmake:354 + + check_library_exists(dl dlopen "" HAVE_LIBDL) + if (HAVE_LIBDL) A more portable form of this: ``` foreach(lib ${CMAKE_DL_LIBS}) list(APPEND system_libs -l${lib}) endforeach() ``` Haiku needs 2 libraries, other Unices can use `-lldl` or similar. https://reviews.llvm.org/D44379 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44379: [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687)
krytarowski added inline comments. Comment at: cmake/modules/LLDBConfig.cmake:354 + + check_library_exists(dl dlopen "" HAVE_LIBDL) + if (HAVE_LIBDL) mgorny wrote: > krytarowski wrote: > > A more portable form of this: > > > > ``` > > foreach(lib ${CMAKE_DL_LIBS}) > > list(APPEND system_libs -l${lib}) > > endforeach() > > ``` > > > > Haiku needs 2 libraries, other Unices can use `-lldl` or similar. > Didn't this raise the problem of cmake using full paths on some systems? No. https://reviews.llvm.org/D44379 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44379: [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687)
krytarowski added inline comments. Comment at: cmake/modules/LLDBConfig.cmake:354 + + check_library_exists(dl dlopen "" HAVE_LIBDL) + if (HAVE_LIBDL) labath wrote: > krytarowski wrote: > > mgorny wrote: > > > krytarowski wrote: > > > > A more portable form of this: > > > > > > > > ``` > > > > foreach(lib ${CMAKE_DL_LIBS}) > > > > list(APPEND system_libs -l${lib}) > > > > endforeach() > > > > ``` > > > > > > > > Haiku needs 2 libraries, other Unices can use `-lldl` or similar. > > > Didn't this raise the problem of cmake using full paths on some systems? > > No. > Do you have some reference for the portability claim? (mainly because I'm > trying to learn more about how cmake works, but also because I'd rather let > cmake figure out when to prepend -l instead of doing it myself). > > I don't see how the "two libraries" thingy comes into play here. It could be > a problem if we are mismatching lists and strings but I don't see why that > would necessitate manually tagging with -l. dlopen(3)-like functions in `-ldl` is Linux; HPUX uses `-ldl`, Darwin/BSDs no extra libraries, Haiku `-lroot -lbe` etc. https://github.com/Kitware/CMake/search?p=2&q=CMAKE_DL_LIBS&type=&utf8=%E2%9C%93 I know that we don't support multiple OSes as of today, but we can make it compatible with every recognizable one with this change. It looks like the proper syntax is to drop `-l` from my first proposal: ``` foreach(lib ${CMAKE_DL_LIBS}) list(APPEND system_libs ${lib}) endforeach() ``` https://reviews.llvm.org/D44379 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44379: [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687)
krytarowski added inline comments. Comment at: cmake/modules/LLDBConfig.cmake:354 + + check_library_exists(dl dlopen "" HAVE_LIBDL) + if (HAVE_LIBDL) krytarowski wrote: > labath wrote: > > krytarowski wrote: > > > mgorny wrote: > > > > krytarowski wrote: > > > > > A more portable form of this: > > > > > > > > > > ``` > > > > > foreach(lib ${CMAKE_DL_LIBS}) > > > > > list(APPEND system_libs -l${lib}) > > > > > endforeach() > > > > > ``` > > > > > > > > > > Haiku needs 2 libraries, other Unices can use `-lldl` or similar. > > > > Didn't this raise the problem of cmake using full paths on some > > > > systems? > > > No. > > Do you have some reference for the portability claim? (mainly because I'm > > trying to learn more about how cmake works, but also because I'd rather let > > cmake figure out when to prepend -l instead of doing it myself). > > > > I don't see how the "two libraries" thingy comes into play here. It could > > be a problem if we are mismatching lists and strings but I don't see why > > that would necessitate manually tagging with -l. > dlopen(3)-like functions in `-ldl` is Linux; HPUX uses `-ldl`, Darwin/BSDs no > extra libraries, Haiku `-lroot -lbe` etc. > > https://github.com/Kitware/CMake/search?p=2&q=CMAKE_DL_LIBS&type=&utf8=%E2%9C%93 > > I know that we don't support multiple OSes as of today, but we can make it > compatible with every recognizable one with this change. > > It looks like the proper syntax is to drop `-l` from my first proposal: > > ``` > foreach(lib ${CMAKE_DL_LIBS}) > list(APPEND system_libs ${lib}) > endforeach() > ``` Or perhaps even unconditional: `list(APPEND system_libs ${CMAKE_DL_LIBS})` https://reviews.llvm.org/D44379 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44379: [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687)
krytarowski added inline comments. Comment at: cmake/modules/LLDBConfig.cmake:349 -if (HAVE_LIBPTHREAD) - list(APPEND system_libs pthread) -endif(HAVE_LIBPTHREAD) - -if (HAVE_LIBDL) - list(APPEND system_libs ${CMAKE_DL_LIBS}) +if(UNIX) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) Why UNIX here? Why CMAKE_THREAD_PREFER_PTHREAD? It looks like used only on IRIX and that one is not going anywhere nowadays. (And certainly similarly to other commercial OSes, due to legal work/removing not-owned code, it's not possible to push it to Open-Source). Assuming that system_libs can accept "-pthreads", this patch looks good to me. https://reviews.llvm.org/D44379 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D44379: [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687)
krytarowski accepted this revision. krytarowski added a comment. This revision is now accepted and ready to land. I cannot test it shortly on NetBSD, but if there are any issues left (probably none) - I will fix it in future. Comment at: cmake/modules/LLDBConfig.cmake:349 -if (HAVE_LIBPTHREAD) - list(APPEND system_libs pthread) -endif(HAVE_LIBPTHREAD) - -if (HAVE_LIBDL) - list(APPEND system_libs ${CMAKE_DL_LIBS}) +if(UNIX) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) labath wrote: > krytarowski wrote: > > Why UNIX here? > > > > Why CMAKE_THREAD_PREFER_PTHREAD? It looks like used only on IRIX and that > > one is not going anywhere nowadays. (And certainly similarly to other > > commercial OSes, due to legal work/removing not-owned code, it's not > > possible to push it to Open-Source). > > > > Assuming that system_libs can accept "-pthreads", this patch looks good to > > me. > For the second part, I copied it out of the llvm's build scripts without > looking at what it does (with the idea of trying to maintain a consistent > build). However, if it's only used at irix, then I guess I can remove that. > > The UNIX part is also inspired by llvm, but I simplified it a bit (they use > CYGWIN OR NOT WINDOWS). I was assuming the idea was to make sure we use > native thread support and not pthreads (which are present there sometimes, I > think). I see, I would use `CYGWIN OR NOT WINDOWS` without changing the logic. Keeping here `CMAKE_THREAD_PREFER_PTHREAD` does not make harm. non-pthreading on UNIX systems is rather in extinct and remnant of 90ties (Minix has something like that.. and lack of pthreads). The UNIX part looks correct. https://reviews.llvm.org/D44379 ___ 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. Fantastic! I got a substantial portion of Process Plugin to work on NetBSD, to coordinate the work feel free to join IRC `#lldb` at OFTC -- e.g. do not waste time on FreeBSD Process Plugin. Demo: http://www.netbsd.org/~kamil/lldb/hello2.txt I'm working on on remaining few features in order to upstream them. Comment at: source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp:60 + +#if defined(__FreeBSD__) || defined(__OpenBSD__) +// Only accept "unknown" for the OS if the host is BSD and Please delete `__FreeBSD__` here and from the FreeBSD platform switch for `__OpenBSD__`, but I don't insist on doing the FreeBSD tweak within the same commit. Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:588 + } +} else if (strncmp(note.n_name.c_str(), "OpenBSD", 7) == 0) { + m_os = llvm::Triple::OpenBSD; `note.n_name == "OpenBSD"` ? Comment at: source/Plugins/Process/elf-core/ThreadElfCore.cpp:114 + +case llvm::Triple::OpenBSD: { + switch (arch.GetMachine()) { I would consider to keep it sorted - after Linux. 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] D31131: [LLDB] OpenBSD support
krytarowski added inline comments. Comment at: source/Host/openbsd/Host.cpp:223 + +#if 0 +lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) { Wasn't it already gone from there? Repository: rL LLVM 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] D31131: [LLDB] OpenBSD support
krytarowski added inline comments. Comment at: include/lldb/Host/Config.h:35 + +#include "lldb/Host/openbsd/Config.h" Missing in patch? Repository: rL LLVM 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] D31131: [LLDB] OpenBSD support
krytarowski added inline comments. Comment at: include/lldb/Host/Config.h:35 + +#include "lldb/Host/openbsd/Config.h" krytarowski wrote: > Missing in patch? I think that Config.h should go away. It's almost empty. But it's beyond the scope of this patch. While there I would sort this list of includes again. Comment at: include/lldb/Host/HostInfo.h:55 +#elif defined(__OpenBSD__) +#include "lldb/Host/openbsd/HostInfoOpenBSD.h" +#define HOST_INFO_TYPE HostInfoOpenBSD I would sort includes here. Repository: rL LLVM 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] D31131: [LLDB] OpenBSD support
krytarowski added inline comments. Comment at: source/Plugins/Platform/CMakeLists.txt:8 +#elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") + add_subdirectory(OpenBSD) #elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") I would sort by subdirectory. Repository: rL LLVM 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] D31131: [LLDB] OpenBSD support
krytarowski added inline comments. Comment at: include/lldb/Host/HostInfo.h:55 +#elif defined(__OpenBSD__) +#include "lldb/Host/openbsd/HostInfoOpenBSD.h" +#define HOST_INFO_TYPE HostInfoOpenBSD kettenis wrote: > krytarowski wrote: > > I would sort includes here. > Do you want me to sort the entire list? Yes, here and in other places as well. We might get more targets and it's better to keep it in order. Comment at: source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp:158 +case 1: + triple.setArchName("i386"); + break; kettenis wrote: > labath wrote: > > As far as I can tell, you're only adding x86_64 support, so you should > > probably remove the others. > True. I trimmed the list that FreeBSD had. My intention is to submit > support for all these architectures. But I can leave the currently > unsupported ones out. This is what I'm doing in NetBSD. Adding x86_64 first, i386 next and later the rest -- perhaps starting with arm 32-bit. Repository: rL LLVM 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] D31132: Add NetBSD case in Entry::Type::ThreadID
krytarowski created this revision. krytarowski added a project: LLDB. NetBSD native threads are printed as 64-bit unsigned integers. The underlying system type of a thread identity is lwpid_t of type int32_t. For consistency with Linux and FreeBSD share the 64-bit unsigned integer type. Repository: rL LLVM https://reviews.llvm.org/D31132 Files: source/Core/FormatEntity.cpp Index: source/Core/FormatEntity.cpp === --- source/Core/FormatEntity.cpp +++ source/Core/FormatEntity.cpp @@ -1187,7 +1187,8 @@ ? arch.GetTriple().getOS() : llvm::Triple::UnknownOS; if ((ostype == llvm::Triple::FreeBSD) || -(ostype == llvm::Triple::Linux)) { +(ostype == llvm::Triple::Linux) || +(ostype == llvm::Triple::NetBSD)) { format = "%" PRIu64; } } else { Index: source/Core/FormatEntity.cpp === --- source/Core/FormatEntity.cpp +++ source/Core/FormatEntity.cpp @@ -1187,7 +1187,8 @@ ? arch.GetTriple().getOS() : llvm::Triple::UnknownOS; if ((ostype == llvm::Triple::FreeBSD) || -(ostype == llvm::Triple::Linux)) { +(ostype == llvm::Triple::Linux) || +(ostype == llvm::Triple::NetBSD)) { format = "%" PRIu64; } } else { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31138: Add stub for PluginProcessNetBSD
krytarowski created this revision. krytarowski added a project: LLDB. Herald added a subscriber: mgorny. This is the base for introduction of further features to support Process Tracing on NetBSD, in local and remote setup. This code contains stubs of the needed functions. Their bodies will be added in next commits. The layout of functions is not set in stone and can be changed in future, however the current one with set of local patches to fill the missing function bodies was used to handle functional debugging session. This code is also a starting point to synchronize the development with other BSDs, Currently only NetBSD is ahead and other can catch up. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31138 Files: source/Plugins/Process/CMakeLists.txt 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/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h tools/lldb-server/CMakeLists.txt Index: tools/lldb-server/CMakeLists.txt === --- tools/lldb-server/CMakeLists.txt +++ tools/lldb-server/CMakeLists.txt @@ -17,6 +17,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" ) include_directories( ../../../../llvm/include + ../../source/Plugins/Process/NetBSD ../../source/Plugins/Process/POSIX ) endif () Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -0,0 +1,84 @@ +//===-- NativeThreadNetBSD.h -- -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef liblldb_NativeThreadNetBSD_H_ +#define liblldb_NativeThreadNetBSD_H_ + +#include "lldb/Host/common/NativeThreadProtocol.h" + +namespace lldb_private { +namespace process_netbsd { + +class NativeProcessNetBSD; + +class NativeThreadNetBSD : public NativeThreadProtocol { + friend class NativeProcessNetBSD; + +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 SetStoppedByExec(); + + void SetStoppedByTrace(); + + void SetStoppedByBreakpoint(); + + void SetRunning(); + + void SetStepping(); + + // - + // Private interface + // - + NativeProcessNetBSD &GetProcess(); + + void SetStopped(); + + // - + // 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; +} // namespace process_netbsd +} // namespace lldb_private + +#endif // #ifndef liblldb_NativeThreadNetBSD_H_ Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -0,0 +1,97 @@ +//===-- NativeThreadNetBSD.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===
[Lldb-commits] [PATCH] D31138: Add stub for PluginProcessNetBSD
krytarowski added a comment. I have got a few local changes that conflict with https://reviews.llvm.org/D31131, this is why I will hold on them unless @kettenis does not intend to land his patch in the coming days. Repository: rL LLVM https://reviews.llvm.org/D31138 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31146: Enable AUXV and QPassSignals in gdb-remote for NetBSD
krytarowski created this revision. krytarowski added a project: LLDB. NetBSD is an ELF platform and it uses Elf Auxiliary Vector like Linux and other modern BSDs. While there enable QPassSignals for the NetBSD port as well. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31146 Files: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -2665,7 +2665,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read( StringExtractorGDBRemote &packet) { // *BSD impls should be able to do this too. -#if defined(__linux__) +#if defined(__linux__) || defined(__NetBSD__) Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS)); // Parse out the offset. Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -838,7 +838,7 @@ response.PutCString(";QThreadSuffixSupported+"); response.PutCString(";QListThreadsInStopReply+"); response.PutCString(";qEcho+"); -#if defined(__linux__) +#if defined(__linux__) || defined(__NetBSD__) response.PutCString(";QPassSignals+"); response.PutCString(";qXfer:auxv:read+"); #endif Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -2665,7 +2665,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read( StringExtractorGDBRemote &packet) { // *BSD impls should be able to do this too. -#if defined(__linux__) +#if defined(__linux__) || defined(__NetBSD__) Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS)); // Parse out the offset. Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -838,7 +838,7 @@ response.PutCString(";QThreadSuffixSupported+"); response.PutCString(";QListThreadsInStopReply+"); response.PutCString(";qEcho+"); -#if defined(__linux__) +#if defined(__linux__) || defined(__NetBSD__) response.PutCString(";QPassSignals+"); response.PutCString(";qXfer:auxv:read+"); #endif ___ 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 inline comments. Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:588 + } +} else if (strncmp(note.n_name.c_str(), "OpenBSD", 7) == 0) { + m_os = llvm::Triple::OpenBSD; kettenis wrote: > krytarowski wrote: > > `note.n_name == "OpenBSD"` ? > That wouldn't work. The notes describing the registers have the thread ID > attached to this name, i.e. "OpenBSD@250037". I'll need to parse that string > to make core dumps of multi-threaded processes work later. I would change it o `string::substr` to make it more clear that it's not just secure comparison of a string. A comment explaining it for those not familiar with OpenBSD internals would be nice. Repository: rL LLVM 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] D31138: Add stub for PluginProcessNetBSD
krytarowski added a comment. In https://reviews.llvm.org/D31138#706216, @labath wrote: > I like the idea of adding boilerplate first, so that we can than better focus > on the important stuff later. However, I think you've have gone a bit too far > with it -- you introduce a lot of functions I am pretty sure will not be > necessary for your case, or that should be handled differently (software > single stepping stuff, handling of linux thread stopping, ...). > > Could we trim this down to just the functions that are necessary to get this > building (basically just virtual overrides -- no private functions or > members)? Those can be always added along with the patch that implements > them, and then we will be in a better position to review it. I will go for it. Your idea is good. I originally planned to trim unneeded chunks afterwards, but this direction is cleaner. Repository: rL LLVM https://reviews.llvm.org/D31138 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31146: Enable AUXV and QPassSignals in gdb-remote for NetBSD
krytarowski added a comment. I'm still evaluating whether to implement on the kernel side `PT_SET_SIGPASS`/`PT_GET_SIGPASS`. Some software like floating point can use it heavily. Repository: rL LLVM https://reviews.llvm.org/D31146 ___ 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 inline comments. Comment at: source/Host/openbsd/HostInfoOpenBSD.cpp:20 + +uint32_t HostInfoOpenBSD::GetMaxThreadNameLength() { return 16; } + The need for this has been removed in trunk. Repository: rL LLVM 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] D31138: Add stub for PluginProcessNetBSD
krytarowski updated this revision to Diff 92492. krytarowski added a comment. Style fix. Repository: rL LLVM https://reviews.llvm.org/D31138 Files: source/Plugins/Process/CMakeLists.txt 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/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h tools/lldb-server/CMakeLists.txt Index: tools/lldb-server/CMakeLists.txt === --- tools/lldb-server/CMakeLists.txt +++ tools/lldb-server/CMakeLists.txt @@ -17,6 +17,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" ) include_directories( ../../../../llvm/include + ../../source/Plugins/Process/NetBSD ../../source/Plugins/Process/POSIX ) endif () Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -0,0 +1,31 @@ +//===-- NativeThreadNetBSD.h -- -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef liblldb_NativeThreadNetBSD_H_ +#define liblldb_NativeThreadNetBSD_H_ + +#include "lldb/Host/common/NativeThreadProtocol.h" + +namespace lldb_private { +namespace process_netbsd { + +class NativeProcessNetBSD; + +class NativeThreadNetBSD : public NativeThreadProtocol { + friend class NativeProcessNetBSD; + +public: + NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid); +}; + +typedef std::shared_ptr NativeThreadNetBSDSP; +} // namespace process_netbsd +} // namespace lldb_private + +#endif // #ifndef liblldb_NativeThreadNetBSD_H_ Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -0,0 +1,21 @@ +//===-- NativeThreadNetBSD.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "NativeThreadNetBSD.h" +#include "NativeRegisterContextNetBSD.h" + +#include "NativeProcessNetBSD.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) {} Index: source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h @@ -0,0 +1,41 @@ +//===-- NativeRegisterContextNetBSD.h ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef lldb_NativeRegisterContextNetBSD_h +#define lldb_NativeRegisterContextNetBSD_h + +#include "lldb/Host/common/NativeRegisterContextRegisterInfo.h" +#include "lldb/Host/common/NativeThreadProtocol.h" + +#include "Plugins/Process/NetBSD/NativeProcessNetBSD.h" + +namespace lldb_private { +namespace process_netbsd { + +class NativeRegisterContextNetBSD : public NativeRegisterContextRegisterInfo { +public: + NativeRegisterContextNetBSD(NativeThreadProtocol &native_thread, + uint32_t concrete_frame_idx, + RegisterInfoInterface *reg_info_interface_p); + + // This function is implemented in the NativeRegisterContextNetBSD_* + // subclasses to create a new instance of the host specific + // NativeRegisterContextNetBSD. The implementations can't collide as only one + // NativeRegisterContextNetBSD_* variant should be compiled into the final + // executable. + static NativeRegisterContextNetBSD * + CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch, +NativeThreadProtocol &native_thread, +uint32_t concrete_frame_idx); +}; + +} // namespace process_netbsd +} // namespace lldb_private + +#endif // #ifndef lldb_NativeRegisterContextNetBSD_h Index: source/Plugin
[Lldb-commits] [PATCH] D31138: Add stub for PluginProcessNetBSD
krytarowski updated this revision to Diff 92490. krytarowski edited the summary of this revision. krytarowski added a comment. Cut down the unused functions from the Native Process NetBSD Plugin. Repository: rL LLVM https://reviews.llvm.org/D31138 Files: source/Plugins/Process/CMakeLists.txt 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/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h tools/lldb-server/CMakeLists.txt Index: tools/lldb-server/CMakeLists.txt === --- tools/lldb-server/CMakeLists.txt +++ tools/lldb-server/CMakeLists.txt @@ -17,6 +17,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" ) include_directories( ../../../../llvm/include + ../../source/Plugins/Process/NetBSD ../../source/Plugins/Process/POSIX ) endif () Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -0,0 +1,31 @@ +//===-- NativeThreadNetBSD.h -- -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef liblldb_NativeThreadNetBSD_H_ +#define liblldb_NativeThreadNetBSD_H_ + +#include "lldb/Host/common/NativeThreadProtocol.h" + +namespace lldb_private { +namespace process_netbsd { + +class NativeProcessNetBSD; + +class NativeThreadNetBSD : public NativeThreadProtocol { + friend class NativeProcessNetBSD; + +public: + NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid); +}; + +typedef std::shared_ptr NativeThreadNetBSDSP; +} // namespace process_netbsd +} // namespace lldb_private + +#endif // #ifndef liblldb_NativeThreadNetBSD_H_ Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -0,0 +1,21 @@ +//===-- NativeThreadNetBSD.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "NativeThreadNetBSD.h" +#include "NativeRegisterContextNetBSD.h" + +#include "NativeProcessNetBSD.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) {} Index: source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h === --- /dev/null +++ source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h @@ -0,0 +1,41 @@ +//===-- NativeRegisterContextNetBSD.h ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef lldb_NativeRegisterContextNetBSD_h +#define lldb_NativeRegisterContextNetBSD_h + +#include "lldb/Host/common/NativeRegisterContextRegisterInfo.h" +#include "lldb/Host/common/NativeThreadProtocol.h" + +#include "Plugins/Process/NetBSD/NativeProcessNetBSD.h" + +namespace lldb_private { +namespace process_netbsd { + +class NativeRegisterContextNetBSD : public NativeRegisterContextRegisterInfo { +public: + NativeRegisterContextNetBSD(NativeThreadProtocol &native_thread, + uint32_t concrete_frame_idx, + RegisterInfoInterface *reg_info_interface_p); + + // This function is implemented in the NativeRegisterContextNetBSD_* + // subclasses to create a new instance of the host specific + // NativeRegisterContextNetBSD. The implementations can't collide as only one + // NativeRegisterContextNetBSD_* variant should be compiled into the final + // executable. + static NativeRegisterContextNetBSD * + CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch, +NativeThreadProtocol &native_thread, +uint32_t concrete_frame_idx); +}; + +} // namespace process_netbs
[Lldb-commits] [PATCH] D31191: Enable ProcessPOSIXLog on NetBSD
krytarowski created this revision. krytarowski added a project: LLDB. NetBSD can share the same logging functionality with Linux and FreeBSD. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31191 Files: source/Initialization/SystemInitializerCommon.cpp Index: source/Initialization/SystemInitializerCommon.cpp === --- source/Initialization/SystemInitializerCommon.cpp +++ source/Initialization/SystemInitializerCommon.cpp @@ -26,7 +26,7 @@ #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #endif -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #endif @@ -93,7 +93,7 @@ #if defined(__APPLE__) ObjectFileMachO::Initialize(); #endif -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ProcessPOSIXLog::Initialize(); #endif #if defined(_MSC_VER) Index: source/Initialization/SystemInitializerCommon.cpp === --- source/Initialization/SystemInitializerCommon.cpp +++ source/Initialization/SystemInitializerCommon.cpp @@ -26,7 +26,7 @@ #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #endif -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #endif @@ -93,7 +93,7 @@ #if defined(__APPLE__) ObjectFileMachO::Initialize(); #endif -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ProcessPOSIXLog::Initialize(); #endif #if defined(_MSC_VER) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31192: Create instance of DynamicLoaderPOSIXDYLD on NetBSD
krytarowski created this revision. krytarowski added a project: LLDB. NetBSD is a modern ELF UNIX-like system. There is requires DynamicLoaderPOSIXDYLD e.g. for ELF AUXV reading from the client. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31192 Files: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp === --- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -63,8 +63,9 @@ if (!create) { const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); -if (triple_ref.getOS() == llvm::Triple::Linux || -triple_ref.getOS() == llvm::Triple::FreeBSD) +if (triple_ref.getOS() == llvm::Triple::FreeBSD || +triple_ref.getOS() == llvm::Triple::Linux || +triple_ref.getOS() == llvm::Triple::NetBSD) create = true; } Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp === --- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -63,8 +63,9 @@ if (!create) { const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); -if (triple_ref.getOS() == llvm::Triple::Linux || -triple_ref.getOS() == llvm::Triple::FreeBSD) +if (triple_ref.getOS() == llvm::Triple::FreeBSD || +triple_ref.getOS() == llvm::Triple::Linux || +triple_ref.getOS() == llvm::Triple::NetBSD) create = true; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31192: Create instance of DynamicLoaderPOSIXDYLD on NetBSD
krytarowski added a comment. This approach is easier for my to understand each change and make sure that it's actually needed and correct (or looking like a proper solution). There are 2 similar changes left I don't fully understand and code interfering with the OpenBSD platform addition that I will hold on a while. I expect that FreeBSD/OpenBSD (and perhaps DragonflyBSD at some point) will have the job clearer. Repository: rL LLVM https://reviews.llvm.org/D31192 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31231: Reuse appropriate Launch and Attach on NetBSD
krytarowski created this revision. krytarowski added a project: LLDB. Herald added a subscriber: mgorny. NetBSD ships with NativeProcessNetBSD inherited from NativeProcessProtocol. Link Plugins/Process/gdb-remote with lldbPluginProcessNetBSD in order to resolve correctly the linking to Launch and Attach from the NetBSD plugin. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31231 Files: source/Host/common/NativeProcessProtocol.cpp source/Plugins/Process/gdb-remote/CMakeLists.txt Index: source/Plugins/Process/gdb-remote/CMakeLists.txt === --- source/Plugins/Process/gdb-remote/CMakeLists.txt +++ source/Plugins/Process/gdb-remote/CMakeLists.txt @@ -11,6 +11,10 @@ list(APPEND LLDB_PLUGINS lldbPluginProcessLinux) endif() +if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") + list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD) +endif() + add_lldb_library(lldbPluginProcessGDBRemote PLUGIN GDBRemoteClientBase.cpp GDBRemoteCommunication.cpp Index: source/Host/common/NativeProcessProtocol.cpp === --- source/Host/common/NativeProcessProtocol.cpp +++ source/Host/common/NativeProcessProtocol.cpp @@ -504,7 +504,7 @@ return Error("failed to retrieve a valid architecture from the exe module"); } -#ifndef __linux__ +#if !defined(__linux__) && !defined(__NetBSD__) // These need to be implemented to support lldb-gdb-server on a given platform. // Stubs are // provided to make the rest of the code link on non-supported platforms. Index: source/Plugins/Process/gdb-remote/CMakeLists.txt === --- source/Plugins/Process/gdb-remote/CMakeLists.txt +++ source/Plugins/Process/gdb-remote/CMakeLists.txt @@ -11,6 +11,10 @@ list(APPEND LLDB_PLUGINS lldbPluginProcessLinux) endif() +if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") + list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD) +endif() + add_lldb_library(lldbPluginProcessGDBRemote PLUGIN GDBRemoteClientBase.cpp GDBRemoteCommunication.cpp Index: source/Host/common/NativeProcessProtocol.cpp === --- source/Host/common/NativeProcessProtocol.cpp +++ source/Host/common/NativeProcessProtocol.cpp @@ -504,7 +504,7 @@ return Error("failed to retrieve a valid architecture from the exe module"); } -#ifndef __linux__ +#if !defined(__linux__) && !defined(__NetBSD__) // These need to be implemented to support lldb-gdb-server on a given platform. // Stubs are // provided to make the rest of the code link on non-supported platforms. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31231: Reuse appropriate Launch and Attach on NetBSD
krytarowski added a comment. Next, I will work on a code to extend the NetBSD Process Plugin from a stub to a version that actually works. Repository: rL LLVM https://reviews.llvm.org/D31231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31231: Reuse appropriate Launch and Attach on NetBSD
krytarowski added a comment. With x86_64 general purpose registers going before that. Repository: rL LLVM https://reviews.llvm.org/D31231 ___ 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 inline comments. Comment at: source/CMakeLists.txt:25 +include_directories( + Plugins/Process/POSIX + ) @labath are the includes for Plugins/Process/FreeBSD and Plugins/Process/FreeBSD necessary? I don't need to add Plugins/Process/NetBSD in order to make things work. (it's not related to OpenBSD patch here) Comment at: source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp:48 + GPR gpr; + FPR_i386 i387; +}; no DBG regs here? 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] D31131: [LLDB] OpenBSD support
krytarowski accepted this revision. krytarowski added a comment. This revision is now accepted and ready to land. In general it looks good. 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] D31131: [LLDB] OpenBSD support
krytarowski added inline comments. Comment at: source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp:48 + GPR gpr; + FPR_i386 i387; +}; kettenis wrote: > krytarowski wrote: > > no DBG regs here? > OpenBSD doesn't actually implement access to the debug registers. Yes, I know, there are also accessors for xmm registers. So far I have not been there with NetBSD either and your code follows FreeBSD (Linux has debug registers in userdata). 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
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
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] [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] D31374: Add support for tracing hello-world application on NetBSD
krytarowski added a comment. In https://reviews.llvm.org/D31374#712221, @labath wrote: > I wasn't able to go into this too deeply, but here is what I have after a > quick pass. I won't be able to review this thoroughly that soon, but I think > it can go in after you take my comments into consideration. Thank you! I will apply the changes as suggested. 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. This code is used as a base for further improvements, I'm going to commit it... debugging hello world still works. $ lldb ./hello (lldb) target create "./hello" Current executable set to './hello' (x86_64). (lldb) r Process 3955 launched: './hello' (x86_64) Hello world! Process 3955 exited with status = 0 (0x) (lldb) version lldb version 5.0.0 (http://llvm.org/svn/llvm-project/lldb/trunk revision 298810) (lldb) platform status Platform: host Triple: x86_64-unknown-netbsd7.99 OS Version: 7.99.66 (0799006600) Kernel: NetBSD 7.99.66 (GENERIC) #5: Tue Mar 28 17:42:09 CEST 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC Hostname: 127.0.0.1 WorkingDir: /public/lldb_devel Kernel: NetBSD Release: 7.99.66 Version: NetBSD 7.99.66 (GENERIC) #5: Tue Mar 28 17:42:09 CEST 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC (lldb) 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 updated this revision to Diff 93312. krytarowski added a comment. Apply changes from review. 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,131 @@ #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_stop_description() {} + +void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo, +const siginfo_t *info) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + LLDB_LOG(log, "tid = {0} in called with signal {1}", GetID(), signo); + + SetStopped(); + + m_stop_info.reason = StopReason::eStopReasonSignal; + m_stop_info.details.signal.signo = signo; + + m_stop_description.clear(); + if (info) { +switch (signo) { +case SIGSEGV: +case SIGBUS: +case SIGFPE: +case SIGILL: + const auto reason = GetCrashReason(*info); + m_stop_description = GetCrashReasonString(reason, *info); + break; +} + } +} + +void NativeThreadNetBSD::SetStoppedByBreakpoint() { + SetStopped(); + m_stop_info.reason = StopReason::eStopReasonBreakpoint; + m_stop_info.details.signal.signo = SIGTRAP; +} + +void NativeThreadNetBSD::SetStopped() { + const StateType new_state = StateType::eStateStopped; + m_state = new_state; + m_stop_description.clear(); +} + +void NativeThreadNetBSD::SetRunning() { + m_state = StateType::eStateRunning; + m_stop_info.reason = StopReason::eStopReasonNone; +} + +std::string NativeThreadNetBSD::GetName() { return std::string(""); } + +lldb::StateType NativeThreadNetBSD::GetState() { return m_state; } + +bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info, + std::string &description) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + + description.clear(); + + switch (m_state) { + case eStateS
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski created this revision. krytarowski added a project: LLDB. Include initial support for: - single step mode (PT_STEP) - single step trap handling (TRAP_TRACE) - exec() trap (TRAP_EXEC) - add placeholder interfaces for FPR - initial code for NetBSD core(5) files - minor tweaks While there improve style of altered elf-core/ files. This code raises the number of passing tests on NetBSD to around 50% (600+/1200+). The introduced code is subject to improve afterwards for additional features and bug fixes. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31450 Files: source/Host/common/Host.cpp source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp 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 source/Plugins/Process/elf-core/ProcessElfCore.cpp source/Plugins/Process/elf-core/ThreadElfCore.cpp Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp === --- source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -21,6 +21,7 @@ #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" +#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h" #include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h" @@ -112,6 +113,17 @@ break; } +case llvm::Triple::NetBSD: { + switch (arch.GetMachine()) { + case llvm::Triple::x86_64: +reg_interface = new RegisterContextNetBSD_x86_64(arch); +break; + default: +break; + } + break; +} + case llvm::Triple::Linux: { switch (arch.GetMachine()) { case llvm::Triple::arm: @@ -144,8 +156,8 @@ reg_interface = new RegisterInfoPOSIX_arm(arch); break; case llvm::Triple::x86: - reg_interface = new RegisterContextOpenBSD_i386(arch); - break; +reg_interface = new RegisterContextOpenBSD_i386(arch); +break; case llvm::Triple::x86_64: reg_interface = new RegisterContextOpenBSD_x86_64(arch); break; @@ -260,7 +272,6 @@ pr_cstime.tv_sec = data.GetPointer(&offset); pr_cstime.tv_usec = data.GetPointer(&offset); - return error; } @@ -317,9 +328,7 @@ // // Parse SIGINFO from NOTE entry // -ELFLinuxSigInfo::ELFLinuxSigInfo() { - memset(this, 0, sizeof(ELFLinuxSigInfo)); -} +ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); } Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) { Error error; Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp === --- source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -62,8 +62,8 @@ // to ignore possible presence of the header extension. const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr); -auto data_sp = -DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0); +auto data_sp = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), + header_size, 0); if (data_sp && data_sp->GetByteSize() == header_size && elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) { elf::ELFHeader elf_header; @@ -223,7 +223,7 @@ bool siginfo_signal_found = false; bool prstatus_signal_found = false; // Check we found a signal in a SIGINFO note. - for (const auto &thread_data: m_thread_data) { + for (const auto &thread_data : m_thread_data) { if (thread_data.signo != 0) siginfo_signal_found = true; if (thread_data.prstatus_sig != 0) @@ -233,7 +233,7 @@ // If we don't have signal from SIGINFO use the signal from each threads // PRSTATUS note. if (prstatus_signal_found) { - for (auto &thread_data: m_thread_data) + for (auto &thread_data : m_thread_data) thread_data.signo = thread_data.prstatus_sig; } else if (m_thread_data.size() > 0) { // If all else fails force the first thread to be SIGSTOP @@ -449,6 +449,11 @@ }; } +namespace NETBSD { + +enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS =
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added a comment. Next: watchpoints, FPR. Current core(5) file format is a subject to change (AUXV can be shortened)... I'm working on the final nits for the NetBSD-8 interfaces. Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added a reviewer: jingham. krytarowski added a comment. Adding Jim as a reviewer, since Pavel is mostly out of the keyboard for longer time. Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added inline comments. Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:249 + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); labath wrote: > This is the third place i'm seeing this code. Any chance of turning it into a > function? Everything that touches threads will be refactored in future. I suspect that at the end this code will lost its capability to iterate threads after exec() as all of them are terminated. Here is a code that handles it in an expanded way and fore 1 thread only. Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:447 +for (const auto &thread_sp : m_threads) { + static_pointer_cast(thread_sp)->SetStepping(); +} labath wrote: > I guess you should be playing with the pt_suspend/resume here to step only > the requested thread(s). Is that something you plan to do as a follow up? I'm planning to reuse PT_RESUME/PT_SUSPEND to select thread/s for execution. And reuse PT_SETSTEP/PT_CLEARSTEP to mark them optionally for single-step mode. And at the end use global PT_CONTINUE as it has option to emit a signal (PT_STEP cannot send a signal). Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31461: Add NetBSD path for Debugging Information in Separate Files
krytarowski created this revision. krytarowski added a project: LLDB. Herald added a subscriber: aprantl. NetBSD stores debug information files in the `/usr/libdata/debug` path. This change fixes debugging distribution executables, e.g. `look`(1): $ lldb /usr/bin/look (lldb) target create "/usr/bin/look" Current executable set to '/usr/bin/look' (x86_64). (lldb) b main Breakpoint 1: where = look`main + 22 at look.c:107, address = 0x0da6 (lldb) r Process 23473 launched: '/usr/bin/look' (x86_64) Process 23473 stopped * thread #1, stop reason = breakpoint 1.1 frame #0: 0x000186600da6 look`main(argc=1, argv=0x7f7fffc7c488) at look.c:107 104 105 string = NULL; 106 file = _PATH_WORDS; -> 107 termchar = '\0'; 108 while ((ch = getopt(argc, argv, "dft:")) != -1) 109 switch(ch) { 110 case 'd': (lldb) There is no `/usr/lib/debug` path on NeBSD, so remove it from search. Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31461 Files: source/Host/common/Symbols.cpp Index: source/Host/common/Symbols.cpp === --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -212,8 +212,13 @@ debug_file_search_paths.AppendIfUnique(FileSpec(".", true)); #ifndef LLVM_ON_WIN32 +#if defined(__NetBSD__) +// Add /usr/libdata/debug directory. +debug_file_search_paths.AppendIfUnique(FileSpec("/usr/libdata/debug", true)); +#else // Add /usr/lib/debug directory. debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true)); +#endif #endif // LLVM_ON_WIN32 std::string uuid_str; Index: source/Host/common/Symbols.cpp === --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -212,8 +212,13 @@ debug_file_search_paths.AppendIfUnique(FileSpec(".", true)); #ifndef LLVM_ON_WIN32 +#if defined(__NetBSD__) +// Add /usr/libdata/debug directory. +debug_file_search_paths.AppendIfUnique(FileSpec("/usr/libdata/debug", true)); +#else // Add /usr/lib/debug directory. debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true)); +#endif #endif // LLVM_ON_WIN32 std::string uuid_str; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added a comment. I think I will start the threading segment with proper handling of core(5) files. It looks like the simplest start point. OpenBSD uses very similar format and can catch up quickly. Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added inline comments. Comment at: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp:383 // On Linux the executable is indicated by an empty path in the entry. On // FreeBSD and on Android it is the full path to the executable. kettenis wrote: > Probably should update this comment Right! Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:456 +} + // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details. kettenis wrote: > Unfortunate that the note numbers are different from architecture to > architecture on NetBSD. Yes, we reuse `PT_GETREGS` and `PT_GETFPREGS` per port variables. This is placeholder to start working on amd64 with threading support. Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added inline comments. Comment at: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:249 + // Initialize new thread + struct ptrace_lwpinfo info = {}; + Error error = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); labath wrote: > krytarowski wrote: > > labath wrote: > > > This is the third place i'm seeing this code. Any chance of turning it > > > into a function? > > Everything that touches threads will be refactored in future. > > > > I suspect that at the end this code will lost its capability to iterate > > threads after exec() as all of them are terminated. > > > > Here is a code that handles it in an expanded way and fore 1 thread only. > That's fine, but if they're identical right now, you could still merge them > together, right? (A lot of the temporary things have a tendency to become > permanent). I will merge this. Even if this is temporary solution. Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski updated this revision to Diff 93524. krytarowski added a comment. Herald added a subscriber: srhines. Apply changes from review. No visible regressions in "check-lldb". Repository: rL LLVM https://reviews.llvm.org/D31450 Files: source/Host/common/Host.cpp source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp 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 source/Plugins/Process/elf-core/ProcessElfCore.cpp source/Plugins/Process/elf-core/ThreadElfCore.cpp Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp === --- source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -21,6 +21,7 @@ #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" +#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" #include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h" #include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h" @@ -112,6 +113,17 @@ break; } +case llvm::Triple::NetBSD: { + switch (arch.GetMachine()) { + case llvm::Triple::x86_64: +reg_interface = new RegisterContextNetBSD_x86_64(arch); +break; + default: +break; + } + break; +} + case llvm::Triple::Linux: { switch (arch.GetMachine()) { case llvm::Triple::arm: @@ -144,8 +156,8 @@ reg_interface = new RegisterInfoPOSIX_arm(arch); break; case llvm::Triple::x86: - reg_interface = new RegisterContextOpenBSD_i386(arch); - break; +reg_interface = new RegisterContextOpenBSD_i386(arch); +break; case llvm::Triple::x86_64: reg_interface = new RegisterContextOpenBSD_x86_64(arch); break; @@ -260,7 +272,6 @@ pr_cstime.tv_sec = data.GetPointer(&offset); pr_cstime.tv_usec = data.GetPointer(&offset); - return error; } @@ -317,9 +328,7 @@ // // Parse SIGINFO from NOTE entry // -ELFLinuxSigInfo::ELFLinuxSigInfo() { - memset(this, 0, sizeof(ELFLinuxSigInfo)); -} +ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); } Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) { Error error; Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp === --- source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -62,8 +62,8 @@ // to ignore possible presence of the header extension. const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr); -auto data_sp = -DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0); +auto data_sp = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), + header_size, 0); if (data_sp && data_sp->GetByteSize() == header_size && elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) { elf::ELFHeader elf_header; @@ -223,7 +223,7 @@ bool siginfo_signal_found = false; bool prstatus_signal_found = false; // Check we found a signal in a SIGINFO note. - for (const auto &thread_data: m_thread_data) { + for (const auto &thread_data : m_thread_data) { if (thread_data.signo != 0) siginfo_signal_found = true; if (thread_data.prstatus_sig != 0) @@ -233,7 +233,7 @@ // If we don't have signal from SIGINFO use the signal from each threads // PRSTATUS note. if (prstatus_signal_found) { - for (auto &thread_data: m_thread_data) + for (auto &thread_data : m_thread_data) thread_data.signo = thread_data.prstatus_sig; } else if (m_thread_data.size() > 0) { // If all else fails force the first thread to be SIGSTOP @@ -449,6 +449,11 @@ }; } +namespace NETBSD { + +enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 }; +} + // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details. static void ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data, ArchSpec &arch) { @@ -485,13 +490,23 @@ thread_data.name = data.GetCStr(&offset, 20); } -stat
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added a comment. Thanks! Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31450: Battery of NetBSD support improvements
krytarowski added a comment. Thanks! I noted that I introduced some bugs.. but I will fix them in future revisions. I will move on to threads now. FPR/watchpoints will be done later, on the cost on adding some code for cores and helping out with base system work. LLDB/NetBSD is now out of the box functional as a debugger for a single thread. Repository: rL LLVM https://reviews.llvm.org/D31450 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31784: Correct environ parsing on NetBSD
krytarowski created this revision. krytarowski added a project: LLDB. This replaces old code in Host::GetEnvironment for NetBSD with the version from Linux. This makes parsing environment variables correctly. It also fixes programs that depend on the variables like curses(3) applications. Long term this function should be moved to Process Plugin, as currently env variables are not available with remote debugging. Other BSDs might want to catch up after this change. Tested with NetBSD top(1). Sponsored by Repository: rL LLVM https://reviews.llvm.org/D31784 Files: source/Host/netbsd/Host.cpp Index: source/Host/netbsd/Host.cpp === --- source/Host/netbsd/Host.cpp +++ source/Host/netbsd/Host.cpp @@ -52,15 +52,12 @@ using namespace lldb_private; size_t Host::GetEnvironment(StringList &env) { - char *v; - char **var = environ; - for (; var != NULL && *var != NULL; ++var) { -v = ::strchr(*var, (int)'-'); -if (v == NULL) - continue; -env.AppendString(v); - } - return env.GetSize(); + char **host_env = environ; + char *env_entry; + size_t i; + for (i = 0; (env_entry = host_env[i]) != NULL; ++i) +env.AppendString(env_entry); + return i; } static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr, Index: source/Host/netbsd/Host.cpp === --- source/Host/netbsd/Host.cpp +++ source/Host/netbsd/Host.cpp @@ -52,15 +52,12 @@ using namespace lldb_private; size_t Host::GetEnvironment(StringList &env) { - char *v; - char **var = environ; - for (; var != NULL && *var != NULL; ++var) { -v = ::strchr(*var, (int)'-'); -if (v == NULL) - continue; -env.AppendString(v); - } - return env.GetSize(); + char **host_env = environ; + char *env_entry; + size_t i; + for (i = 0; (env_entry = host_env[i]) != NULL; ++i) +env.AppendString(env_entry); + return i; } static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67
krytarowski added a comment. Hmm still wrong. Later in this code: // NetBSD per-thread information is stored in notes named // "NetBSD-CORE@nnn" so match on the initial part of the string. m_os = llvm::Triple::NetBSD; if (note.n_type == NETBSD::NT_PROCINFO) { ParseNetBSDProcInfo(*thread_data, note_data); } else if (note.n_type == NETBSD::NT_AUXV) { m_auxv = DataExtractor(note_data); } else if (arch.GetMachine() == llvm::Triple::x86_64 && note.n_type == NETBSD::NT_AMD64_REGS) { thread_data->gpregset = note_data; } else if (arch.GetMachine() == llvm::Triple::x86_64 && note.n_type == NETBSD::NT_AMD64_FPREGS) { thread_data->fpregset = note_data; } `arch.GetMachine()` evaluates to `llvm::Triple::UnknownArch` and `gpregset` and `fpregset` is never set. Changing `ArchSpec arch = GetArchitecture();` to `ArchSpec arch = GetTarget().GetArchitecture();` does not help... I'm trying to investigate. Repository: rL LLVM https://reviews.llvm.org/D31825 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67
krytarowski added a comment. Other BSDs work. Repository: rL LLVM https://reviews.llvm.org/D31825 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67
krytarowski added a comment. For the reference, I uploaded FreeBSD/amd64 and OpenBSD/i386 core(5) files: http://netbsd.org/~kamil/lldb/freebsd.10.3.release.p11-top.core.93102 http://netbsd.org/~kamil/lldb/openbsd.6.0-top.core Repository: rL LLVM https://reviews.llvm.org/D31825 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31877: Remove Plugins/Process/POSIX from include_directories
krytarowski added a comment. Thank you for working on it! https://reviews.llvm.org/D31877 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67
krytarowski created this revision. krytarowski added a project: LLDB. This change has been authored by Zachary Turner. It fixes loading into the debugger core(5) files generated by NetBSD x86_64 v. 7.99.67. These core(5) files have the e_ident[EI_OSABI] property set to ELFOSABI_SYSV. It might change in future versions to ELFOSABI_NETBSD. However it still should not crash the debugger. With this change applied, LLDB can be loaded properly with: ` lldb -c ./core ` Repository: rL LLVM https://reviews.llvm.org/D31825 Files: source/Core/ArchSpec.cpp source/Plugins/Process/elf-core/ProcessElfCore.cpp Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp === --- source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -220,7 +220,7 @@ target_arch.MergeFrom(core_arch); GetTarget().SetArchitecture(target_arch); - SetUnixSignals(UnixSignals::Create(GetArchitecture())); + SetUnixSignals(UnixSignals::Create(target_arch)); // Ensure we found at least one thread that was stopped on a signal. bool siginfo_signal_found = false; @@ -724,17 +724,7 @@ } ArchSpec ProcessElfCore::GetArchitecture() { - ObjectFileELF *core_file = - (ObjectFileELF *)(m_core_module_sp->GetObjectFile()); - ArchSpec arch; - core_file->GetArchitecture(arch); - - ArchSpec target_arch = GetTarget().GetArchitecture(); - - if (target_arch.IsMIPS()) -return target_arch; - - return arch; + return GetTarget().GetArchitecture(); } const lldb::DataBufferSP ProcessElfCore::GetAuxvData() { Index: source/Core/ArchSpec.cpp === --- source/Core/ArchSpec.cpp +++ source/Core/ArchSpec.cpp @@ -989,29 +989,34 @@ } void ArchSpec::MergeFrom(const ArchSpec &other) { - if (TripleVendorIsUnspecifiedUnknown() && - !other.TripleVendorIsUnspecifiedUnknown()) -GetTriple().setVendor(other.GetTriple().getVendor()); - if (TripleOSIsUnspecifiedUnknown() && !other.TripleOSIsUnspecifiedUnknown()) -GetTriple().setOS(other.GetTriple().getOS()); - if (GetTriple().getArch() == llvm::Triple::UnknownArch) -GetTriple().setArch(other.GetTriple().getArch()); - if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && - !TripleVendorWasSpecified()) { -if (other.TripleVendorWasSpecified()) - GetTriple().setEnvironment(other.GetTriple().getEnvironment()); - } // If this and other are both arm ArchSpecs and this ArchSpec is a generic - // "some kind of arm" - // spec but the other ArchSpec is a specific arm core, adopt the specific arm - // core. + // "some kind of arm" spec but the other ArchSpec is a specific arm core, adopt + // the specific arm core. + bool ShouldOverrideCore = false; + + if (GetCore() == ArchSpec::kCore_invalid && other.GetCore() != ArchSpec::kCore_invalid) +ShouldOverrideCore = true; if (GetTriple().getArch() == llvm::Triple::arm && - other.GetTriple().getArch() == llvm::Triple::arm && - IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && - other.GetCore() != ArchSpec::eCore_arm_generic) { +other.GetTriple().getArch() == llvm::Triple::arm && +IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && +other.GetCore() != ArchSpec::eCore_arm_generic) +ShouldOverrideCore = true; + if (ShouldOverrideCore) { m_core = other.GetCore(); CoreUpdated(true); } + + if (GetTriple().getVendor() == llvm::Triple::UnknownVendor) +GetTriple().setVendor(other.GetTriple().getVendor()); + + if (GetTriple().getOS() == llvm::Triple::UnknownOS) +GetTriple().setOS(other.GetTriple().getOS()); + + if (GetTriple().getArch() == llvm::Triple::UnknownArch) +GetTriple().setArch(other.GetTriple().getArch()); + + if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment) +GetTriple().setEnvironment(other.GetTriple().getEnvironment()); } bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu, Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp === --- source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -220,7 +220,7 @@ target_arch.MergeFrom(core_arch); GetTarget().SetArchitecture(target_arch); - SetUnixSignals(UnixSignals::Create(GetArchitecture())); + SetUnixSignals(UnixSignals::Create(target_arch)); // Ensure we found at least one thread that was stopped on a signal. bool siginfo_signal_found = false; @@ -724,17 +724,7 @@ } ArchSpec ProcessElfCore::GetArchitecture() { - ObjectFileELF *core_file = - (ObjectFileELF *)(m_core_module_sp->GetObjectFile()); - ArchSpec arch; - core_file->GetArchitecture(arch); - - ArchSpec target_arch = GetTarget().GetArchitecture(); - - if (target_arch.IsMIPS()) -retur
[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67
krytarowski added a comment. Example core(5) file: http://netbsd.org/~kamil/lldb/top.core Generated with gcore(1), which snapshoted a running top(1) program. Repository: rL LLVM https://reviews.llvm.org/D31825 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31825: Fix loading core(5) files from NetBSD 7.99.67
krytarowski added a comment. I might need some guidance to address the asserts appropriately in finite time. In general we set osabi to generic unix (value 0), and NetBSD core(5) files are distinguished only (or mostly) with "NetBSD-CORE*" notes. Repository: rL LLVM https://reviews.llvm.org/D31825 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h
krytarowski added inline comments. Comment at: cmake/modules/LLDBConfig.cmake:433 +set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H}) +set(LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED ${HAVE_FCNTL_H}) +if(NOT UNIX) Can we just use `#ifdef F_GETPATH` in the source code? No need to define another symbol wrapping `F_GETPATH`. https://reviews.llvm.org/D31969 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits