[lldb] Fix a regression introduced by D75730
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 22 Oct 2020 15:32:05 +0000 (08:32 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 22 Oct 2020 15:38:03 +0000 (08:38 -0700)
commit826997c46280351861be43522d4a022d8fdbc466
treebb76edd32c02d34b826a36cc54219c6230797e4a
parenta8b0ae3bddee311cbc97801089a95702f32773f8
[lldb] Fix a regression introduced by D75730

In a new Range class was introduced to simplify and the Disassembler API
and reduce duplication. It unintentionally broke the
SBFrame::Disassemble functionality because it unconditionally converts
the number of instructions to a Range{Limit::Instructions,
num_instructions}. This is subtly different from the previous behavior,
where now we're passing a Range and assume it's valid in the callee, the
original code would propagate num_instructions and the callee would
compare the value and decided between disassembling instructions or
bytes.

Unfortunately the existing tests was not particularly strict:

  disassembly = frame.Disassemble()
  self.assertNotEqual(len(disassembly), 0, "Disassembly was empty.")

This would pass because without this patch we'd disassemble zero
instructions, resulting in an error:

  (lldb) script print(lldb.frame.Disassemble())
  error: error reading data from section __text

Differential revision: https://reviews.llvm.org/D89925
lldb/include/lldb/Core/Disassembler.h
lldb/source/Core/Disassembler.cpp
lldb/source/Target/StackFrame.cpp
lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
lldb/test/API/commands/disassemble/basic/main.cpp