TianoCore EDK2 master
Loading...
Searching...
No Matches
EdbSymbol.c File Reference
#include "Edb.h"

Go to the source code of this file.

Data Structures

struct  EFI_DEBUG_IMAGE_INFO_TABLE_HEADER_OLD
 

Enumerations

enum  EDB_EBC_MAP_PARSE_STATE {
  EdbEbcMapParseStateUninitialized , EdbEbcMapParseStateSymbolStart , EdbEbcMapParseStateSeHandlerSymbol , EdbEbcMapParseStateFunctionSymbol ,
  EdbEbcMapParseStateVarbssInitSymbol , EdbEbcMapParseStateCrtSymbol , EdbEbcMapParseStateVariableSymbol , EdbEbcMapParseStateStaticFunctionSymbol ,
  EdbEbcMapParseStateMax
}
 
enum  EDB_EBC_SYMBOL_PARSE_STATE {
  EdbEbcSymbolParseStateUninitialized , EdbEbcSymbolParseStateReadyForName , EdbEbcSymbolParseStateReadyForRVA , EdbEbcSymbolParseStateReadyForType ,
  EdbEbcSymbolParseStateReadyForObject , EdbEbcSymbolParseStateMax
}
 
enum  EDB_EBC_COD_PARSE_STATE {
  EdbEbcCodParseStateUninitialized , EdbEbcCodParseStateSymbolInitialized , EdbEbcCodParseStateSymbolStart , EdbEbcCodParseStateSymbolEnd ,
  EdbEbcCodParseStateMax
}
 
enum  EDB_EBC_LINE_SEARCH_TYPE { EdbEbcLineSearchTypeAny , EdbEbcLineSearchTypeFirst , EdbEbcLineSearchTypeLast , EdbEbcLineSearchTypeMax }
 

Functions

EFI_STATUS EdbLoadSymbolSingleEntry (IN EFI_DEBUGGER_SYMBOL_OBJECT *Object, IN CHAR8 *Name, IN CHAR8 *ObjName, IN UINTN Address, IN EFI_DEBUGGER_SYMBOL_TYPE Type)
 
