On 2012-10-24 12:34, Volodymyr Kostyrko wrote:
...
Can you attempt to figure out what the illegal instruction was, in that
case?
How can I do that? I'm not very familiar with gdb.

Try the following:

  $ gdb /path/to/crashed-program /path/to/crashed-program.core
  GNU gdb (GDB) 7.5 [GDB v7.5 for FreeBSD]
  Copyright (C) 2012 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 "i386-portbld-freebsd10.0".
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>...
  Reading symbols from /path/to/crashed-program...(no debugging symbols 
found)...done.
  [New process 100137]
  Core was generated by `crashed-program'.
  Program terminated with signal 4, Illegal instruction.
  #0  0x08048632 in main ()
  (gdb) disassemble
  Dump of assembler code for function main:
     0x08048600 <+0>:     push   %ebp
     0x08048601 <+1>:     mov    %esp,%ebp
     0x08048603 <+3>:     sub    $0x18,%esp
     0x08048606 <+6>:     lea    0x80486b0,%eax
     0x0804860c <+12>:    movl   $0x0,-0x4(%ebp)
     0x08048613 <+19>:    mov    %eax,(%esp)
     0x08048616 <+22>:    call   0x8048390 <printf@plt>
     0x0804861b <+27>:    mov    0x8049868,%ecx
     0x08048621 <+33>:    mov    %ecx,(%esp)
     0x08048624 <+36>:    mov    %eax,-0x8(%ebp)
     0x08048627 <+39>:    call   0x80483c0 <fflush@plt>
     0x0804862c <+44>:    lea    0x80486ce,%ecx
  => 0x08048632 <+50>:    (bad)
     0x08048633 <+51>:    (bad)
     0x08048634 <+52>:    (bad)
     0x08048635 <+53>:    (bad)
     0x08048636 <+54>:    (bad)
     0x08048637 <+55>:    (bad)
     0x08048638 <+56>:    (bad)
     0x08048639 <+57>:    decl   0x4589240c(%ecx)
     0x0804863f <+63>:    hlt
     0x08048640 <+64>:    call   0x8048390 <printf@plt>
     0x08048645 <+69>:    mov    0x8049868,%ecx
     0x0804864b <+75>:    mov    %ecx,(%esp)
     0x0804864e <+78>:    mov    %eax,-0x10(%ebp)
     0x08048651 <+81>:    call   0x80483c0 <fflush@plt>
     0x08048656 <+86>:    mov    $0x0,%ecx
     0x0804865b <+91>:    mov    %eax,-0x14(%ebp)
     0x0804865e <+94>:    mov    %ecx,%eax
     0x08048660 <+96>:    add    $0x18,%esp
     0x08048663 <+99>:    pop    %ebp
     0x08048664 <+100>:   ret
  End of assembler dump.
  (gdb) info registers
  eax            0x0      0
  ecx            0x80486ce        134514382
  edx            0x2819a8d4       672770260
  ebx            0xbfbfd650       -1077946800
  esp            0xbfbfd5e0       0xbfbfd5e0
  ebp            0xbfbfd5f8       0xbfbfd5f8
  esi            0xbfbfd64c       -1077946804
  edi            0x0      0
  eip            0x8048632        0x8048632 <main+50>
  eflags         0x10286  [ PF SF IF RF ]
  cs             0x33     51
  ss             0x3b     59
  ds             0x3b     59
  es             0x3b     59
  fs             0x3b     59
  gs             0x1b     27

It should highlight the illegal instruction with the => arrow.  Just
copy/paste the whole piece of assembly, and the registers info.


...
On the problematic athlons, can you please post the exact CPUIDs from
dmesg?  If you have WITH_CLANG_EXTRAS enabled, please also post the
output of "opt -version".

Oct 24 01:47:20 limbo kernel: CPU: AMD Athlon(tm) XP 2500+ (1833.95-MHz
686-class CPU)
Oct 24 01:47:20 limbo kernel: Origin = "AuthenticAMD"  Id = 0x6a0
Family = 0x6  Model = 0xa  Stepping = 0

Ok, this CPU should be recognized by llvm as "athlon-xp".  There is in
fact no need to compile all the WITH_CLANG_EXTRAS programs, I just
remembered.

If you compile a sample program with -march=native -v, it should show
you the detected CPU in the verbose command line output, e.g.:

  $ clang -v -march=native -c /home/dim/src/example.c
  FreeBSD clang version 3.2 (trunk 162107) 20120817
  Target: i386-unknown-freebsd10.0
  Thread model: posix
   "/usr/bin/clang" -cc1 -triple i386-unknown-freebsd10.0 -emit-obj -mrelax-all 
-disable-free -main-file-name example.c -mrelocation-model static -mdisable-fp-elim 
-masm-verbose -mconstructor-aliases -target-cpu core2 -momit-leaf-frame-pointer -v 
-coverage-file hw.o -resource-dir /usr/bin/../lib/clang/3.2 -fmodule-cache-path 
/home/dim/tmp/clang-module-cache -fdebug-compilation-dir /home/dim/src -ferror-limit 19 
-fmessage-length 265 -mstackrealign -fobjc-runtime=gnustep -fdiagnostics-show-option 
-fcolor-diagnostics -o hw.o -x c /home/dim/src/example.c
  clang -cc1 version 3.2 based upon LLVM 3.2svn default target 
i386-unknown-freebsd10.0
  ignoring nonexistent directory "/usr/bin/../lib/clang/3.2/include"
  #include "..." search starts here:
  #include <...> search starts here:
   /usr/include/clang/3.2
   /usr/include
  End of search list.

In my case, it uses "-target-cpu core2", as you can see.
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to