diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-06-27 19:56:15 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-06-27 19:56:15 +0000 |
commit | f70c2a12344fca6c73821cb3a7feacf0b92009f9 (patch) | |
tree | 7876cd8ce2016cd93f94f70fe0c0b8964f2f9c6b /InOsEmuPkg/Unix/Sec | |
parent | 8bd282bee9909a0ac414f11c9274c473dbb9a538 (diff) | |
download | edk2-f70c2a12344fca6c73821cb3a7feacf0b92009f9.zip edk2-f70c2a12344fca6c73821cb3a7feacf0b92009f9.tar.gz edk2-f70c2a12344fca6c73821cb3a7feacf0b92009f9.tar.bz2 |
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
Diffstat (limited to 'InOsEmuPkg/Unix/Sec')
-rw-r--r-- | InOsEmuPkg/Unix/Sec/SecMain.c | 128 |
1 files changed, 47 insertions, 81 deletions
diff --git a/InOsEmuPkg/Unix/Sec/SecMain.c b/InOsEmuPkg/Unix/Sec/SecMain.c index 4b59101..2806347 100644 --- a/InOsEmuPkg/Unix/Sec/SecMain.c +++ b/InOsEmuPkg/Unix/Sec/SecMain.c @@ -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 // @@ -130,23 +173,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 // gSystemMemoryCount = CountSeperatorsInString (MemorySizeStr, '!') + 1; @@ -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); |