EFI_STATUS EdbLoadSymbolEntryByIec (IN EFI_DEBUGGER_SYMBOL_OBJECT *Object, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EdbLoadSymbolEntry (IN EFI_DEBUGGER_SYMBOL_OBJECT *Object, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_DEBUGGER_SYMBOL_OBJECTEdbFindSymbolFile (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN OUT UINTN *Index OPTIONAL)
 
UINTN EbdFindSymbolAddress (IN UINTN Address, IN EDB_MATCH_SYMBOL_TYPE Type, OUT EFI_DEBUGGER_SYMBOL_OBJECT **RetObject, OUT EFI_DEBUGGER_SYMBOL_ENTRY **RetEntry)
 
EFI_STATUS EdbUnloadSymbol (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName)
 
EFI_STATUS EdbLoadSymbol (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer)
 
CHAR8 * GetPdbPath (VOID *ImageBase)
 
BOOLEAN MatchPdbAndMap (IN CHAR8 *PdbFileName, IN CHAR16 *MapFileName)
 
VOID EdbFixDebugImageInfoTable (IN OUT EFI_DEBUG_IMAGE_INFO_TABLE_HEADER **DebugImageInfoTableHeader)
 
EFI_STATUS EdbPatchSymbolRVA (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType)
 
BOOLEAN MatchObjAndCod (IN CHAR8 *ObjFileName, IN CHAR16 *CodFileName)
 
CHAR8 * EdbLoadCodBySymbolByIec (IN CHAR8 *Name, IN VOID *Buffer, IN UINTN BufferSize, OUT UINTN *CodeBufferSize, OUT UINTN *FuncOffset)
 
CHAR8 * EdbLoadCodBySymbol (IN CHAR8 *Name, IN VOID *Buffer, IN UINTN BufferSize, OUT UINTN *CodeBufferSize, OUT UINTN *FuncOffset)
 
VOID * EdbFindCodeFromObject (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_DEBUGGER_SYMBOL_OBJECT *Object, IN CHAR16 *FileName)
 
EFI_STATUS EdbLoadCode (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EdbUnloadCode (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *FileName, OUT VOID **Buffer)
 
EFI_STATUS EdbAddCodeBuffer (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *CodeFileName, IN UINTN SourceBufferSize, IN VOID *SourceBuffer)
 
EFI_STATUS EdbDeleteCodeBuffer (IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *CodeFileName, IN VOID *SourceBuffer)
 
CHAR8 * FindSymbolStr (IN UINTN Address)
 
UINTN EdbGetLineNumberAndOffsetFromThisLine (IN VOID *Line, OUT UINTN *Offset)
 
UINTN EdbGetLineNumberFromCode (IN EFI_DEBUGGER_SYMBOL_ENTRY *Entry, IN UINTN FuncOffset, IN EDB_EBC_LINE_SEARCH_TYPE SearchType)
 
VOID * EdbGetSourceStrFromCodeByLine (IN EFI_DEBUGGER_SYMBOL_ENTRY *Entry, IN UINTN LineNumber, IN VOID **FuncEnd)
 
VOID * EdbGetSourceStrFromCode (IN EFI_DEBUGGER_SYMBOL_ENTRY *Entry, IN UINTN FuncOffset, IN VOID **FuncEnd)
 
UINTN EdbPrintSource (IN UINTN Address, IN BOOLEAN IsPrint)
 
VOID GetMapfileAndSymbol (IN CHAR16 *Symbol, OUT CHAR16 **MapfileName, OUT CHAR16 **SymbolName)
 
EFI_STATUS Symboltoi (IN CHAR16 *Symbol, OUT UINTN *Address)
 

Variables

EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugImageInfoTableHeader
 

Detailed Description

Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EdbSymbol.c.

Enumeration Type Documentation

◆ EDB_EBC_COD_PARSE_STATE

enum EDB_EBC_COD_PARSE_STATE

Definition at line 1170 of file EdbSymbol.c.

◆ EDB_EBC_LINE_SEARCH_TYPE

enum EDB_EBC_LINE_SEARCH_TYPE

Definition at line 1858 of file EdbSymbol.c.

◆ EDB_EBC_MAP_PARSE_STATE

enum EDB_EBC_MAP_PARSE_STATE

Definition at line 79 of file EdbSymbol.c.

◆ EDB_EBC_SYMBOL_PARSE_STATE

enum EDB_EBC_SYMBOL_PARSE_STATE

Definition at line 91 of file EdbSymbol.c.

Function Documentation

◆ EbdFindSymbolAddress()

UINTN EbdFindSymbolAddress ( IN UINTN  Address,
IN EDB_MATCH_SYMBOL_TYPE  Type,
OUT EFI_DEBUGGER_SYMBOL_OBJECT **  RetObject,
OUT EFI_DEBUGGER_SYMBOL_ENTRY **  RetEntry 
)

Find symbol by address.

Parameters
Address- Symbol address
Type- Search type
RetObject- Symbol object
RetEntry- Symbol entry
Returns
Nearest symbol address

Definition at line 477 of file EdbSymbol.c.

◆ EdbAddCodeBuffer()

EFI_STATUS EdbAddCodeBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  MapFileName,
IN CHAR16 *  CodeFileName,
IN UINTN  SourceBufferSize,
IN VOID *  SourceBuffer 
)

Add code buffer.

Parameters
DebuggerPrivate- EBC Debugger private data structure
MapFileName- Symbol file name
CodeFileName- Code file name
SourceBufferSize-Code buffer size
SourceBuffer- Code buffer
Return values
EFI_SUCCESS- CodeBuffer added successfully

Definition at line 1630 of file EdbSymbol.c.

◆ EdbDeleteCodeBuffer()

EFI_STATUS EdbDeleteCodeBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  MapFileName,
IN CHAR16 *  CodeFileName,
IN VOID *  SourceBuffer 
)

Delete code buffer.

Parameters
DebuggerPrivate- EBC Debugger private data structure
MapFileName- Symbol file name
CodeFileName- Code file name
SourceBuffer- Code buffer
Return values
EFI_SUCCESS- CodeBuffer deleted successfully

Definition at line 1674 of file EdbSymbol.c.

◆ EdbFindCodeFromObject()

VOID * EdbFindCodeFromObject ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN EFI_DEBUGGER_SYMBOL_OBJECT Object,
IN CHAR16 *  FileName 
)

Find code from object.

Parameters
DebuggerPrivateEBC Debugger private data structure
Object- Symbol object
FileName- File name

Definition at line 1375 of file EdbSymbol.c.

◆ EdbFindSymbolFile()

EFI_DEBUGGER_SYMBOL_OBJECT * EdbFindSymbolFile ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  FileName,
IN OUT UINTN *Index  OPTIONAL 
)

Find symbol file by name.

Parameters
DebuggerPrivate- EBC Debugger private data structure
FileName- Symbol file name
Index- Symbol file index
Returns
Object

