Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[lldb][DWARF] Only log address range error to verbose channel #144037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Jun 13, 2025

Currently LLDB_LOG_ERROR always logs to the "always-on" channel (which prints to the console; this started with #111911).

Attaching to LLDB on macOS spams the console with a bunch of these messages:

...
2025-06-13 10:15:09.965660+0100 lldb[40872:3936672] [lldb] DIE(0x240901): DIE has no address range information
2025-06-13 10:15:09.965667+0100 lldb[40872:3936672] [lldb] DIE(0x240925): DIE has no address range information
2025-06-13 10:15:09.965672+0100 lldb[40872:3936672] [lldb] DIE(0x240942): DIE has no address range information
2025-06-13 10:15:09.965679+0100 lldb[40872:3936672] [lldb] DIE(0x24095e): DIE has no address range information
2025-06-13 10:15:09.965686+0100 lldb[40872:3936672] [lldb] DIE(0x240981): DIE has no address range information
2025-06-13 10:15:09.965694+0100 lldb[40872:3936672] [lldb] DIE(0x240993): DIE has no address range information
2025-06-13 10:15:09.965701+0100 lldb[40872:3936672] [lldb] DIE(0x2409a2): DIE has no address range information
...

AFAIU this is not a fatal error, so this patch downgrades it from "always-on" by logging only in "verbose" mode.

It still seems pretty aggressive to log all LLDB_LOG_ERROR messages to the console, but this is a stop-gap until we want to do something about it.

Currently `LLDB_LOG_ERROR` always logs to the "always-on" channel (which
prints to the console; this started with TBD).

Attaching to LLDB spams the console with a bunch of these messages:
```
...
2025-06-13 10:15:09.965660+0100 lldb[40872:3936672] [lldb] DIE(0x240901): DIE has no address range information
2025-06-13 10:15:09.965667+0100 lldb[40872:3936672] [lldb] DIE(0x240925): DIE has no address range information
2025-06-13 10:15:09.965672+0100 lldb[40872:3936672] [lldb] DIE(0x240942): DIE has no address range information
2025-06-13 10:15:09.965679+0100 lldb[40872:3936672] [lldb] DIE(0x24095e): DIE has no address range information
2025-06-13 10:15:09.965686+0100 lldb[40872:3936672] [lldb] DIE(0x240981): DIE has no address range information
2025-06-13 10:15:09.965694+0100 lldb[40872:3936672] [lldb] DIE(0x240993): DIE has no address range information
2025-06-13 10:15:09.965701+0100 lldb[40872:3936672] [lldb] DIE(0x2409a2): DIE has no address range information
...
```

AFAIU this is not a fatal error, so this patch downgrades it from
"always-on" by logging only in "verbose" mode.

It still seems pretty aggressive to log all `LLDB_LOG_ERROR` messages to
the console, but this is a stop-gap until we want to do something about
it.
@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2025

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

Currently LLDB_LOG_ERROR always logs to the "always-on" channel (which prints to the console; this started with #111911).

Attaching to LLDB spams the console with a bunch of these messages:

...
2025-06-13 10:15:09.965660+0100 lldb[40872:3936672] [lldb] DIE(0x240901): DIE has no address range information
2025-06-13 10:15:09.965667+0100 lldb[40872:3936672] [lldb] DIE(0x240925): DIE has no address range information
2025-06-13 10:15:09.965672+0100 lldb[40872:3936672] [lldb] DIE(0x240942): DIE has no address range information
2025-06-13 10:15:09.965679+0100 lldb[40872:3936672] [lldb] DIE(0x24095e): DIE has no address range information
2025-06-13 10:15:09.965686+0100 lldb[40872:3936672] [lldb] DIE(0x240981): DIE has no address range information
2025-06-13 10:15:09.965694+0100 lldb[40872:3936672] [lldb] DIE(0x240993): DIE has no address range information
2025-06-13 10:15:09.965701+0100 lldb[40872:3936672] [lldb] DIE(0x2409a2): DIE has no address range information
...

AFAIU this is not a fatal error, so this patch downgrades it from "always-on" by logging only in "verbose" mode.

It still seems pretty aggressive to log all LLDB_LOG_ERROR messages to the console, but this is a stop-gap until we want to do something about it.


Full diff: https://github.com/llvm/llvm-project/pull/144037.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (+1-1)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 5196ce89a2c13..4d091f4deeabe 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -617,7 +617,7 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
         for (const auto &r : *ranges)
           debug_aranges->AppendRange(GetOffset(), r.LowPC, r.HighPC);
       } else {
-        LLDB_LOG_ERROR(log, ranges.takeError(), "DIE({1:x}): {0}", GetOffset());
+        LLDB_LOG_ERRORV(log, ranges.takeError(), "DIE({1:x}): {0}", GetOffset());
       }
     }
 

