This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Fix possible nullptr exception
ClosedPublic

Authored by Emmmer on Aug 16 2022, 12:53 AM.

Details

Summary

Some architectures do not have a flag register (like riscv).
In this case, we should set it to baton.m_register_values.end() to avoid nullptr exception.

Diff Detail

Event Timeline

Emmmer created this revision.Aug 16 2022, 12:53 AM
Emmmer requested review of this revision.Aug 16 2022, 12:53 AM
DavidSpickett accepted this revision.Aug 16 2022, 1:45 AM

LGTM. Skimming the code I think what happens is it will try to read the flags from the context, fail and return 0xF...F. Then nothing for riscv is going to read that value so no harm done by not having a flags register.

Testing wise I assume that without this any attempt to run a single step crashes? So if they now pass, it's covered.

Something I noticed going through this is that MIPS returns sr as its flags register, when I would have said that MIPS doesn't have flags either (and I worked on MIPS for a while so I think I'd remember). Even so I think you're doing the right thing here by not providing a flags register at all.

This revision is now accepted and ready to land.Aug 16 2022, 1:45 AM

LGTM. Skimming the code I think what happens is it will try to read the flags from the context, fail and return 0xF...F. Then nothing for riscv is going to read that value so no harm done by not having a flags register.

Testing wise I assume that without this any attempt to run a single step crashes? So if they now pass, it's covered.

Something I noticed going through this is that MIPS returns sr as its flags register, when I would have said that MIPS doesn't have flags either (and I worked on MIPS for a while so I think I'd remember). Even so I think you're doing the right thing here by not providing a flags register at all.

Thank you for your explanation!

This revision was automatically updated to reflect the committed changes.