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
#
# Start the program running
#
run
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
#
run
end

View File

@ -59,6 +59,26 @@ IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL;
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:
@ -96,15 +116,38 @@ main (
CHAR16 *FirmwareVolumesStr;
UINTN *StackPointer;
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 (stderr, 0);
MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
printf ("\nEDK II UNIX Emulation Environment from edk2.sourceforge.net\n");
//
// PPIs pased into PEI_CORE
//
@ -129,23 +172,6 @@ main (
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
//
@ -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
IsPdbFile (
IN CHAR8 *PdbFileName
@ -1096,9 +1094,9 @@ DlLoadImage (
);
Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
if (Handle) {
if (Handle != NULL) {
Entry = dlsym (Handle, "_ModuleEntryPoint");
AddHandle (ImageContext, Handle);
} else {
printf("%s\n", dlerror());
}
@ -1127,18 +1125,6 @@ GdbScriptAddImage (
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);
@ -1159,13 +1145,6 @@ GdbScriptAddImage (
} else {
ASSERT (FALSE);
}
AddHandle (ImageContext, ImageContext->PdbPointer);
if (InterruptsWereEnabled) {
SecEnableInterrupt ();
}
}
}
@ -1195,7 +1174,6 @@ GdbScriptRemoveImage (
)
{
FILE *GdbTempFile;
BOOLEAN InterruptsWereEnabled;
//
// Need to skip .PDB files created from VC++
@ -1204,13 +1182,6 @@ GdbScriptRemoveImage (
return;
}
if (SecInterruptEanbled ()) {
SecDisableInterrupt ();
InterruptsWereEnabled = TRUE;
} else {
InterruptsWereEnabled = FALSE;
}
//
// Write the file we need for the gdb script
//
@ -1227,10 +1198,6 @@ GdbScriptRemoveImage (
} else {
ASSERT (FALSE);
}
if (InterruptsWereEnabled) {
SecEnableInterrupt ();
}
}
@ -1246,7 +1213,6 @@ SecPeCoffUnloadImageExtraAction (
// Check to see if the image symbols were loaded with gdb script, or dlopen
//
Handle = RemoveHandle (ImageContext);
if (Handle != NULL) {
#ifndef __APPLE__
dlclose (Handle);

View File

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

View File

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