Definition at line 434 of file EdbSymbol.c.

◆ EdbFixDebugImageInfoTable()

VOID EdbFixDebugImageInfoTable ( IN OUT EFI_DEBUG_IMAGE_INFO_TABLE_HEADER **  DebugImageInfoTableHeader)

For compatibility consideration, we handle 2 cases:

1) IA32: Old: New: +---------------------—+ +---------------------—+ | EfiDebugImageInfoTable | | UpdateStatus | +---------------------—+ +---------------------—+ | UpdateStatus | | TableSize | +---------------------—+ +---------------------—+ | TableSize | | EfiDebugImageInfoTable | +---------------------—+ +---------------------—+

2) X64 and IPF: Old: New: +---------------------—+ +---------------------—+ | EfiDebugImageInfoTable | | UpdateStatus | | | +---------------------—+ | | | TableSize | +---------------------—+ +---------------------—+ | UpdateStatus | | EfiDebugImageInfoTable | +---------------------—+ | | | TableSize | | | +---------------------—+ +---------------------—+

Parameters
DebugImageInfoTableHeaderPoint to the EFI_DEBUG_IMAGE_INFO_TABLE_HEADER structure.

Definition at line 959 of file EdbSymbol.c.

◆ EdbGetLineNumberAndOffsetFromThisLine()

UINTN EdbGetLineNumberAndOffsetFromThisLine ( IN VOID *  Line,
OUT UINTN Offset 
)

Get line number and offset from this line in code file.

Parameters
Line- Line buffer in code file
Offset- Offset to functin entry
Returns
Line number

Definition at line 1782 of file EdbSymbol.c.

◆ EdbGetLineNumberFromCode()

UINTN EdbGetLineNumberFromCode ( IN EFI_DEBUGGER_SYMBOL_ENTRY Entry,
IN UINTN  FuncOffset,
IN EDB_EBC_LINE_SEARCH_TYPE  SearchType 
)

Get line number from this code file.

Parameters
Entry- Symbol entry
FuncOffset- Offset to functin entry
SearchType- Search type for the code
Returns
Line number

Definition at line 1877 of file EdbSymbol.c.

◆ EdbGetSourceStrFromCode()

VOID * EdbGetSourceStrFromCode ( IN EFI_DEBUGGER_SYMBOL_ENTRY Entry,
IN UINTN  FuncOffset,
IN VOID **  FuncEnd 
)

Get source string from this code file.

Parameters
Entry- Symbol entry
FuncOffset- Offset to functin entry
FuncEnd- Function end
Return values
Funtionstart

Definition at line 2055 of file EdbSymbol.c.

◆ EdbGetSourceStrFromCodeByLine()

VOID * EdbGetSourceStrFromCodeByLine ( IN EFI_DEBUGGER_SYMBOL_ENTRY Entry,
IN UINTN  LineNumber,
IN VOID **  FuncEnd 
)

Get the source string from this code file by line.

Parameters
Entry- Symbol entry
LineNumber- line number
FuncEnd- Function end
Returns
Funtion start

Definition at line 1988 of file EdbSymbol.c.

◆ EdbLoadCodBySymbol()

CHAR8 * EdbLoadCodBySymbol ( IN CHAR8 *  Name,
IN VOID *  Buffer,
IN UINTN  BufferSize,
OUT UINTN CodeBufferSize,
OUT UINTN FuncOffset 
)

Load code by symbol.

Parameters
Name- Symbol file name
Buffer- Symbol file buffer
BufferSize- Symbol file buffer size
CodeBufferSize- Code buffer size
FuncOffset- Code funcion offset
Returns
CodeBuffer

Definition at line 1348 of file EdbSymbol.c.

◆ EdbLoadCodBySymbolByIec()

CHAR8 * EdbLoadCodBySymbolByIec ( IN CHAR8 *  Name,
IN VOID *  Buffer,
IN UINTN  BufferSize,
OUT UINTN CodeBufferSize,
OUT UINTN FuncOffset 
)

The following code depends on the COD file generated by IEC compiler. Load code by symbol by Iec.

Parameters
Name- Symbol file name
Buffer- Symbol file buffer
BufferSize- Symbol file buffer size
CodeBufferSize- Code buffer size
FuncOffset- Code funcion offset
Returns
CodeBuffer

Definition at line 1198 of file EdbSymbol.c.

◆ EdbLoadCode()

EFI_STATUS EdbLoadCode ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  MapFileName,
IN CHAR16 *  FileName,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Load code.

