[Bug 37317] New: ModuleList::FindGlobalVariables fails with append=false

Bug ID 37317
Summary ModuleList::FindGlobalVariables fails with append=false
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter tom@tromey.com
CC llvm-bugs@lists.llvm.org

In my Rust work I found that ModuleList::FindGlobalVariables will not
work properly when passed append=false.

The issue comes because SymbolFileDWARF::FindGlobalVariables does:

  // If we aren't appending the results to this list, then clear the list
  if (!append)

So, if there are multiple modules, later ones will erase the results
from earlier ones.

A simple fix would be to change ModuleList::FindGlobalVariables to
do something like:

if (!append) variables.Clear();
    (*pos)->FindGlobalVariables(name, nullptr, true, max_matches,

That is, always pass append=true to the callees.

I would submit a patch for this but I don't know how to write a test case.
So, I thought I'd file this instead.  I'm also going to fix it in my tree.

Tom Tromey changed bug 37317

What Removed Added
Resolution FIXED

Comment # 8 on bug 37317 from Tom Tromey

The fix went in a while ago.