; -------------------------------------------------------------------------------- ; @Title: Dialog to load a Linux Core Dump File ; @Description: ; This script opens a dialog to load a core dump file generated after a crash ; on a Linux system. ; @Keywords: crash, GDB, GNU ; @Author: KJM ; @Copyright: (C) 1989-2018 Lauterbach GmbH, licensed for use with TRACE32(R) only ; -------------------------------------------------------------------------------- ; $Id: coreload.cmm 12576 2018-05-08 08:48:11Z msamet $ LOCAL &dynamic &debug_base &lm &tmp &name_addr &offset &filepath &corefile &elffile &libpath &last_path &elfname &step_width &readFunc &lm_step &endRange &step_width=0x4 &readFunc="Data.Long" &lm_step=0xC ; 3 x &step_width IF CPUIS64BIT() ( &step_width=0x8 &readFunc="Data.Quad" &lm_step=0x18 ; 3 x &step_width ) &last_path=OS.PPD() DIALOG.view ( HEADER "Linux Core Dump File Loader" POS 1. 1. 10. TEXT "Core File" POS 11. 1. 30. CORE: EDIT "" "gosub set_core_file" POS 43. 1. 3. 1. BUTTON "..." "GOSUB browse_file CORE corefile *" POS 1. 2. 10. TEXT "Elf File :" POS 11. 2. 30. ELF: EDIT "" "gosub set_elf_file" POS 43. 2. 3. 1. BUTTON "..." "GOSUB browse_file ELF elffile *" POS 1. 3. 10. TEXT "Libs Path :" POS 11. 3. 30. LIB: EDIT "" "gosub set_libpath" POS 43. 3. 3. 1. BUTTON "..." "GOSUB browse_libpath" POS 19. 5. 10. 1. START: BUTTON "Start" "jumpto startme" POS 0. 0. 47. 7. BOX "" CLOSE "jumpto winclose" ) STOP winclose: DIALOG.END ENDDO set_elf_file: LOCAL &str &str=DIALOG.STRing(ELF) &elffile="&str" RETURN set_core_file: LOCAL &str &str=DIALOG.STRing(CORE) &corefile="&str" RETURN set_libpath: LOCAL &str &str=DIALOG.STRing(LIB) &libpath="&str" RETURN browse_libpath: LOCAL &str LOCAL &directory &directory="&last_path"+"/*" DIALOG.DIR &directory ENTRY &str IF "&str"=="" RETURN &str="&str" &libpath="&str" DIALOG.Set LIB "&str" RETURN browse_file: LOCAL &str &label &item ENTRY &label &item &ext &str=DIALOG.STRing(&label) &str=OS.FILE.PATH("&str") IF "&str"!="" &str="&last_path"+"/"+"&ext" DIALOG.File "&str" ENTRY &str IF "&str"=="" RETURN &assignment="&"+"&item"+"="+"""&str""" &assignment DIALOG.Set &label "&str" &last_path=OS.FILE.PATH("&str") RETURN startme: DIALOG.END WinCLEAR AREA.CLEAR RESet SYStem.Up IF "&corefile"=="" ENDDO IF "&libpath"!="" sYmbol.SourcePATH.SetDir &libpath sYmbol.AutoLOAD.CHECKCoMmand "do ~~/demo/etc/coredump/autoload.cmm " Data.LOAD.CORE "&corefile" /NoClear IF "&elffile"!="" Data.LOAD.Elf "&elffile" /NoClear /ia64 /NOREGISTER /NoCODE IF "&elffile"!="" ( ; strip name extension (.elf / .exe) if existing &elffile=OS.FILE.NAME(&elffile) &elfname=STRing.SPLIT("&elffile",".",0) ) &debug_base=0 &dynamic=ADDRESS.OFFSET(sYmbol.SECADDRESS(\\&elfname\.dynamic)) &endRange=ADDRESS.OFFSET(sYmbol.SECEND(\\&elfname\.dynamic)) loop: &tmp="D:"+"&dynamic" &tmp=&readFunc(&tmp) IF &tmp==0x15 ( &dynamic=&dynamic+&step_width &tmp="D:"+"&dynamic" &debug_base=&readFunc(&tmp) ) ELSE ( &dynamic=&dynamic+&step_width IF &dynamic<&endRange GOTO loop ) IF &debug_base==0 ENDDO &tmp=&debug_base+&step_width &tmp="D:"+"&tmp" &lm=&readFunc(&tmp) ; discard first entry IF &lm==0 ENDDO next: &tmp=&lm+&lm_step &tmp="D:"+"&tmp" &lm=&readFunc(&tmp) IF &lm==0 ( WinCLEAR ; Open some windows WinPOS 0% 0% 100% 50% List.auto WinPOS 0% 50% 50% 25% Frame /Locals /Caller WinPOS 50% 50% 50% 50% AREA WinPOS 0% 75% 50% 25% Register ENDDO ) &tmp=&lm+&step_width &tmp="D:"+"&tmp" &name_addr=&readFunc(&tmp) &tmp="D:"+"&name_addr" &namestr=Data.STRing(&tmp) &tmp="D:"+"&lm" &offset=&readFunc(&tmp) PRINT "&namestr" " at offset " "&offset" &filepath="&namestr" IF ("&libpath"!="") ( &tmp=OS.FILE.NAME("&namestr") &filepath="&libpath"+"/"+"&tmp" ) IF !OS.FILE("&filepath") ( &namestr=OS.FILE.NAME("&namestr") &filepath=sYmbol.SEARCHFILE("&filepath") ) IF !OS.FILE("&filepath") ( LOCAL &file &spath WinPOS ,,,,,, filebox normal "Searching symbols for &namestr" DIALOG.File "*&file*" ENTRY %LINE &filepath IF "&filepath"=="" GOTO next &spath=OS.FILE.PATH("&filepath") sYmbol.SourcePATH.Set "&spath" ) IF OS.FILE("&filepath") ( Data.LOAD.Elf "&filepath" &offset /NoClear /NOREG ) GOTO next set_target: SYStem.CPU * SYStem.Up RETURN