This is an archive of the discontinued LLVM Phabricator instance.

Refactor FindVariable() core functionality into StackFrame out of SBFrame
ClosedPublic

Authored by shafik on Sep 18 2018, 2:01 PM.

Details

Summary

SBFrame should be a thin wrapper around the core functionality in StackFrame. Currently FindVariable() core functionality is implemented in SBFrame and this will move that into StackFrame.

This is step two in enabling stepping into std::function.

Diff Detail

Repository
rL LLVM

Event Timeline

shafik created this revision.Sep 18 2018, 2:01 PM
davide accepted this revision.Sep 18 2018, 2:26 PM
davide added a subscriber: davide.

LGTM modulo minor.

source/Target/StackFrame.cpp
1733–1738 ↗(On Diff #166032)

This is fairly unreadable IMHO. If I were you, I would hoist the lambda out.

This revision is now accepted and ready to land.Sep 18 2018, 2:26 PM
davide added inline comments.Sep 18 2018, 2:27 PM
include/lldb/Target/StackFrame.h
506–507 ↗(On Diff #166032)

Also, I think you might want to add a doxygen comment here, as this function is now part of the API.

clayborg requested changes to this revision.Sep 18 2018, 3:06 PM
clayborg added a subscriber: clayborg.
clayborg added inline comments.
include/lldb/Target/StackFrame.h
506 ↗(On Diff #166032)

Make this a "ConstString name" since we need that for lookup anyway? We couldn't do that in SBFrame cause we don't expose our constant strings outside the API, but internally we can use ConstString

source/API/SBFrame.cpp
669 ↗(On Diff #166032)
value_sp = frame->FindVariable(ConstString(name));
source/Target/StackFrame.cpp
1712 ↗(On Diff #166032)
lldb::ValueObjectSP StackFrame::FindVariable(ConstString name) {
1737 ↗(On Diff #166032)

remove ConstString if we change parameter

This revision now requires changes to proceed.Sep 18 2018, 3:06 PM

I agree with Greg, this is the sort of function that we'd pass a ConstString to on the lldb_private side.

We haven't documented all the API's we should. This one is pretty self-explanatory, but still we should try to document all the new functions we add, Davide's right there.

Other than those nits, this seems fine.

shafik updated this revision to Diff 166194.Sep 19 2018, 3:54 PM
shafik marked 6 inline comments as done.

Addressing comments:

- Adding documentation to FindVariable()
- Using ConstString instead of const char *

@jingham @clayborg @davide addressed comments w/ the exception of the lambda one which I politely disagree with.

source/Target/StackFrame.cpp
1733–1738 ↗(On Diff #166032)

This is exactly the case lambda were meant to address, moving it out would just add boilerplate code :-(

jingham accepted this revision.Sep 19 2018, 4:01 PM

This is fine by me.

davide accepted this revision.Sep 19 2018, 4:02 PM

Sure.

clayborg accepted this revision.Sep 19 2018, 4:13 PM

Just a documentation suggestion, but looks good.

include/lldb/Target/StackFrame.h
508 ↗(On Diff #166194)

We might want to say how the search is done. Something like "The search for the variable starts in the deepest block corresponding to the current PC in the stack frame and traverse through all parent blocks stopping at inlined function boundaries"

This revision is now accepted and ready to land.Sep 19 2018, 4:13 PM
shafik updated this revision to Diff 166308.Sep 20 2018, 9:02 AM

Adjusting documentation based on feedback

clayborg accepted this revision.Sep 20 2018, 9:29 AM

Looks good

This revision was automatically updated to reflect the committed changes.