[all-commits] [llvm/llvm-project] dd00c4: Fix breakpoint setting so it always works when the...

Greg Clayton via All-commits all-commits at lists.llvm.org
Mon Oct 24 16:28:55 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dd00c4db747e27f53a5621a8b9c50711f00894ef
      https://github.com/llvm/llvm-project/commit/dd00c4db747e27f53a5621a8b9c50711f00894ef
  Author: Greg Clayton <gclayton at fb.com>
  Date:   2022-10-24 (Mon, 24 Oct 2022)

  Changed paths:
    M lldb/source/Symbol/CompileUnit.cpp
    M lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
    A lldb/test/API/functionalities/breakpoint/breakpoint_command/bad_aranges.yaml

  Log Message:
  -----------
  Fix breakpoint setting so it always works when there is a line entry in a compile unit's line table.

Prior to this fix, if the compile unit function:

  void CompileUnit::ResolveSymbolContext(const SourceLocationSpec &src_location_spec, SymbolContextItem resolve_scope, SymbolContextList &sc_list);

was called with a resolve scope that wasn't just eSymbolContextLineEntry, we would end up calling:

  line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);

This is ok as long as the line entry's base address is able to be resolved back to the same information, but there were problems when it didn't. The example I found was we have a file with a bad .debug_aranges section where the address to compile unit mapping was incomplete. When this happens, the above function call to calculate the symbol context would end up matching the module and it would NULL out the compile unit and line entry, which means we would fail to set this breakpoint. We have many other clients that ask for eSymbolContextEverything as the resolve_scope, so all other locations could end up failing as well.

The solutions is to make sure the compile unit matches the current compile unit after calling the calculate symbol context. If the compile unit is NULL, then we report an error via the module/debugger as this indicates an entry in the line table fails to resolve back to any compile unit. If the compile unit is not NULL and it differs from the current compile unit, we restore the current compile unit and line entry to ensure the call to .CalculateSymbolContext doesn't match something completely different, as can easily happen if LTO or other link time optimizations are enabled that could end up outlining or merging functions.

This patch allows breakpoint succeeding to work as expected and not get short circuited by our address lookup logic failing.

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




More information about the All-commits mailing list