This is an archive of the discontinued LLVM Phabricator instance.

[NativeProcessLinux] Use lambdas in DoOperation calls
ClosedPublic

Authored by labath on Jun 24 2015, 8:24 AM.

Details

Summary

This removes a lot of boilerplate, which was needed to execute monitor operations. Previously one
needed do declare a separate class for each operation which would manually capture all needed
arguments, which was very verbose. In addition to less code, I believe this also makes the code
more readable, since now the implementation of the operation can be physically closer to the code
that invokes it.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 28358.Jun 24 2015, 8:24 AM
labath retitled this revision from to [NativeProcessLinux] Use lambdas in DoOperation calls.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: tberghammer, chaoren.
labath added a subscriber: Unknown Object (MLST).
chaoren added inline comments.Jun 24 2015, 11:29 AM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
3171 ↗(On Diff #28358)

Why not make this void * to begin with?

3178 ↗(On Diff #28358)

Does it make sense to have PtraceWrapper return Error? To be consistent with some changes you made above.

3190 ↗(On Diff #28358)

void *?

3728 ↗(On Diff #28358)

Nit: extra space.

source/Plugins/Process/Linux/NativeProcessLinux.h
142 ↗(On Diff #28358)

Nit: extra space.

chaoren added inline comments.Jun 24 2015, 11:32 AM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
3171 ↗(On Diff #28358)

Whoops, didn't see the assignment right below. Please ignore this.

labath updated this revision to Diff 28441.Jun 25 2015, 1:55 AM
  • Remove extra spaces
labath added inline comments.
source/Plugins/Process/Linux/NativeProcessLinux.cpp
3171 ↗(On Diff #28358)

This could be made simpler, but I did not want to do it here, as it is just copy-pasted.

3178 ↗(On Diff #28358)

I've thought about that as well and I think it is a good idea. I propose to do it in a followup patch. I'll need to check if putting the current return value in a by-ref parameter will not make other things more awkward.

3728 ↗(On Diff #28358)

Done.

source/Plugins/Process/Linux/NativeProcessLinux.h
142 ↗(On Diff #28358)

On which side? :)
I'll remove the right one, as that seems to be most consistent with other uses.

tberghammer accepted this revision.Jun 25 2015, 3:45 AM
tberghammer edited edge metadata.

Looks good, but please check it compiles on all supported architecture (x86_64, arm, aarch64, mips/mips64) because some of the code only used on one of these.

source/Plugins/Process/Linux/NativeProcessLinux.cpp
259 ↗(On Diff #28441)

(nit): You can do a "return Error();" here

713 ↗(On Diff #28441)

(nit): I think "m_operation->operator()();" is cleaner but it is up to you

253 ↗(On Diff #28358)

(nit) You don't need this. ("return Error();")

This revision is now accepted and ready to land.Jun 25 2015, 3:45 AM
labath added inline comments.Jun 25 2015, 5:25 AM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
259 ↗(On Diff #28441)

I don't think so. PtraceWrapper sets the error variable, and I need to test it. right?

713 ↗(On Diff #28441)

I don't find either of the options particularly appealing, but I prefer this one a bit.

tberghammer added inline comments.Jun 25 2015, 5:37 AM
source/Plugins/Process/Linux/NativeProcessLinux.cpp
259 ↗(On Diff #28441)

Sorry, I missed that call

chaoren accepted this revision.Jun 25 2015, 10:44 AM
chaoren edited edge metadata.

LGTM.

source/Plugins/Process/Linux/NativeProcessLinux.cpp
3178 ↗(On Diff #28358)

I think it might be better to pass a pointer instead, for consistency with the other arguments, and makes it optional.

This revision was automatically updated to reflect the committed changes.