Copy link

github-actions bot commented Jun 13, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@Michael137
Copy link
Member Author

Example CU where we fail to get the address range info:

builds-lldb/debug/lib/liblldbPluginSymbolFileDWARF.a(DWARFDebugInfoEntry.cpp.o):        file format Mach-O arm64

.debug_info contents:

0x0000000c: DW_TAG_compile_unit
              DW_AT_producer    ("Apple clang version 17.0.0 (clang-1700.3.10.902) [+internal-os]")
              DW_AT_language    (DW_LANG_C_plus_plus_14)
              DW_AT_name        ("/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp")
              DW_AT_str_offsets_base    (0x00000008)
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("/Users/jonas/Git/llvm-worktrees/llvm-project/builds-lldb/debug")
              DW_AT_low_pc      (0x0000000000000000)
              DW_AT_ranges      (indexed (0xd) rangelist = 0x00000105
                 [0x0000000000000000, 0x0000000000011be8)
                 [0x0000000000011c80, 0x0000000000012064)
                 [0x00000000000120fc, 0x0000000000012164)
                 [0x0000000000012178, 0x00000000000121f4)
                 [0x0000000000012208, 0x0000000000013380))
              DW_AT_addr_base   (0x00000008)
              DW_AT_rnglists_base       (0x0000000c)
              DW_AT_loclists_base       (0x0000000c)

0x00000031:   DW_TAG_namespace
                DW_AT_name      ("llvm")

0x0000003f:     DW_TAG_namespace
                  DW_AT_name    ("dwarf")

0x0000092e:       DW_TAG_structure_type
                    DW_AT_calling_convention    (DW_CC_pass_by_value)
                    DW_AT_name  ("FormParams")
                    DW_AT_byte_size     (0x06)
                    DW_AT_decl_file     ("/Users/jonas/Git/llvm-worktrees/llvm-project/llvm/include/llvm/BinaryFormat/Dwarf.h")
                    DW_AT_decl_line     (1093)

0x00000962:         DW_TAG_subprogram
                      DW_AT_linkage_name        ("_ZNK4llvm5dwarf10FormParams18getRefAddrByteSizeEv")
                      DW_AT_name        ("getRefAddrByteSize")
                      DW_AT_decl_file   ("/Users/jonas/Git/llvm-worktrees/llvm-project/llvm/include/llvm/BinaryFormat/Dwarf.h")
                      DW_AT_decl_line   (1104)
                      DW_AT_type        (0x0008192d "uint8_t")
                      DW_AT_declaration (true)
                      DW_AT_external    (true)

@Michael137
Copy link
Member Author

Another thing that's confusing me is that this error only prints to the console when you attach to LLDB. E.g.,

$ cat range.cpp 
struct Foo {
    void func() {}
};

int main() {
    Foo{}.func();
    return 0;
}

This doesn't print the error:

./build/bin/lldb ~/a.out -o "b main" -o run

But,

./build/bin/lldb -o "b DWARFDebugInfoEntry.cpp:620" -- ./build/bin/lldb ~/a.out -o "b main" -o run

Will break on the error path, and the error is logged to the console..

@Michael137
Copy link
Member Author

Michael137 commented Jun 13, 2025

Looks like this error just happens anytime we build the aranges table for a CU and the DW_TAG_subprogram doesn't have a DW_AT_low_pc/DW_AT_high_pc; which is always the case for forward declarations. Should we maybe just skip the call to GetAttributeAddressRanges here when we're looking at forward declaration DIEs?

