This is an archive of the discontinued LLVM Phabricator instance.

[nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using .debug_names
ClosedPublic

Authored by jankratochvil on Aug 6 2021, 10:43 AM.

Details

Summary

As this issue is a bit difficult to debug it is better to make it safe against future changes.

Diff Detail

Event Timeline

jankratochvil created this revision.Aug 6 2021, 10:43 AM

Can we not just grab the skeleton unit when/if needed instead of asserting in many places?

Can we not just grab the skeleton unit when/if needed instead of asserting in many places?

I agree it could be unified for API simplicity to be always the skeleton unit, thanks for the idea. Done in this patch. Still I believe it should be asserted as unfortunately with the current Unit types it cannot be compile-time checked.

kimanh accepted this revision.Aug 9 2021, 4:47 AM

LGTM, I also support that assertions are added. This gives confidence in what's expected and also makes it easier to read/understand whether it's a skeleton/non-skeleton unit that we are dealing with.

This revision is now accepted and ready to land.Aug 9 2021, 4:47 AM

Thanks for checking it but ...

Can we not just grab the skeleton unit when/if needed instead of asserting in many places?

... I am not sure @clayborg likes the assertions.

Thanks for checking it but ...

Can we not just grab the skeleton unit when/if needed instead of asserting in many places?

... I am not sure @clayborg likes the assertions.

I don't mind lldbassert() calls as they are not in release builds, so it is nice to catch things during debug build testing. I prefer that asserts are not used when the program would knowingly crash immediately after the assert. I don't like asserts in code like:

assert(ptr)
ptr->foo();

This code will crash both when asserts are enabled and also when they aren't. And the llvm/clang/lldb code is used in a shared library that other tools link against. So the code really shouldn't crash when it is easy to work around and add code to avoid the crash. I still prefer the above code to look like:

assert(ptr)
if (ptr)
  ptr->foo();

As long as the program continues to function correctly without the assert, feel free to add any asserts to help catch issues during development.

This revision was landed with ongoing or failed builds.Aug 10 2021, 11:43 AM
This revision was automatically updated to reflect the committed changes.