InOsEmuPkg: Fix Xcode symbol loading with new scheme. Fix bug in dlcose. Move some of the gdb infrastrucuture to the start of main().

signed-off-by: andrewfish



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11895 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2011-06-27 19:56:15 +00:00
parent 8bd282bee9
commit f70c2a1234
4 changed files with 65 additions and 94 deletions

View File

@ -67,8 +67,13 @@ define RemoveFirmwareSymbolFile
end end
end end
if gInXcode == 1
# in Xcode the program is already runing. Issuing a run command
# will cause a fatal debugger error. The break point sciprt that
# is used to source this script sets gInCode to 1.
else
# #
# Start the program running # Start the program running
# #
run run
end

View File

@ -59,6 +59,26 @@ IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL;
EFI_PEI_PPI_DESCRIPTOR *gPpiList; EFI_PEI_PPI_DESCRIPTOR *gPpiList;
int gInXcode = 0;
/*++
Breakpoint target for Xcode project. Set in the Xcode XML
Xcode breakpoint will 'source SecMain.gdb'
gGdbWorkingFileName is set to SecMain.gdb
**/
VOID
SecGdbConfigBreak (
VOID
)
{
}
/*++ /*++
Routine Description: Routine Description:
@ -97,14 +117,37 @@ main (
UINTN *StackPointer; UINTN *StackPointer;
FILE *GdbTempFile; FILE *GdbTempFile;
//
// Xcode does not support sourcing gdb scripts directly, so the Xcode XML
// has a break point script to source the GdbRun script.
//
SecGdbConfigBreak ();
//
// If dlopen doesn't work, then we build a gdb script to allow the
// symbols to be loaded.
//
Index = strlen (*Argv);
gGdbWorkingFileName = AllocatePool (Index + strlen(".gdb") + 1);
strcpy (gGdbWorkingFileName, *Argv);
strcat (gGdbWorkingFileName, ".gdb");
//
// Empty out the gdb symbols script file.
//
GdbTempFile = fopen (gGdbWorkingFileName, "w");
if (GdbTempFile != NULL) {
fclose (GdbTempFile);
}
printf ("\nEDK II UNIX Host Emulation Environment from edk2.sourceforge.net\n");
setbuf (stdout, 0); setbuf (stdout, 0);
setbuf (stderr, 0); setbuf (stderr, 0);
MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize); MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume); FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
printf ("\nEDK II UNIX Emulation Environment from edk2.sourceforge.net\n");
// //
// PPIs pased into PEI_CORE // PPIs pased into PEI_CORE
// //
@ -129,23 +172,6 @@ main (
gPpiList = GetThunkPpiList (); gPpiList = GetThunkPpiList ();
//
// If dlopen doesn't work, then we build a gdb script to allow the
// symbols to be loaded.
//
Index = strlen (*Argv);
gGdbWorkingFileName = AllocatePool (Index + strlen(".gdb") + 1);
strcpy (gGdbWorkingFileName, *Argv);
strcat (gGdbWorkingFileName, ".gdb");
//
// Empty out the gdb symbols script file.
//
GdbTempFile = fopen (gGdbWorkingFileName, "w");
if (GdbTempFile != NULL) {
fclose (GdbTempFile);
}
// //
// Allocate space for gSystemMemory Array // Allocate space for gSystemMemory Array
// //
@ -974,34 +1000,6 @@ RemoveHandle (
//
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to source a
// add-symbol-file command. Hey what can you say scripting in gdb is not that great....
//
// Put .gdbinit in the CWD where you do gdb SecMain.dll for source level debug
//
// cat .gdbinit
// b SecGdbScriptBreak
// command
// silent
// source SecMain.gdb
// c
// end
//
VOID
SecGdbScriptBreak (
VOID
)
{
}
VOID
SecUnixLoaderBreak (
VOID
)
{
}
BOOLEAN BOOLEAN
IsPdbFile ( IsPdbFile (
IN CHAR8 *PdbFileName IN CHAR8 *PdbFileName
@ -1096,9 +1094,9 @@ DlLoadImage (
); );
Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW); Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
if (Handle != NULL) {
if (Handle) {
Entry = dlsym (Handle, "_ModuleEntryPoint"); Entry = dlsym (Handle, "_ModuleEntryPoint");
AddHandle (ImageContext, Handle);
} else { } else {
printf("%s\n", dlerror()); printf("%s\n", dlerror());
} }
@ -1127,18 +1125,6 @@ GdbScriptAddImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
BOOLEAN InterruptsWereEnabled;
//
// Disable interrupts to make sure writing of the .gdb file
// is an atomic operation.
//
if (SecInterruptEanbled ()) {
SecDisableInterrupt ();
InterruptsWereEnabled = TRUE;
} else {
InterruptsWereEnabled = FALSE;
}
PrintLoadAddress (ImageContext); PrintLoadAddress (ImageContext);
@ -1159,13 +1145,6 @@ GdbScriptAddImage (
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
} }
AddHandle (ImageContext, ImageContext->PdbPointer);
if (InterruptsWereEnabled) {
SecEnableInterrupt ();
}
} }
} }
@ -1195,7 +1174,6 @@ GdbScriptRemoveImage (
) )
{ {
FILE *GdbTempFile; FILE *GdbTempFile;
BOOLEAN InterruptsWereEnabled;
// //
// Need to skip .PDB files created from VC++ // Need to skip .PDB files created from VC++
@ -1204,13 +1182,6 @@ GdbScriptRemoveImage (
return; return;
} }
if (SecInterruptEanbled ()) {
SecDisableInterrupt ();
InterruptsWereEnabled = TRUE;
} else {
InterruptsWereEnabled = FALSE;
}
// //
// Write the file we need for the gdb script // Write the file we need for the gdb script
// //
@ -1227,10 +1198,6 @@ GdbScriptRemoveImage (
} else { } else {
ASSERT (FALSE); ASSERT (FALSE);
} }
if (InterruptsWereEnabled) {
SecEnableInterrupt ();
}
} }
@ -1246,7 +1213,6 @@ SecPeCoffUnloadImageExtraAction (
// Check to see if the image symbols were loaded with gdb script, or dlopen // Check to see if the image symbols were loaded with gdb script, or dlopen
// //
Handle = RemoveHandle (ImageContext); Handle = RemoveHandle (ImageContext);
if (Handle != NULL) { if (Handle != NULL) {
#ifndef __APPLE__ #ifndef __APPLE__
dlclose (Handle); dlclose (Handle);

View File

@ -5,7 +5,7 @@
activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */; activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */;
activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */; activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */;
breakpoints = ( breakpoints = (
BA11A11A0FB10E0700D06FEC /* SecGdbScriptBreak */, BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */,
); );
codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */; codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */;
executables = ( executables = (
@ -161,7 +161,7 @@
path = ../../../../Build/EmuUnixIa32/DEBUG_XCLANG/IA32/SecMain; path = ../../../../Build/EmuUnixIa32/DEBUG_XCLANG/IA32/SecMain;
sourceTree = SOURCE_ROOT; sourceTree = SOURCE_ROOT;
}; };
BA11A11A0FB10E0700D06FEC /* SecGdbScriptBreak */ = { BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */ = {
isa = PBXSymbolicBreakpoint; isa = PBXSymbolicBreakpoint;
actions = ( actions = (
BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */, BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */,
@ -176,11 +176,11 @@
modificationTime = 263261853.260195; modificationTime = 263261853.260195;
originalNumberOfMultipleMatches = 1; originalNumberOfMultipleMatches = 1;
state = 1; state = 1;
symbolName = SecGdbScriptBreak; symbolName = SecGdbConfigBreak;
}; };
BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = { BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = {
isa = XCBreakpointCommandAction; isa = XCBreakpointCommandAction;
command = "source SecMain.gdb"; command = "set gInXcode=1\nsource ../../../../InOsEmuPkg/Unix/GdbRun";
fallbackIsa = XCBreakpointAction; fallbackIsa = XCBreakpointAction;
logCommand = 0; logCommand = 0;
useDebuggerSideImplementation = 1; useDebuggerSideImplementation = 1;

View File

@ -5,7 +5,7 @@
activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */; activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */;
activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */; activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */;
breakpoints = ( breakpoints = (
BA11A11A0FB10E0700D06FEC /* SecGdbScriptBreak */, BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */,
); );
codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */; codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */;
executables = ( executables = (
@ -161,7 +161,7 @@
path = ../../../../Build/EmuUnixX64/DEBUG_XCLANG/X64/SecMain; path = ../../../../Build/EmuUnixX64/DEBUG_XCLANG/X64/SecMain;
sourceTree = SOURCE_ROOT; sourceTree = SOURCE_ROOT;
}; };
BA11A11A0FB10E0700D06FEC /* SecGdbScriptBreak */ = { BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */ = {
isa = PBXSymbolicBreakpoint; isa = PBXSymbolicBreakpoint;
actions = ( actions = (
BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */, BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */,
@ -176,11 +176,11 @@
modificationTime = 263261853.260195; modificationTime = 263261853.260195;
originalNumberOfMultipleMatches = 1; originalNumberOfMultipleMatches = 1;
state = 1; state = 1;
symbolName = SecGdbScriptBreak; symbolName = SecGdbConfigBreak;
}; };
BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = { BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = {
isa = XCBreakpointCommandAction; isa = XCBreakpointCommandAction;
command = "source SecMain.gdb"; command = "set gInXcode=1\nsource ../../../../InOsEmuPkg/Unix/GdbRun";
fallbackIsa = XCBreakpointAction; fallbackIsa = XCBreakpointAction;
logCommand = 0; logCommand = 0;
useDebuggerSideImplementation = 1; useDebuggerSideImplementation = 1;