<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/151857>151857</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            BOLT: BOLT generates odd address ranges in .gdb_index, which confuse gdb
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            BOLT
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          itrofimow
      </td>
    </tr>
</table>

<pre>
    I'm investigating gdb asserts/warnings (gdb 12 asserts, gdb 14 spams warnings) when poking BOLT-ed binaries containing `.gdb_index`.

gdb-12 asserts here https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/dwarf2/read.c;h=10550336063f51545063885281dd587a8e1774f0;hb=e53a8e8685685c97588f8319d993ea6cd5635e47#l4502

, and warnings in gdb 14 look like these:
```
warning: (Internal error: pc 0x231439a0 in read in CU, but not in symtab.)
warning: (Error: pc 0x231439a0 in address map, but not in symtab.)
```
, coming from here https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/dwarf2/read.c;h=5bbc8e24cf96d4d7dda40b8486b6fd3d88301543;hb=02c10eaecb63e5dbb99cbfdd1c5385e53ed031ff#l3209

So far, what I'm seeing is that BOLT sometimes generates address ranges like this in `.gdb_index`:
`Low/High address = [0x0, 0x0) (Size: 0x0), CU id = 326`
and I think such ranges break this gdb logic https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/dwarf2/read-gdb-index.c;h=9bfc5302b0e87bcf83782b351d25da243e09406d;hb=02c10eaecb63e5dbb99cbfdd1c5385e53ed031ff#l754, as the `hi` suddenly becomes max ulong value. Omitting such ranges either in BOLT or in gdb fixes this for some of the binaries I have, and for other gdb still asserts/spams warnings in the same way, but that I'm yet to pin-point.

----

What makes me think this is BOLT misbehaving (other than obviously odd ranges), is that if I strip the index from BOLT-ed binary and regenerate it by gdb itself -- all seems to be working fine.

I didn't manage to find an open-source reproducer yet, but I can provide a binary together with the BOLT-profile for it, so one would need to run the binary
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8Vk1v4zYQ_TX0ZWCDIkV9HHxINjUaYIE9bBc9FqQ4kthIpEFSdtxfX4xsJ9kt2kOBFgigmBzOzJs380idkhs84p6pR6aeNnrJY4h7l2Po3RzOGxPsZf_MRD2D8ydM2Q06Oz_AYA3olDDmxMThrKN3fkjAREM7hXjf_LTaFiWko54T3E2ZaOE8oodjeCGHj18-_7JFC8Z5HR0m6ILP2pEtsIrvBmt-c97iK_1g_IHxh8Ga7XskGDEijDkfE5MPTByYOKSwxA7POuIuxIGJw-Ay7cjDkckn4_yS3ZS2gzU72pGPmpanYJh87Jl8Gqxh4mDPOvaCiUNEbXcdk48jk08FV4pLWfFK9qpQpeKVbBolmsJa1dS6waKuy56TuWHyCZXUDTZVo6pGdW2tmqZvZNHatpWoq86qSiosaybkVCourhipftrbt7KB8_d6TiG8wOReEPKICQk0f2AVv_3xh9sZJh-Il2efMXo9AcYYIi0eO-CvQhalbDUnx4SPvp--UVizZPAh00K6zFmbHRPtX9z-9LfetLURU4JZH__J3ceMya4LM3HexzD_35QqY7oGRdn1bWVLW1urS26asqlM1Vtpm0byQpXyTikXXcFRY2cqicoa07ad6a0tOiUbhUqi5bLoe6JUCt5eKf0aoNeRoJ5HneE6XQmRULsEmRZpGiCFGbObMcGAHqPOmN6KGrUfMN3pd2tf_Dgmbx3xOZyZOPzshvHtPJNPwNQjf-WUyPppic6v7g_qpNsK7X36Bs6u9lJUV5qoIZ8prH-BtHTjPRsTUb9c06EencLguv-ePjLerpjfiGxN3ynJheHY1KbrG1k3wkhVWKGsFqVE3pa8sv-GyFqV61ASU0g1Hx2rOKTFWvTTBQx2gTib9SssU_ADnPS04A6-zC6v2vmxZOjyiJHYWykP8T7gvXvFdK1lH-LaCxD6NeabRD7DqE94lwgyC6s3Op-ym6YPEv29-lIUcpX0jHDWl_uA5veOvGCGH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