[PATCH] D51908: [DebugInfo] Do not generate debug info for removed labels.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 11 23:15:44 PDT 2018


HsiangKai added a comment.

If it has no DW_AT_low_pc in label debug info, GDB seems to assume it is 0x0.

  (gdb) info scope foo
  Scope for foo:
  Symbol done is a label at address 0x400551, length 8.
  Symbol unreach is a label at address 0x0, length 8.

llvm-dwarfdump results:

  0x00000056:     DW_TAG_label
                    DW_AT_abstract_origin (0x00000075 "done")
                    DW_AT_low_pc  (0x0000000000400551)
  
  0x00000063:     DW_TAG_label
                    DW_AT_abstract_origin (0x0000007c "unreach")
  
  0x00000068:     NULL
  ...
  0x00000075:     DW_TAG_label
                    DW_AT_name    ("done")
                    DW_AT_decl_file       ("edd2.c")
                    DW_AT_decl_line       (13)
  
  0x0000007c:     DW_TAG_label
                    DW_AT_name    ("unreach")
                    DW_AT_decl_file       ("edd2.c")
                    DW_AT_decl_line       (11)
  
  0x00000083:     NULL

It will trigger assertions in GDB if we set breakpoint on labels with address 0x0 on x86 platform.

  (gdb) b foo:done
  Note: breakpoint 1 also set at pc 0x400581.
  Breakpoint 2 at 0x400551: foo:done. (2 locations)
  (gdb) list foo:done
  8       int foo(void)
  9       {
  10          goto done;
  11      unreach:
  12          printf("hi\n");
  13      done:
  14          return rand() % 666;
  15      }
  16
  17      int main()
  (gdb) list foo:unreach
  6       }
  7
  8       int foo(void)
  9       {
  10          goto done;
  11      unreach:
  12          printf("hi\n");
  13      done:
  14          return rand() % 666;
  15      }
  (gdb) b foo:unreach
  /build/gdb-GT4MLW/gdb-8.1/gdb/linespec.c:3302: internal-error: void decode_line_full(const
   event_location*, int, program_space*, symtab*, int, linespec_result*, const char*, const
  char*): Assertion `result.size () == 1 || canonical->pre_expanded' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n)

So, to avoid the assertion failed in GDB, I removed debug info of these unreachable labels in this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D51908





More information about the llvm-commits mailing list