Why does gdb think my x86-64 program is i386?
fpc, freepascal, gdb, x86-64
Solution
Your problem starts here:
gdbarch_find_by_info: Target rejected architecture
This means that target-dependent code in GDB didn't like something about the `i386:x86-64` architecture. Unfortunately there is no easy way to tell what it didn't like -- you'll have to debug GDB itself to find that out.
Can you debug other binaries (e.g. `/bin/date`) on the machine where GDB fails?
Problem
I am attempting to debug a 64-bit program but gdb seems to think it has an i386 architecture. ``` # file /usr/local/bin/foo /usr/local/bin/foo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.0, not stripped # gdb --args foo bar GNU gdb (GDB) 7.3.1 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /usr/local/bin/foo...done. (gdb) set debug arch 1 (gdb) show debug arch Architecture debugging is 1. (gdb) info target Symbols from "/usr/local/bin/foo". Local exec file: gdbarch_find_by_info: info.bfd_arch_info i386:x86-64 gdbarch_find_by_info: info.byte_order 1 (little) gdbarch_find_by_info: info.osabi 5 (GNU/Linux) gdbarch_find_by_info: info.abfd 0xaf4a90 gdbarch_find_by_info: info.tdep_info 0x0 gdbarch_find_by_info: Previous architecture 0xb05790 (i386:x86-64) selected `/usr/local/bin/foo', file type elf64-x86-64. Entry point: 0x419730 0x00000000004001c8 - 0x00000000004001e4 is .interp 0x00000000004001e4 - 0x0000000000400204 is .note.ABI-tag 0x0000000000400208 - 0x0000000000402560 is .hash 0x0000000000402560 - 0x0000000000409898 is .dynsym 0x0000000000409898 - 0x0000000000411188 is .dynstr 0x0000000000411188 - 0x0000000000411b22 is .gnu.version 0x0000000000411b28 - 0x0000000000411b88 is .gnu.version_r 0x0000000000411b88 - 0x00000000004181a0 is .rela.dyn 0x00000000004181a0 - 0x0000000000418e78 is .rela.plt 0x0000000000418e78 - 0x0000000000418e90 is .init 0x0000000000418e90 - 0x0000000000419730 is .plt 0x0000000000419730 - 0x00000000004ede38 is .text 0x00000000004ede38 - 0x00000000004ede46 is .fini 0x00000000004ede48 - 0x00000000004ede4c is .eh_frame 0x00000000006ee000 - 0x00000000006ee010 is .ctors 0x00000000006ee010 - 0x00000000006ee020 is .dtors 0x00000000006ee020 - 0x00000000006ee028 is .jcr 0x00000000006ee028 - 0x00000000006ee1f8 is .dynamic 0x00000000006ee1f8 - 0x00000000006f07f0 is .got 0x00000000006f07f0 - 0x00000000006f0c50 is .got.plt 0x00000000006f0c50 - 0x0000000000736c70 is .data 0x0000000000736c70 - 0x000000000073b420 is .bss (gdb) start Temporary breakpoint 1 at 0x419e70: file foo.lpr, line 69. Starting program: /usr/local/bin/foo bar warning: Selected architecture i386:x86-64 is not compatible with reported target architecture i386 gdbarch_find_by_info: info.bfd_arch_info i386:x86-64 gdbarch_find_by_info: info.byte_order 1 (little) gdbarch_find_by_info: info.osabi 5 (GNU/Linux) gdbarch_find_by_info: info.abfd 0xaf4a90 gdbarch_find_by_info: info.tdep_info 0x0 gdbarch_find_by_info: Target rejected architecture gdbarch_update_p: Architecture not found warning: Architecture rejected target-supplied description gdbarch_find_by_info: info.bfd_arch_info i386:x86-64 gdbarch_find_by_info: info.byte_order 1 (little) gdbarch_find_by_info: info.osabi 5 (GNU/Linux) gdbarch_find_by_info: info.abfd 0xd6ce90 gdbarch_find_by_info: info.tdep_info 0x0 gdbarch_find_by_info: Previous architecture 0xb05790 (i386:x86-64) selected Error in re-setting breakpoint 1: Cannot access memory at address 0x419e60 Error in re-setting breakpoint 1: Cannot access memory at address 0x419e60 process 5299 is executing new program: /usr/local/bin/foo warning: Selected architecture i386:x86-64 is not compatible with reported target architecture i386 gdbarch_find_by_info: info.bfd_arch_info i386:x86-64 gdbarch_find_by_info: info.byte_order 1 (little) gdbarch_find_by_info: info.osabi 5 (GNU/Linux) gdbarch_find_by_info: info.abfd 0xb21790 gdbarch_find_by_info: info.tdep_info 0x0 gdbarch_find_by_info: Target rejected architecture Architecture of file not recognized. ``` Note the warning: ``` warning: Selected architecture i386:x86-64 is not compatible with reported target architecture i386 ``` and then: ``` gdbarch_find_by_info: Target rejected architecture gdbarch_update_p: Architecture not found warning: Architecture rejected target-supplied description ``` In gdb, if I type 'set architecture' and hit tab, I see the following: ``` (gdb) set architecture auto i386:intel i386:x64-32:intel i386:x86-64:intel i386 i386:x64-32 i386:x86-64 i8086 ``` My question is: why does gdb think my file has an i386 architecture even though it is obviously an x86-64 binary and what can I do to fix it? My program was compiled using FreePascal version 2.6.0. UPDATE: I do not get any warnings using the same gdb binary and the same freepascal binary on my Ubuntu 12.04 machine (with a 3.2.0-31 kernel). The server I am attempting to debug on is running a 2.6.34.10-24 kernel. Could something be misconfigured in the kernel or on the server that would affect gdb?