This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [llgs] Implement qXfer:siginfo:read
ClosedPublic

Authored by mgorny on Jan 12 2022, 6:39 AM.

Details

Summary

Implement the qXfer:siginfo:read that is used to read the siginfo_t
(extended signal information) for the current thread. This is currently
implemented on FreeBSD and Linux.

Diff Detail

Event Timeline

mgorny created this revision.Jan 12 2022, 6:39 AM
mgorny requested review of this revision.Jan 12 2022, 6:39 AM
labath added inline comments.Jan 12 2022, 8:41 AM
lldb/include/lldb/Host/common/NativeProcessProtocol.h
195–198

I think it would be more natural/consistent to have this function on a specific NativeThreadProtocol object (and let the user choose whether it wants the siginfo for the current thread, or someone else).

lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
1987

I'd be better to outright allocate a memory buffer of the right size (getNewUninitMemBuffer), and directly write the data there.

lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
1398

Didn't D117103 fix that?

1437

you want the address width of the debugged binary, not python, right? We already have some utilities to help with that (grep for parse_process_info_response).

mgorny updated this revision to Diff 399478.Jan 12 2022, 2:52 PM
mgorny marked 4 inline comments as done.

Implemented the requested changes.

lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
1987

I suppose there's no similar solution for the FreeBSD case where the returned struct is a member of the temporary struct?

lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
1398

Yeah, I left a comment, so I don't forget, then I've forgotten that I've left a comment ;-D.

labath accepted this revision.Jan 13 2022, 2:16 AM

cool

lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
1987

Not with the current interface (and it's probably not worth changing it for it).

This revision is now accepted and ready to land.Jan 13 2022, 2:16 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2022, 2:24 AM

This does not build correctly with gcc 7.3.1 on CentOS:

/usr/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/resource/1/b/llvm/Release/tools/lldb/source/Plugins/Process/Linux -I/mnt/resource/1/s/llvm-project/lldb/source/Plugins/Process/Linux -I/mnt/resource/1/s/llvm-project/lldb/include -I/mnt/resource/1/b/llvm/Release/tools/lldb/include -I/mnt/resource/1/b/llvm/Release/include -I/mnt/resource/1/s/llvm-project/llvm/include -I/mnt/resource/1/s/llvm-project/llvm/../clang/include -I/mnt/resource/1/b/llvm/Release/tools/lldb/../clang/include -I/mnt/resource/1/s/llvm-project/lldb/source -I/mnt/resource/1/b/llvm/Release/tools/lldb/source -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/NativeThreadLinux.cpp.o -MF tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/NativeThreadLinux.cpp.o.d -o tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/NativeThreadLinux.cpp.o -c /mnt/resource/1/s/llvm-project/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
/mnt/resource/1/s/llvm-project/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp: In member function ‘virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer> > lldb_private::process_linux::NativeThreadLinux::GetSiginfo() const’:
/mnt/resource/1/s/llvm-project/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp:552:10: error: could not convert ‘siginfo_buf’ from ‘std::unique_ptr<llvm::WritableMemoryBuffer>’ to ‘llvm::Expected<std::unique_ptr<llvm::MemoryBuffer> >’
   return siginfo_buf;

sounds like something that could be fixed by a couple of std::moves

This does not build correctly with gcc 7.3.1 on CentOS:

Could you please try adding some std::move()s to the relevant returns? I don't have an access to such an ancient compiler.