This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Fix display of value of a vector variables in watchpoint operations
ClosedPublic

Authored by mohit.bhakkad on Sep 27 2015, 11:32 PM.

Details

Summary

Consider a vector variable 'v8i16 s0'

Right now if we print value of s0, it gives us proper value:
(lldb) print s0
(v8i16) $0 = (member 1, member 2, ........,member 8)

But if we try to set a watchpoint on it, it shows null for its value:

(lldb) watchpoint set variable s0
Watchpoint created: Watchpoint 1: addr = <addr> size = 16 state = enabled type = w

declare @ 'file_name:line_no'
watchpoint spec = 's0'
new value: (null)

Approach used in patch is already used in in function ValueObjectPrinter::GetValueSummaryError,
which is called for command 'print s0'.

Diff Detail

Repository
rL LLVM

Event Timeline

mohit.bhakkad retitled this revision from to [LLDB] Fix display of value of a vector variables in watchpoint operations.
mohit.bhakkad updated this object.
mohit.bhakkad set the repository for this revision to rL LLVM.
mohit.bhakkad added subscribers: jaydeep, bhushan, slthakur and 2 others.
zturner requested changes to this revision.Sep 27 2015, 11:33 PM
zturner added a reviewer: zturner.
zturner added a subscriber: zturner.

Can you find a way to add a test for this?

This revision now requires changes to proceed.Sep 27 2015, 11:33 PM
mohit.bhakkad edited edge metadata.

Adding a simple test to check displayed value of vector

Looks good to me. Just add a decorator to both tests to skip unless the compiler is gcc or clang ( __attribute((vector_size))__ doesn't work on MSVC or clang-cl, for example

Actually I'm wrong. Leave it enabled and I'll see what happens. clang-cl (which we require for windows tests) supports that syntax after all.

clayborg requested changes to this revision.Oct 5 2015, 11:44 AM
clayborg edited edge metadata.

Back from vacation, sorry for the delay.

One quick fix as noted in inlined comments.

source/Breakpoint/Watchpoint.cpp
224–235 ↗(On Diff #35879)

It would be nice to store these in local variables and clean up the code a bit like:

const char *old_value_cstr =  m_old_value_sp->GetValueAsCString();
if (old_value_cstr && old_value_cstr[0])
    s->Printf("\n%sold value: %s", prefix, old_value_cstr);
else
{
    const char *old_summary_cstr =  m_old_value_sp-> GetSummaryAsCString();
    if (old_summary_cstr && old_summary_cstr[0])
        s->Printf("\n%sold value: %s", prefix, old_summary_cstr);
}

This way we don't ever print "old value: " when there is no value or summary...

This revision now requires changes to proceed.Oct 5 2015, 11:44 AM
mohit.bhakkad edited edge metadata.

Changing as suggested

clayborg accepted this revision.Oct 8 2015, 9:51 AM
clayborg edited edge metadata.

Looks good.

This revision was automatically updated to reflect the committed changes.

Shouldn't that test have been inside the test/ folder?

Strange, it was fine in the review, but wrong in the commit. Yea, that
needs to be fixed.

Strange, it was fine in the review, but wrong in the commit. Yea, that
needs to be fixed.

Yes it looks strange, I directly applied the patch from review, and it looks like new files are added directly to the trunk.
Mistake from my side is I didn't checked changes before committing, as patch got applied successfully without any
issues. I will be careful from next time.

@loladiro @zturner Thanks for pointing this out, fixed it in rL249897