Parameters
DebuggerPrivate- EBC Debugger private data structure
MapFileName- Symbol file name
FileName- Code file name
BufferSize- Code file buffer size
Buffer- Code file buffer
Return values
EFI_SUCCESS- Code loaded successfully

Definition at line 1438 of file EdbSymbol.c.

◆ EdbLoadSymbol()

EFI_STATUS EdbLoadSymbol ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  FileName,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Load symbol file by name.

Parameters
DebuggerPrivate- EBC Debugger private data structure
FileName- Symbol file name
BufferSize- Symbol file buffer size
Buffer- Symbol file buffer
Return values
EFI_SUCCESS- load symbol successfully

Definition at line 693 of file EdbSymbol.c.

◆ EdbLoadSymbolEntry()

EFI_STATUS EdbLoadSymbolEntry ( IN EFI_DEBUGGER_SYMBOL_OBJECT Object,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Load symbol entry.

Parameters
Object- Symbol file object
BufferSize- Symbol file buffer size
Buffer- Symbol file buffer
Return values
EFI_SUCCESS- add symbol entry successfully

Definition at line 407 of file EdbSymbol.c.

◆ EdbLoadSymbolEntryByIec()

EFI_STATUS EdbLoadSymbolEntryByIec ( IN EFI_DEBUGGER_SYMBOL_OBJECT Object,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

The following code depends on the MAP file generated by IEC compiler (actually Microsoft linker).

Sample as follows: EbcTest.map

EbcTest

Timestamp is 45b02718 (Fri Jan 19 10:04:08 2007)

Preferred load address is 10000000

Start Length Name Class 0001:00000000 00000370H .text CODE 0002:00000000 00000030H _VARBSS_INIT CODE 0003:00000000 00000004H .CRT$TSA DATA 0003:00000004 00000004H .CRT$TSC DATA 0003:00000008 00000004H .CRT$X DATA 0003:0000000c 00000008H .CRT$XCU DATA 0003:00000014 00000004H .CRT$Z DATA 0003:00000020 0000001cH .rdata DATA 0003:0000003c 00000000H .edata DATA 0003:0000003c 00000056H .rdata$debug DATA 0004:00000000 00000070H .data DATA 0004:00000070 00000020H .bss DATA

Address Publics by Value Rva+Base Lib:Object

0000:00000000 ___safe_se_handler_table 00000000 <absolute> 0000:00000000 ___safe_se_handler_count 00000000 <absolute> 0001:00000042 TestSubRoutine 10000442 f EbcTest.obj 0001:0000011a EfiMain 1000051a f EbcTest.obj 0001:00000200 TestSubRoutineSub 10000600 f EbcTestSub.obj 0001:00000220 EfiStart 10000620 f EbcLib:EbcLib.obj 0002:00000000 varbss_init_C:\efi_src\TIANO\Edk\Sample\Universal\Ebc\Dxe\EbcTest\EbcTest$c45b02717 10000800 f EbcTest.obj 0002:00000020 varbss_init_C:\efi_src\TIANO\Edk\Sample\Universal\Ebc\Dxe\EbcTest\EbcTestSub$c45af77f3 10000820 f EbcTestSub.obj 0003:00000000 CrtThunkBegin 10000a00 EbcLib:EbcLib.obj 0003:00000004 CrtThunkEnd 10000a04 EbcLib:EbcLib.obj 0003:00000008 CrtBegin 10000a08 EbcLib:EbcLib.obj 0003:00000014 CrtEnd 10000a14 EbcLib:EbcLib.obj 0004:00000070 TestStr 10000c70 EbcTest.obj 0004:00000078 TestVariable1 10000c78 EbcTest.obj 0004:00000080 TestSubVariableSub 10000c80 EbcTestSub.obj

entry point at 0001:00000220

Static symbols

0001:00000000 TestSubRoutine2 10000400 f EbcTest.obj

Load symbol entry by Iec.

Parameters
Object- Symbol file object
BufferSize- Symbol file buffer size
Buffer- Symbol file buffer
Return values
EFI_SUCCESS- add symbol entry successfully

Definition at line 165 of file EdbSymbol.c.

◆ EdbLoadSymbolSingleEntry()

EFI_STATUS EdbLoadSymbolSingleEntry ( IN EFI_DEBUGGER_SYMBOL_OBJECT Object,
IN CHAR8 *  Name,
IN CHAR8 *  ObjName,
IN UINTN  Address,
IN EFI_DEBUGGER_SYMBOL_TYPE  Type 
)

Load single symbol entry.

Parameters
Object- Symbol file object
Name- Symbol name
ObjName- Object name
Address- Symbol address
Type- Symbol type
Return values
EFI_SUCCESS- add single symbol entry successfully

Definition at line 25 of file EdbSymbol.c.

◆ EdbPatchSymbolRVA()

EFI_STATUS EdbPatchSymbolRVA ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  FileName,
IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE  SearchType 
)

Patch symbol RVA.

Parameters
DebuggerPrivate- EBC Debugger private data structure
FileName- Symbol file name
SearchType- Search type for Object
Return values
EFI_SUCCESS- Patch symbol RVA successfully
EFI_NOT_FOUND- Symbol RVA base not found

Definition at line 997 of file EdbSymbol.c.

◆ EdbPrintSource()

UINTN EdbPrintSource ( IN UINTN  Address,
IN BOOLEAN  IsPrint 
)

Print source.

Parameters
Address- Instruction address
IsPrint- Whether need to print
Return values
1- find the source
0- not find the source

Definition at line 2086 of file EdbSymbol.c.

◆ EdbUnloadCode()

EFI_STATUS EdbUnloadCode ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  MapFileName,
IN CHAR16 *  FileName,
OUT VOID **  Buffer 
)