void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
    DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
  Log *log = GetLog(DWARFLog::DebugInfo);
  if (m_tag) {
    if (m_tag == DW_TAG_subprogram) {
      if (llvm::Expected<llvm::DWARFAddressRangesVector> ranges =
              GetAttributeAddressRanges(cu, /*check_hi_lo_pc=*/true)) {

?

@labath @adrian-prantl

@labath
Copy link
Collaborator

labath commented Jun 13, 2025

It still seems pretty aggressive to log all LLDB_LOG_ERROR messages to the console, but this is a stop-gap until we want to do something about it.

I said as much on the PR, and still think it's too aggressive to send all these errors to the system log.

Looks like this error just happens anytime we build the aranges table for a CU and the DW_TAG_subprogram doesn't have a DW_AT_low_pc/DW_AT_high_pc; which is always the case for forward declarations. Should we maybe just skip the call to GetAttributeAddressRanges here when we're looking at forward declaration DIEs?

That's probably fine. This code sounds like it could be relatively hot, so I feel slightly bad for doing another scan of the abbreviation just to do what we do anyway (ignore the DIE), but this may actually be faster than constructing the llvm::Error object.

Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jun 13, 2025
…rd declarations

This fixes the error reported in
llvm#144037.

When computing the aranges table of a CU, LLDB would currently visit all
`DW_TAG_subprogram` DIEs and check their `DW_AT_low_pc`/`DW_AT_high_pc`.
If those don't exist it would error out and spam the console. Some
subprograms (particularly forward declarations) don't have low/high pc
attributes, so it's not really an "error". We should just ignore those
DIEs.
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jun 13, 2025
…rd declarations

This fixes the error reported in
llvm#144037.

When computing the aranges table of a CU, LLDB would currently visit all
`DW_TAG_subprogram` DIEs and check their `DW_AT_low_pc`/`DW_AT_high_pc`.
If those don't exist it would error out and spam the console. Some
subprograms (particularly forward declarations) don't have low/high pc
attributes, so it's not really an "error". We should just ignore those
DIEs.
@Michael137
Copy link
Member Author

It still seems pretty aggressive to log all LLDB_LOG_ERROR messages to the console, but this is a stop-gap until we want to do something about it.

I said as much on the PR, and still think it's too aggressive to send all these errors to the system log.

@JDevlieghere @adrian-prantl in case we want to revisit this.

Last time we spoke about this @felipepiovezan suggested having a more explicit name for the macro (something in the spirit of LLDB_LOG_ERROR_DONT_DROP_THIS). So LLDB devs don't accidentally log a frequently occurring llvm::Error to the console

Looks like this error just happens anytime we build the aranges table for a CU and the DW_TAG_subprogram doesn't have a DW_AT_low_pc/DW_AT_high_pc; which is always the case for forward declarations. Should we maybe just skip the call to GetAttributeAddressRanges here when we're looking at forward declaration DIEs?

That's probably fine. This code sounds like it could be relatively hot, so I feel slightly bad for doing another scan of the abbreviation just to do what we do anyway (ignore the DIE), but this may actually be faster than constructing the llvm::Error object.

#144059

Michael137 added a commit that referenced this pull request Jun 13, 2025
…rd declarations (#144059)

This fixes the error reported in
#144037.

When computing the aranges table of a CU, LLDB would currently visit all
`DW_TAG_subprogram` DIEs and check their
`DW_AT_low_pc`/`DW_AT_high_pc`/`DW_AT_ranges` attributes. If those don't
exist it would error out and spam the console. Some subprograms
(particularly forward declarations) don't have low/high pc attributes,
so it's not really an "error". See DWARFv5 spec section `3.3.3
Subroutine and Entry Point Locations`:
```
A subroutine entry may have either a DW_AT_low_pc and DW_AT_high_pc
pair of attributes or a DW_AT_ranges attribute whose values encode the
contiguous or non-contiguous address ranges, respectively, of the machine
instructions generated for the subroutine (see Section 2.17 on page 51).
...
A subroutine entry representing a subroutine declaration that is not also a
definition does not have code address or range attributes.
```

We should just ignore those DIEs.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 13, 2025
…on of forward declarations (#144059)

This fixes the error reported in
llvm/llvm-project#144037.

When computing the aranges table of a CU, LLDB would currently visit all
`DW_TAG_subprogram` DIEs and check their
`DW_AT_low_pc`/`DW_AT_high_pc`/`DW_AT_ranges` attributes. If those don't
exist it would error out and spam the console. Some subprograms
(particularly forward declarations) don't have low/high pc attributes,
so it's not really an "error". See DWARFv5 spec section `3.3.3
Subroutine and Entry Point Locations`:
```
A subroutine entry may have either a DW_AT_low_pc and DW_AT_high_pc
pair of attributes or a DW_AT_ranges attribute whose values encode the
contiguous or non-contiguous address ranges, respectively, of the machine
instructions generated for the subroutine (see Section 2.17 on page 51).
...
A subroutine entry representing a subroutine declaration that is not also a
definition does not have code address or range attributes.
```

We should just ignore those DIEs.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
…rd declarations (llvm#144059)

This fixes the error reported in
llvm#144037.

When computing the aranges table of a CU, LLDB would currently visit all
`DW_TAG_subprogram` DIEs and check their
`DW_AT_low_pc`/`DW_AT_high_pc`/`DW_AT_ranges` attributes. If those don't
exist it would error out and spam the console. Some subprograms
(particularly forward declarations) don't have low/high pc attributes,
so it's not really an "error". See DWARFv5 spec section `3.3.3
Subroutine and Entry Point Locations`:
```
A subroutine entry may have either a DW_AT_low_pc and DW_AT_high_pc
pair of attributes or a DW_AT_ranges attribute whose values encode the
contiguous or non-contiguous address ranges, respectively, of the machine
instructions generated for the subroutine (see Section 2.17 on page 51).
...
A subroutine entry representing a subroutine declaration that is not also a
definition does not have code address or range attributes.
```

We should just ignore those DIEs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.