GDB 5.2 vs. Ada (and probably other unknown languages)

Florian Weimer
2002-03-31T10:46:39Z

[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]

It seems that GDB (starting with 5.1.1 or so) can no longer debug
programs written in languages unknown to it. With previous GDB
versions, you could at least set breakpoints, get backtraces, and
examine most variables, although you had to take name mangling into
account.

For example, if I try to set a breakpoint in an Ada program, I just
get the error message "internal error - unimplemented function
unk_lang_create_fundamental_type called."

Is there a workaround? Even if full Ada support is not available,
getting backtraces would be helpful in some cases.

Here's a small, stand-alone test program (you have to compile it using
"gcc -S -g no_debug.adb && gcc no_debug.s", as it doesn't use the Ada
run-time library).

package No_Debug is

procedure Main;
pragma Export (C, Main, "main");

end No_Debug;

with System; use System;

package body No_Debug is

procedure Puts (Str : Address);
pragma Import (C, Puts, "puts");

Message : constant String := "Hello, world!" & ASCII.NUL;

procedure Main is
begin
Puts (Message'Address);
end Main;

end No_Debug;

I've attached the x86 assembler code below, in case you want to
experiment yourself without having to install Ada.

[-- Attachment #2: no_debug.s --]
[-- Type: text/plain, Size: 10577 bytes --]

.file "no_debug.adb"
.file 1 "no_debug.adb"
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
.section .debug_info,"",@progbits
.Ldebug_info0:
.section .debug_line,"",@progbits
.Ldebug_line0:
.text
.Ltext0:
.file 2 "/opt/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.2/adainclude/system.ads"
.comm no_debug_E,1,1
.data
.type no_debug__message,@object
.size no_debug__message,14
no_debug__message:
.string "Hello, world!"
.text
.align 2
.globl main
.type main,@function
main:
.LFB1:
.loc 1 10 0
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
subl $8, %esp
.LCFI2:
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
.loc 1 12 0
movl $no_debug__message, (%esp)
call puts
leave
ret
.LFE1:
.Lfe1:
.size main,.Lfe1-main
.section .debug_frame,"",@progbits
.Lframe0:
.long .LECIE0-.LSCIE0
.LSCIE0:
.long 0xffffffff
.byte 0x1
.string ""
.uleb128 0x1
.sleb128 -4
.byte 0x8
.byte 0xc
.uleb128 0x4
.uleb128 0x4
.byte 0x88
.uleb128 0x1
.align 4
.LECIE0:
.LSFDE0:
.long .LEFDE0-.LASFDE0
.LASFDE0:
.long .Lframe0
.long .LFB1
.long .LFE1-.LFB1
.byte 0x4
.long .LCFI0-.LFB1
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI1-.LCFI0
.byte 0xd
.uleb128 0x5
.align 4
.LEFDE0:
.text
.Letext0:
.section .debug_info
.long 0x2b6
.value 0x2
.long .Ldebug_abbrev0
.byte 0x4
.uleb128 0x1
.long .Ldebug_line0
.long .Letext0
.long .Ltext0
.long .LC42
.long .LC43
.long .LC44
.byte 0x3
.uleb128 0x2
.long 0x3e
.long .LC2
.byte 0x10
.byte 0x1
.byte 0x3
.uleb128 0x3
.string "F"
.byte 0x1
.byte 0x3
.long 0x3e
.byte 0x2
.byte 0x23
.uleb128 0x0
.byte 0x0
.uleb128 0x4
.long .LC10
.byte 0xc
.byte 0x4
.uleb128 0x5
.long 0x5e
.long .LC45
.byte 0x1
.byte 0x2
.byte 0x1
.uleb128 0x6
.long .LC0
.byte 0x0
.uleb128 0x6
.long .LC1
.byte 0x1
.byte 0x0
.uleb128 0x2
.long 0xbf
.long .LC3
.byte 0x14
.byte 0x2
.byte 0x1
.uleb128 0x7
.long .LC4
.byte 0x2
.byte 0x1
.long 0x45
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0x7
.long .LC5
.byte 0x2
.byte 0x1
.long 0xbf
.byte 0x2
.byte 0x23
.uleb128 0x1
.uleb128 0x7
.long .LC6
.byte 0x2
.byte 0x1
.long 0xc6
.byte 0x2
.byte 0x23
.uleb128 0x4
.uleb128 0x7
.long .LC7
.byte 0x2
.byte 0x1
.long 0xcd
.byte 0x2
.byte 0x23
.uleb128 0x8
.uleb128 0x7
.long .LC8
.byte 0x2
.byte 0x1
.long 0xcd
.byte 0x2
.byte 0x23
.uleb128 0xc
.uleb128 0x7
.long .LC9
.byte 0x2
.byte 0x1
.long 0xd3
.byte 0x2
.byte 0x23
.uleb128 0x10
.byte 0x0
.uleb128 0x4
.long .LC11
.byte 0x1
.byte 0x7
.uleb128 0x4
.long .LC12
.byte 0x4
.byte 0x7
.uleb128 0x8
.byte 0x4
.long 0xbf
.uleb128 0x4
.long .LC13
.byte 0x4
.byte 0x5
.uleb128 0x2
.long 0x103
.long .LC14
.byte 0x8
.byte 0x1
.byte 0x8
.uleb128 0x3
.string "LB0"
.byte 0x1
.byte 0x8
.long 0x103
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0x3
.string "UB0"
.byte 0x1
.byte 0x8
.long 0x103
.byte 0x2
.byte 0x23
.uleb128 0x4
.byte 0x0
.uleb128 0x4
.long .LC13
.byte 0x4
.byte 0x5
.uleb128 0x2
.long 0x133
.long .LC15
.byte 0x8
.byte 0x1
.byte 0x8
.uleb128 0x7
.long .LC16
.byte 0x1
.byte 0x8
.long 0x14d
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0x7
.long .LC17
.byte 0x1
.byte 0x8
.long 0x153
.byte 0x2
.byte 0x23
.uleb128 0x4
.byte 0x0
.uleb128 0x9
.long 0x146
.long .LC30
.long 0xbf
.uleb128 0xa
.long 0x146
.byte 0x0
.uleb128 0x4
.long .LC18
.byte 0x4
.byte 0x5
.uleb128 0x8
.byte 0x4
.long 0x133
.uleb128 0x8
.byte 0x4
.long 0xda
.uleb128 0xb
.long 0x185
.long .LC19
.long 0xffffffff
.byte 0x1
.byte 0x8
.uleb128 0x7
.long .LC20
.byte 0x1
.byte 0x8
.long 0xda
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0x7
.long .LC21
.byte 0x1
.byte 0x8
.long 0x14d
.byte 0x2
.byte 0x23
.uleb128 0x0
.byte 0x0
.uleb128 0xb
.long 0x1b1
.long .LC22
.long 0xffffffff
.byte 0x1
.byte 0x8
.uleb128 0x7
.long .LC20
.byte 0x1
.byte 0x8
.long 0xda
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0x7
.long .LC23
.byte 0x1
.byte 0x8
.long 0x133
.byte 0x2
.byte 0x23
.uleb128 0xb
.byte 0x0
.uleb128 0xc
.byte 0x1
.long .LC46
.byte 0x1
.byte 0xa
.long .LC47
.long .LFB1
.long .LFE1
.byte 0x1
.byte 0x55
.uleb128 0xd
.long .LC10
.long 0x3e
.uleb128 0xd
.long .LC24
.long 0x25
.uleb128 0xd
.long .LC11
.long 0xbf
.uleb128 0xd
.long .LC25
.long 0xc6
.uleb128 0xd
.long .LC26
.long 0xcd
.uleb128 0xd
.long .LC13
.long 0xd3
.uleb128 0xe
.long .LC27
.byte 0x2
.byte 0x1
.long 0x208
.uleb128 0x4
.long .LC27
.byte 0x4
.byte 0x7
.uleb128 0xf
.long .LC28
.uleb128 0xe
.long .LC29
.byte 0x2
.byte 0x1
.long 0x21f
.uleb128 0x9
.long 0x234
.long .LC29
.long 0x234
.uleb128 0x10
.long 0x146
.byte 0x0
.byte 0x5
.byte 0x0
.uleb128 0x4
.long .LC31
.byte 0x4
.byte 0x5
.uleb128 0xe
.long .LC32
.byte 0x2
.byte 0x69
.long 0x246
.uleb128 0x4
.long .LC33
.byte 0x4
.byte 0x7
.uleb128 0xd
.long .LC34
.long 0x256
.uleb128 0x4
.long .LC35
.byte 0x4
.byte 0x7
.uleb128 0xd
.long .LC36
.long 0x133
.uleb128 0xd
.long .LC37
.long 0x26f
.uleb128 0x8
.byte 0x4
.long 0x185
.uleb128 0xd
.long .LC38
.long 0x27e
.uleb128 0x4
.long .LC39
.byte 0x4
.byte 0x7
.uleb128 0xd
.long .LC40
.long 0x28e
.uleb128 0x9
.long 0x2a3
.long .LC41
.long 0xbf
.uleb128 0x10
.long 0x146
.byte 0x1
.byte 0xe
.byte 0x0
.uleb128 0x11
.long .LC48
.byte 0x1
.byte 0x8
.long 0x2b4
.byte 0x5
.byte 0x3
.long no_debug__message
.uleb128 0x12
.long 0x28e
.byte 0x0
.section .debug_abbrev
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x10
.uleb128 0x6
.uleb128 0x12
.uleb128 0x1
.uleb128 0x11
.uleb128 0x1
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1b
.uleb128 0xe
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x2
.uleb128 0x13
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x3
.uleb128 0xd
.byte 0x0
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x4
.uleb128 0x24
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x5
.uleb128 0x4
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x6
.uleb128 0x28
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1c
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x7
.uleb128 0xd
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x8
.uleb128 0xf
.byte 0x0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0x9
.uleb128 0x1
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3
.uleb128 0xe
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0xa
.uleb128 0x21
.byte 0x0
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0xb
.uleb128 0x13
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0x6
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0xc
.uleb128 0x2e
.byte 0x0
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x2007
.uleb128 0xe
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x40
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0xd
.uleb128 0x16
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0xe
.uleb128 0x16
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0xf
.uleb128 0x16
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.byte 0x0
.byte 0x0
.uleb128 0x10
.uleb128 0x21
.byte 0x0
.uleb128 0x49
.uleb128 0x13
.uleb128 0x22
.uleb128 0xb
.uleb128 0x2f
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x11
.uleb128 0x34
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x12
.uleb128 0x26
.byte 0x0
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.byte 0x0
.section .debug_pubnames,"",@progbits
.long 0x20
.value 0x2
.long .Ldebug_info0
.long 0x2ba
.long 0x1b1
.string "no_debug.main"
.long 0x0
.section .debug_aranges,"",@progbits
.long 0x1c
.value 0x2
.long .Ldebug_info0
.byte 0x4
.byte 0x0
.value 0x0
.value 0x0
.long .Ltext0
.long .Letext0-.Ltext0
.long 0x0
.long 0x0
.section .debug_str,"MS",@progbits,1
.LC23:
.string "ARRAY"
.LC10:
.string "long_long_float"
.LC5:
.string "lang"
.LC26:
.string "access_character"
.LC17:
.string "P_BOUNDS"
.LC42:
.string "no_debug.adb"
.LC44:
.string "GNU Ada 3.2 20020330 (experimental)"
.LC38:
.string "no_debug.TTmessageSP1._XDLU_1"
.LC35:
.string "positive___XDLU_1__2147483647"
.LC4:
.string "not_handled_by_others"
.LC48:
.string "no_debug.message"
.LC8:
.string "htable_ptr"
.LC28:
.string "void"
.LC37:
.string "string._XU"
.LC32:
.string "system.address"
.LC24:
.string "long_long_float._PAD"
.LC3:
.string "exception"
.LC9:
.string "import_code"
.LC45:
.string "boolean"
.LC34:
.string "positive._XDLU_1"
.LC47:
.string "main"
.LC16:
.string "P_ARRAY"
.LC12:
.string "natural___XDLU_0__2147483647"
.LC39:
.string "no_debug__TTmessageSP1___XDLU_1__14"
.LC20:
.string "BOUNDS"
.LC41:
.string "no_debug__TmessageS"
.LC0:
.string "false"
.LC19:
.string "string___XUT___XVE"
.LC25:
.string "natural._XDLU_0"
.LC27:
.string "unsigned int"
.LC2:
.string "long_long_float___PAD"
.LC43:
.string "/tmp"
.LC1:
.string "true"
.LC6:
.string "name_length"
.LC40:
.string "no_debug.TmessageS"
.LC30:
.string "string___XUA"
.LC14:
.string "string___XUB"
.LC15:
.string "string___XUP"
.LC22:
.string "string___XUT"
.LC21:
.string "ARRAY._XVL"
.LC46:
.string "no_debug.main"
.LC33:
.string "system__address"
.LC31:
.string "SIGNED_32"
.LC29:
.string "JMPBUF_T"
.LC36:
.string "string._XUA"
.LC7:
.string "full_name"
.LC11:
.string "character"
.LC18:
.string "long int"
.LC13:
.string "integer"
.ident "GCC: (GNU) 3.2 20020330 (experimental)"