Unload code.

Parameters
DebuggerPrivate- EBC Debugger private data structure
MapFileName- Symbol file name
FileName- Code file name
Buffer- Code file buffer
Return values
EFI_SUCCESS- Code unloaded successfully

Definition at line 1554 of file EdbSymbol.c.

◆ EdbUnloadSymbol()

EFI_STATUS EdbUnloadSymbol ( IN EFI_DEBUGGER_PRIVATE_DATA DebuggerPrivate,
IN CHAR16 *  FileName 
)

Unload symbol file by name.

Parameters
DebuggerPrivate- EBC Debugger private data structure
FileName- Symbol file name
Return values
EFI_SUCCESS- unload symbol successfully

Definition at line 614 of file EdbSymbol.c.

◆ FindSymbolStr()

CHAR8 * FindSymbolStr ( IN UINTN  Address)

Find the symbol string according to address.

Parameters
Address- Symbol address
Returns
Symbol string

Definition at line 1733 of file EdbSymbol.c.

◆ GetMapfileAndSymbol()

VOID GetMapfileAndSymbol ( IN CHAR16 *  Symbol,
OUT CHAR16 **  MapfileName,
OUT CHAR16 **  SymbolName 
)

Get Mapfile and SymbolName from one symbol format: [MapFileName:]SymbolName.

Parameters
Symbol- whole Symbol name
MapfileName- the mapfile name in the symbol
SymbolName- the symbol name in the symbol

Definition at line 2183 of file EdbSymbol.c.

◆ GetPdbPath()

CHAR8 * GetPdbPath ( VOID *  ImageBase)

Located PDB path name in PE image.

Parameters
ImageBase- base of PE to search
Returns
Pointer into image at offset of PDB file name if PDB file name is found, Otherwise a pointer to an empty string.

Definition at line 773 of file EdbSymbol.c.

◆ MatchObjAndCod()

BOOLEAN MatchObjAndCod ( IN CHAR8 *  ObjFileName,
IN CHAR16 *  CodFileName 
)

Check whether OBJ file and COD file have same name.

Parameters
ObjFileName- OBJ file name
CodFileName- COD file name
Return values
TRUE- OBJ and COD file name match
FALSE- OBJ and COD file name not match

Definition at line 1125 of file EdbSymbol.c.

◆ MatchPdbAndMap()

BOOLEAN MatchPdbAndMap ( IN CHAR8 *  PdbFileName,
IN CHAR16 *  MapFileName 
)

Check whether PDB file and MAP file have same name.

Parameters
PdbFileName- PDB file name
MapFileName- MAP file name
Return values
TRUE- PDB and MAP file name match
FALSE- PDB and MAP file name not match

Definition at line 875 of file EdbSymbol.c.

◆ Symboltoi()

EFI_STATUS Symboltoi ( IN CHAR16 *  Symbol,
OUT UINTN Address 
)

Convert a symbol to an address.

Parameters
Symbol- Symbol name
Address- Symbol address
Return values
EFI_SUCCESS- symbol found and address returned.
EFI_NOT_FOUND- symbol not found
EFI_NO_MAPPING- duplicated symbol not found

Definition at line 2222 of file EdbSymbol.c.

Variable Documentation

◆ mDebugImageInfoTableHeader

EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugImageInfoTableHeader

Definition at line 928 of file EdbSymbol.c.