This is an archive of the discontinued LLVM Phabricator instance.

Use the right type for pid_t on FreeBSD
ClosedPublic

Authored by davide on Mar 20 2015, 1:27 PM.

Details

Summary

pid_t is int32_t on FreeBSD, not uint64_t. I think it's better committing a small sin her rather than changing it globally.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 22372.Mar 20 2015, 1:27 PM
davide retitled this revision from to Use the right type for pid_t on FreeBSD.
davide updated this object.
davide edited the test plan for this revision. (Show Details)
davide added a reviewer: emaste.
davide added a subscriber: Unknown Object (MLST).
davide updated this revision to Diff 22397.Mar 20 2015, 5:18 PM

Updated patch after suggestion from Chaoren on IRC.

emaste accepted this revision.EditedMar 20 2015, 6:12 PM
emaste edited edge metadata.

I'm not sure it's uint64_t anywhere, actually, and I think PseudoTerminal::Fork ought to return a ::pid_t as well. But this change is OK as long as it works - specifically, the if ((pid = terminal.Fork(err_str, err_len)) == -1)

This revision is now accepted and ready to land.Mar 20 2015, 6:12 PM

Just for the records, it's uint64_t as defined in lldb_types.h. pid_t is int32_t at least on FreeBSD and Mac OS (didn't check Linux). Also, clang complains about signed vs unsigned comparison:

../tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp:973:49: warning: comparison of integers of different signs: 'lldb::pid_t' (aka 'unsigned long') and 'int' [-Wsign-compare]

if ((pid = terminal.Fork(err_str, err_len)) == -1)
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^  ~~

so actually this change make the logic correct in case fork() fails and therefore returns -1 to the parent.

all of the lldb:: types are 64 bit because it needs to be able to hold a
pid of any platform (if you are remote debugging for example). You need to
cast to and from ::pid_t inside your host layer

all of the lldb:: types are 64 bit because it needs to be able to hold a
pid of any platform (if you are remote debugging for example). You need to
cast to and from ::pid_t inside your host layer

Right - what I meant is I'm not aware of any platform that has a 64-bit pid type.

I'm not either fwiw, just explaining the motivation for Davide :)

Thank for the clarification Zachary. While at it, are you OK with this patch or you have ohter comments?

If Ed says it's fine then I'm fine too.

This revision was automatically updated to reflect the committed changes.