On Nov 28, 2012, at 9:47 PM, Shivamurthy Shastri wrote:

> On Thu, Nov 29, 2012 at 1:28 AM, Andrew Fish <[email protected]> wrote:
> 
> On Nov 28, 2012, at 11:18 AM, Shivamurthy Shastri wrote:
> 
>> Hi Andrew,
>> 
>> I am using Trace32 for debugging.
> 
> Not sure if there a scripts around for this, maybe the ARM Ltd. guys would 
> know? The ARM JTAG debugger scripts seem to live @ 
> https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ArmPlatformPkg/Scripts/Ds5/
> 
> I just noticed this in the BeagleBoardPkg: 
> https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/BeagleBoardPkg/Debugger_scripts/trace32_load_symbols.cmm
> 
> So the load_symbols: command is not what you want as it does the DXE lookup 
> the table and find  all the symbols thing. You want to use the basic 
> load_symbol_file:. 
> 
>> I need COFF file for debugging. Is there any single final COFF file for 
>> debugging?
>> 
> 
> Not sure what you mean by that. I think the answer is NO. The *.EFI file is 
> the PE/COFF image and it is linked at 0x000 or ~0x240 (converted from 
> ELF/Mach-O). So it is the correct image, but not relocated to its executable 
> address. The tool that constructs the FV/FD does this final relocation. So 
> what you have to do in the debugger is tell the debugger where the symbols 
> are loaded.
> 
> 
> I need the final relocated COFF file, which might be generated before *.FD 
> file. The FD file is binary, so I can not use that for debugging.
> 

As I mentioned before there is no final relocated PE/COFF image. The final 
relocation is done by the tool the creates the FV, when the FV is being 
created.  You are looking at this problem all wrong. You don't need the final 
relocated PE/COFF image to load symbols in the debugger.  For example if you 
load the EFI Shell into memory it does not load at its linked address, it loads 
at the address dynamically allocated by the DXE Core when the shell is loaded. 
So you have to tell the debugger the file name and load address. So if you just 
treat the code that runs from the FD/FV the same way it will work. 

Thanks,

Andrew

>  
> Something like:
> load_symbol_file 
> Build/ArmVExpress-RTSM-A15_MPCore/DEBUG_ARMLINUXGCC/ARM/ArmPlatformPkg/Sec/Sec/DEBUG/SecMain.dll
>  0xEF0001240
> 
> The file name you give is NOT the PE/COFF .efi file. It needs to be the file 
> that contains the symbolic debug information. So it could the the original 
> ELF. For a Microsoft toolchain this is the *.pdb file. 
> 
> If I do a quick look I see a file in the build results directory that may be 
> helpful for you (here is my example): 
> Build/Emulator/DEBUG_XCLANG/EmulatorPkg.map
> 
> EmuSec (Fixed Flash Address, BaseAddress=0x01020001a0, 
> EntryPoint=0x0102003a90)
> (GUID=BCAF98C9-22B0-3B4F-9CBD-C8A6B4DBCEE9 .textbaseaddress=0x01020003e0 
> .databaseaddress=0x0102004fc0)
> (IMAGE=/Users/fish/work/edk2TOT/Build/Emulator/DEBUG_XCLANG/X64/EmulatorPkg/Sec/Sec/DEBUG/EmuSec.efi)
> 
> 
> 
> PeiCore (Fixed Flash Address, BaseAddress=0x01020052a0, 
> EntryPoint=0x0102008af0)
> (GUID=52C05B14-0B98-496C-BC3B-04B50211D680 .textbaseaddress=0x01020054e0 
> .databaseaddress=0x0102019740)
> (IMAGE=/Users/fish/work/edk2TOT/Build/Emulator/DEBUG_XCLANG/X64/MdeModulePkg/Core/Pei/PeiMain/DEBUG/PeiCore.efi)
> 
> ....
> 
> It should be possible to post process this file and build a file you can 
> import into Trace32 to load symbols for all the execute from FD/FV code. 
> 
> BaseAddress == your load addresss and IMAGE == the PE/COFF file (remember it 
> points to the file that contains the symbols). 
> In this example since I built with clang and produced a Mach-O my load 
> command would look like:
> load_symbol_file 
> /Users/fish/work/edk2TOT/Build/Emulator/DEBUG_XCLANG/X64/MdeModulePkg/Core/Pei/PeiMain/DEBUG/PeiCore.dll
>  0x01020003e0
> 
> I know that my PE/COFF points to the Mach-O for the symbols and the Mach-O 
> has a .dll extension. Also you can see by the textbaseaddress that this image 
> is linked at 0x240 and not zero, and the Mach-O (ELF) file has no concept of 
> the first 0x240 bytes that contain the PE/COFF header this is why you have to 
> add 0x240 to the load address. 
> 
> Good Luck!
> 
> Andrew
> 
> PS If your debugger is PE/COFF aware it may be possible to pass the PE/COFF 
> *.efi file directly. But the debugger is going the crack open the PE/COFF 
> file and find the debug directory entry  that points to the symbol file and 
> load it for you.  
> 
>> 

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
VERIFY Test and improve your parallel project with help from experts 
and peers. http://goparallel.sourceforge.net
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to