This is an archive of the discontinued LLVM Phabricator instance.

[windows] LLDB shows the wrong values when register read is executed at a frame other than zero
ClosedPublic

Authored by stella.stamenova on Jul 9 2018, 5:19 PM.

Details

Summary

This is a clean version of the change suggested here: https://bugs.llvm.org/show_bug.cgi?id=37495

The main change is to follow the same pattern as non-windows targets and use an unwinder object to retrieve the register context. I also changed a couple of the comments to actually log, so that issues with unsupported scenarios can be tracked down more easily. Lastly, ClearStackFrames is implemented in the base class, so individual thread implementations don't have to override it.

Diff Detail

Repository
rL LLVM

Event Timeline

aleksandr.urakov requested changes to this revision.Jul 10 2018, 12:45 AM

Looks good to me, except formatting.

source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
74–81 ↗(On Diff #154739)

It seems that lines are too long, you can easily reformat this with clang-format.

This revision now requires changes to proceed.Jul 10 2018, 12:45 AM

Some code style notes

source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
52 ↗(On Diff #154739)

Smart pointer's operator bool is intended just for this case, no need in this change.

53 ↗(On Diff #154739)

Please, use nullptr instead of NULL.

68 ↗(On Diff #154739)

Revert to using operator bool also.

92 ↗(On Diff #154739)

Here you check plain pointer, don't cast it to bool - compare with nullptr.

source/Plugins/Process/elf-core/ThreadElfCore.cpp
232 ↗(On Diff #154739)

ditto

source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
92 ↗(On Diff #154739)

What are the disadvantages of casting to bool in comparison with nullptr checking?

source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
92 ↗(On Diff #154739)

That's a matter of opinion, but most coding styles consider implicit casts as less readable. E.g. if you run clang-tidy with enabled readability checks, you get readability-implicit-bool-conversion warning on this code.

stella.stamenova marked 8 inline comments as done.Jul 10 2018, 9:57 AM

I made the requested changes and I'll update the revision once all the tests pass.

source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
92 ↗(On Diff #154739)

I actually intentionally copied this line and several of the others verbatim from the other targets (so that they are the same) but I can fix both places.

I think this is a matter of opinion and the code is fine as is personally.
If you prefer the implicit cast, feel free to leave it. This pattern is
already pervasive all over LLVM and clang, so you can treat it as a nit
(fix it if you agree, leave it if you prefer).

Update to address style comments

I think this is a matter of opinion and the code is fine as is personally.
If you prefer the implicit cast, feel free to leave it. This pattern is
already pervasive all over LLVM and clang, so you can treat it as a nit
(fix it if you agree, leave it if you prefer).

It's a small change and it makes things a little more consistent, so I might as well fix it :). Thanks!

LGTM - thank you! But let's wait also for Zachary or Aaron.

This revision is now accepted and ready to land.Jul 10 2018, 11:24 AM

Oops! I meant only your changes when asking to use nullptr instead of NULL;)

Such modernizing is pleasing to the eye, but is worth separate commit, possibly.

This revision was automatically updated to reflect the committed changes.