This is an archive of the discontinued LLVM Phabricator instance.

[XRay] Update FDR log reader to be aware of buffer sizes per thread.
ClosedPublic

Authored by kpw on Mar 27 2017, 1:33 AM.

Details

Summary

It is problematic for this reader that it expects to read data from
several threads, but the header or message format does not define
framing. Since the buffers are reused, we can't rely on skipping
zeroed out data as a synchronization method either.

There is an argument that this is not version compatible with the format
the reader expected previously. I argue that since the writer wrote garbage
past the end of buffer record, there is no currently working reader to
compromise.

The corresponding writer change is posted to D31384.

Diff Detail

Repository
rL LLVM

Event Timeline

kpw created this revision.Mar 27 2017, 1:33 AM
dberris accepted this revision.Mar 27 2017, 7:14 PM

LGTM with some nits.

lib/XRay/Trace.cpp
138 ↗(On Diff #93104)

Just curious -- did you need to actually explicitly create an instance of Twine? Or would just returning the literal work just fine?

385–386 ↗(On Diff #93104)

I don't think you need the else since you're already continuing in the body of the true branch.

423–426 ↗(On Diff #93104)

I suspect it's more readable if you just used '+' here. Idiomatic Twine usage seems to prefer concatenation with '+' for readability reasons.

This revision is now accepted and ready to land.Mar 27 2017, 7:14 PM
kpw updated this revision to Diff 93322.Mar 28 2017, 5:22 PM

This now expects the buffer size information in the Header rather than in a separate
piece of data.

LGTM - Few more nits.

lib/XRay/Trace.cpp
376–377 ↗(On Diff #93322)

Did clang-format do this?

388–390 ↗(On Diff #93322)

I think you just need the first object in the '+' concatenation to be a Twine -- the rest can be as they are just fine:

Twine("Incomplete thread buffer. Expected ") + (State.CurrentBufferSize - State.CurrentBufferConsumed) + " remaining bytes but found " + S.size()

416–420 ↗(On Diff #93322)

Same here.

kpw marked 3 inline comments as done.Mar 28 2017, 5:32 PM
kpw added inline comments.
lib/XRay/Trace.cpp
138 ↗(On Diff #93104)

It was unnecessary thanks to implicit constructors.

423–426 ↗(On Diff #93104)

Will a conversion operator be called for literal strings past the first.

Is it idiomatic to write Twine("Concatenating ") + "several" + " strings " + " that " + " become twines " and get a Twine as the result?

dberris added inline comments.Mar 28 2017, 5:33 PM
lib/XRay/Trace.cpp
423–426 ↗(On Diff #93104)

Yes, that's idiomatic. :)

kpw updated this revision to Diff 93330.Mar 28 2017, 6:43 PM
kpw marked 2 inline comments as done.

Few more cleanups for nits and change the freeform space handling to better use DataExtractor.

Twine needs to wrap integral types and clang format did ruin the indentation on FDRState.

kpw marked 3 inline comments as done.Mar 28 2017, 6:44 PM
kpw added inline comments.
lib/XRay/Trace.cpp
376–377 ↗(On Diff #93322)

Unfortunately yes.

This revision was automatically updated to reflect the committed changes.