[all-commits] [llvm/llvm-project] 22667e: Fix regex & startsWith name lookup in SBTarget::Fi...

jimingham via All-commits all-commits at lists.llvm.org
Thu Jun 1 16:15:22 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 22667e3220de5ead353a2148265d841644b63824
      https://github.com/llvm/llvm-project/commit/22667e3220de5ead353a2148265d841644b63824
  Author: Jim Ingham <jingham at apple.com>
  Date:   2023-06-01 (Thu, 01 Jun 2023)

  Changed paths:
    M lldb/source/API/SBTarget.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
    M lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
    M lldb/test/API/lang/cpp/class_static/main.cpp

  Log Message:
  -----------
  Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

There were two bugs here.

eMatchTypeStartsWith searched for "symbol_name" by adding ".*" to the
end of the symbol name and treating that as a regex, which isn't
actually a regex for "starts with". The ".*" is in fact a no-op.  When
we finally get to comparing the name, we compare against whatever form
of the name was in the accelerator table. But for C++ that might be
the mangled name. We should also try demangled names here, since most
users are going the see demangled not mangled names.  I fixed these
two bugs and added a bunch of tests for FindGlobalVariables.

This change is in the DWARF parser code, so there may be a similar bug
in PDB, but the test for this was already skipped for Windows, so I
don't know about this.

You might theoretically need to do this Mangled comparison in

DWARFMappedHash::MemoryTable::FindByName

except when we have names we always chop them before looking them up
so I couldn't see any code paths that fail without that change. So I
didn't add that to this patch.

Differential Revision: https://reviews.llvm.org/D151940




More information about the All-commits mailing list