[all-commits] [llvm/llvm-project] d0fa52: [lldb] Rewrite Scalar::GetBytes

Pavel Labath via All-commits all-commits at lists.llvm.org
Thu Jun 25 06:32:09 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d0fa52cc3797fd8805d24a04e6b8198154cd7b53
      https://github.com/llvm/llvm-project/commit/d0fa52cc3797fd8805d24a04e6b8198154cd7b53
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2020-06-25 (Thu, 25 Jun 2020)

  Changed paths:
    M lldb/include/lldb/Utility/RegisterValue.h
    M lldb/include/lldb/Utility/Scalar.h
    M lldb/source/Utility/RegisterValue.cpp
    M lldb/source/Utility/Scalar.cpp
    M lldb/unittests/Utility/ScalarTest.cpp

  Log Message:
  -----------
  [lldb] Rewrite Scalar::GetBytes

This function was modifying and returning pointers to static storage,
which meant that any two accesses to different Scalar objects could
potentially race (depending on which types the objects were storing and
the host endianness).

In the new version the user is responsible for providing a buffer into
which this method will store its binary representation. The main caller
(RegisterValue::GetBytes) already has one such buffer handy, so this did
not require any major rewrites.

To make that work, I've needed to mark the RegisterValue value buffer
mutable -- not an ideal solution, but definitely better than modifying
global storage. This could be further improved by changing
RegisterValue::GetBytes to take a buffer too.




More information about the All-commits mailing list