This is an archive of the discontinued LLVM Phabricator instance.

Modernize and simplify HostInfo::GetOSKernelDescription
ClosedPublic

Authored by labath on Oct 25 2021, 7:47 AM.

Details

Summary

Replace bool+by-ref argument with llvm::Optional, and move the common
implementation into HostInfoPOSIX. Based on my (simple) experiment,
the uname and the sysctl approach return the same value on MacOS, so
there's no need for a mac-specific implementation of this functionality.

Diff Detail

Event Timeline

labath created this revision.Oct 25 2021, 7:47 AM
labath requested review of this revision.Oct 25 2021, 7:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 25 2021, 7:47 AM
This revision is now accepted and ready to land.Oct 25 2021, 9:13 AM
mgorny added inline comments.Oct 25 2021, 9:57 AM
lldb/include/lldb/Host/posix/HostInfoPosix.h
25

Ok, I must be missing something but I don't see the implementation of this in this patch.

lldb/source/Target/Platform.cpp
495

I'd also change this prototype while at it ;-).

labath updated this revision to Diff 382048.Oct 25 2021, 10:41 AM

add missing implementation

labath marked 2 inline comments as done.Oct 25 2021, 10:43 AM
labath added inline comments.
lldb/include/lldb/Host/posix/HostInfoPosix.h
25

I forgot to amend the implementation into the patch. Thanks for catching that.

lldb/source/Target/Platform.cpp
495

A lot of this code is only built/tested on some platforms, so I wanted to do that as a followup -- to reduce the number of moving parts. I also did GetOSBuildString in two parts, and both parts managed to break something.

mgorny added inline comments.Oct 25 2021, 11:03 AM
lldb/source/Host/posix/HostInfoPosix.cpp
44 ↗(On Diff #382048)

I'm somewhat surprised that you need to do that. I wonder if there was a real reason why it's done or just someone being overly careful.

labath updated this revision to Diff 382223.Oct 26 2021, 1:38 AM
labath marked 2 inline comments as done.

Remove memset

lldb/source/Host/posix/HostInfoPosix.cpp
44 ↗(On Diff #382048)

I'm pretty sure it isn't necessary.

labath marked an inline comment as done.Oct 26 2021, 1:39 AM
mgorny accepted this revision.Oct 26 2021, 1:56 AM

LGTM

This revision was automatically updated to reflect the committed changes.