[all-commits] [llvm/llvm-project] d941fc: Add the ability to see when a type in incomplete.

Greg Clayton via All-commits all-commits at lists.llvm.org
Wed Nov 23 10:07:27 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d941fceca8e9bc9b5a00c9865ee022ba5507df32
      https://github.com/llvm/llvm-project/commit/d941fceca8e9bc9b5a00c9865ee022ba5507df32
  Author: Greg Clayton <gclayton at fb.com>
  Date:   2022-11-23 (Wed, 23 Nov 2022)

  Changed paths:
    M lldb/include/lldb/Symbol/CompilerType.h
    M lldb/include/lldb/Symbol/TypeSystem.h
    M lldb/source/API/SBType.cpp
    M lldb/source/Core/ValueObject.cpp
    M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
    M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
    M lldb/source/Symbol/CompilerType.cpp
    M lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
    M lldb/unittests/Symbol/TestTypeSystemClang.cpp

  Log Message:
  -----------
  Add the ability to see when a type in incomplete.

-flimit-debug-info and other compiler options might end up removing debug info that is needed for debugging. LLDB marks these types as being forcefully completed in the metadata in the TypeSystem. These types should have been complete in the debug info but were not because the compiler omitted them to save space. When we can't find a suitable replacement for the type, we should let the user know that these types are incomplete to indicate there was an issue instead of just showing nothing for a type.

The solution is to display presented in this patch is to display "<incomplete type>" as the summary for any incomplete types. If there is a summary string or function that is provided for a type, but the type is currently forcefully completed, the installed summary will be ignored and we will display "<incomplete type>". This patch also exposes the ability to ask a SBType if it was forcefully completed with:

  bool SBType::IsTypeForcefullyCompleted();

This will allow the user interface for a debugger to also detect this issue and possibly mark the variable display up on some way to indicate to the user the type is incomplete.

To show how this is diplayed, we can look at the existing output first for the example source file from the file: lldb/test/API/functionalities/limit-debug-info/main.cpp

(lldb) frame variable inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = (member = 47)
(InheritsFromTwo) ::inherits_from_two = (member = 47)
(OneAsMember) ::one_as_member = (one = member::One @ 0x0000000100008028, member = 47)
(TwoAsMember) ::two_as_member = (two = member::Two @ 0x0000000100008040, member = 47)
(array::One [3]) ::array_of_one = ([0] = array::One @ 0x0000000100008068, [1] = array::One @ 0x0000000100008069, [2] = array::One @ 0x000000010000806a)
(array::Two [3]) ::array_of_two = ([0] = array::Two @ 0x0000000100008098, [1] = array::Two @ 0x0000000100008099, [2] = array::Two @ 0x000000010000809a)
(ShadowedOne) ::shadowed_one = (member = 47)
(lldb) frame variable --show-types inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = {
  (int) member = 47
}
(InheritsFromTwo) ::inherits_from_two = {
  (int) member = 47
}
(OneAsMember) ::one_as_member = {
  (member::One) one = {}
  (int) member = 47
}
(TwoAsMember) ::two_as_member = {
  (member::Two) two = {}
  (int) member = 47
}
(array::One [3]) ::array_of_one = {
  (array::One) [0] = {}
  (array::One) [1] = {}
  (array::One) [2] = {}
}
(array::Two [3]) ::array_of_two = {
  (array::Two) [0] = {}
  (array::Two) [1] = {}
  (array::Two) [2] = {}
}
(ShadowedOne) ::shadowed_one = {
  (int) member = 47
}

With this patch in place we can now see any classes that were forcefully completed to let us know that we are missing information:

(lldb) frame variable inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = (One = <incomplete type>, member = 47)
(InheritsFromTwo) ::inherits_from_two = (Two = <incomplete type>, member = 47)
(OneAsMember) ::one_as_member = (one = <incomplete type>, member = 47)
(TwoAsMember) ::two_as_member = (two = <incomplete type>, member = 47)
(array::One[3]) ::array_of_one = ([0] = <incomplete type>, [1] = <incomplete type>, [2] = <incomplete type>)
(array::Two[3]) ::array_of_two = ([0] = <incomplete type>, [1] = <incomplete type>, [2] = <incomplete type>)
(ShadowedOne) ::shadowed_one = (func_shadow::One = <incomplete type>, member = 47)
(lldb) frame variable --show-types inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = {
  (One) One = <incomplete type> {}
  (int) member = 47
}
(InheritsFromTwo) ::inherits_from_two = {
  (Two) Two = <incomplete type> {}
  (int) member = 47
}
(OneAsMember) ::one_as_member = {
  (member::One) one = <incomplete type> {}
  (int) member = 47
}
(TwoAsMember) ::two_as_member = {
  (member::Two) two = <incomplete type> {}
  (int) member = 47
}
(array::One[3]) ::array_of_one = {
  (array::One) [0] = <incomplete type> {}
  (array::One) [1] = <incomplete type> {}
  (array::One) [2] = <incomplete type> {}
}
(array::Two[3]) ::array_of_two = {
  (array::Two) [0] = <incomplete type> {}
  (array::Two) [1] = <incomplete type> {}
  (array::Two) [2] = <incomplete type> {}
}
(ShadowedOne) ::shadowed_one = {
  (func_shadow::One) func_shadow::One = <incomplete type> {}
  (int) member = 47
}

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




More information about the All-commits mailing list