This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-remote] Use standardized GDB errno values
ClosedPublic

Authored by mgorny on Aug 16 2021, 10:35 AM.

Details

Summary

GDB uses normalized errno values for vFile errors. Implement
the translation between them and system errno values in the gdb-remote
plugin.

Diff Detail

Event Timeline

mgorny requested review of this revision.Aug 16 2021, 10:35 AM
mgorny created this revision.
labath added a comment.Sep 7 2021, 5:55 AM

I think this would be a good use case for a llvm-style .def file. It would provide a central place listing all the known constants, and one could use it to generate the enum definition and both of the conversion functions (by defining a suitable macro).

mgorny added a comment.Sep 7 2021, 9:46 AM

I think this would be a good use case for a llvm-style .def file. It would provide a central place listing all the known constants, and one could use it to generate the enum definition and both of the conversion functions (by defining a suitable macro).

So basically a new thingie for lldb's TableGen? or is there some generic thingie I could reuse for this?

Nah, tablegen is overkill. I was thinking of something similar to (but simpler than) include/llvm/BinaryFormat/Dwarf.def.

Nah, tablegen is overkill. I was thinking of something similar to (but simpler than) include/llvm/BinaryFormat/Dwarf.def.

Yeah, that looks easier. You got me scared there for a sec!

mgorny updated this revision to Diff 371351.Sep 8 2021, 8:42 AM

Use a .def file.

labath accepted this revision.Sep 10 2021, 1:13 AM

LG, modulo the comment. Keep an eye out on the bots though. I fear some systems (windows, in particular), may not have all errno constants defined, and we'll need to do something smarter.

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
3071

Normally, it's the job of the .def file to undef this macro.

This revision is now accepted and ready to land.Sep 10 2021, 1:13 AM
mgorny marked an inline comment as done.Sep 10 2021, 1:29 AM

LG, modulo the comment. Keep an eye out on the bots though. I fear some systems (windows, in particular), may not have all errno constants defined, and we'll need to do something smarter.

Yeah, I was thinking how to handle this… after all, we can't #ifdef here.

Judging by https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-constants?view=msvc-160, this may just work, so let's cross that bridge when we get to it.

This revision was landed with ongoing or failed builds.Sep 10 2021, 5:09 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2021, 5:09 AM