[lldb] [Process/NetBSD] Fix crash on unsupported i386 regs
authorMichał Górny <mgorny@moritz.systems>
Thu, 1 Oct 2020 17:38:49 +0000 (19:38 +0200)
committerMichał Górny <mgorny@moritz.systems>
Sat, 3 Oct 2020 17:54:38 +0000 (19:54 +0200)
commit9821632056dce9e2150bab9c0fbd9b2c7da64258
treebfb244b3591e05bc12547eb0b93ad871012d097e
parent80b108f404fc9e88889df7247f6ae9697083cbda
[lldb] [Process/NetBSD] Fix crash on unsupported i386 regs

Multiple fixes related to bugs discovered while debugging a crash
when reading all registers on i386.

The underlying problem was that GetSetForNativeRegNum() did not account
for MPX registers on i386, and since it only compared against upper
bounds of each known register set, the MPX registers were classified
into the wrong set and therefore considered supported.  However, they
were not expected in RegNumX86ToX86_64() and caused the assertion
to fail.

This includes:

- adding (unused) i386 → x86_64 translations for MPX registers
- fixing GetSetForNativeRegNum() to check both lower and upper bound
  for register sets, to avoid wrongly classifying unhandled register
  sets
- adding missing range check for MPX registers on i386
- renaming k_last_mpxr to k_last_mpxr_i386 for consistency
- replacing return-assertions with llvm_unreachable() and adding more
  checks for unexpected parameters

Differential Revision: https://reviews.llvm.org/D88682
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h