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 | |
parent | 8bd282bee9909a0ac414f11c9274c473dbb9a538 (diff) | |
download | edk2-platforms-f70c2a12344fca6c73821cb3a7feacf0b92009f9.tar.xz |
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
4 files changed, 65 insertions, 94 deletions
diff --git a/InOsEmuPkg/Unix/GdbRun b/InOsEmuPkg/Unix/GdbRun index c374cb8ca5..428e655631 100644 --- a/InOsEmuPkg/Unix/GdbRun +++ b/InOsEmuPkg/Unix/GdbRun @@ -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 diff --git a/InOsEmuPkg/Unix/Sec/SecMain.c b/InOsEmuPkg/Unix/Sec/SecMain.c index 4b5910187d..2806347941 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); diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser b/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser index 5c5163a09a..5a2dfe8bc6 100644 --- a/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser +++ b/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser @@ -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; diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser b/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser index 846ee23662..1fe821f8de 100644 --- a/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser +++ b/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser @@ -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; |