Author: hyperion Date: Sat Mar 10 06:51:27 2007 New Revision: 26051
URL: http://svn.reactos.org/svn/reactos?rev=26051&view=rev Log: added lib/debugsup added lib/debugsup/debugsup-ntos.def added lib/debugsup/debugsup.rbuild modified lib/lib.rbuild New import-only library. Links modules that need low-level debugging functions (DbgBreakPoint, DbgBreakPointWithStatus, DbgPrint, DbgPrompt, DbgPrintEx, RtlAssert, RtlUnwind) to the correct low-level library (ntdll for user mode and ntoskrnl for kernel mode). This ensures debugging macros will always work, everywhere, and it doesn't force all modules with debugging information to link to ntdll/ntoskrnl. TODO: link RtlUnwind to kernel32 for Win32 modules
modified tools/rbuild/backend/mingw/modulehandler.cpp modified tools/rbuild/backend/mingw/modulehandler.h Add debugsup_ntdll/debugsup_ntoskrnl as an implicit library for all executable modules (minus the kernel)
Added: trunk/reactos/lib/debugsup/ trunk/reactos/lib/debugsup/debugsup-ntos.def trunk/reactos/lib/debugsup/debugsup.rbuild Modified: trunk/reactos/lib/lib.rbuild trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
Added: trunk/reactos/lib/debugsup/debugsup-ntos.def URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/debugsup/debugsup-ntos.... ============================================================================== --- trunk/reactos/lib/debugsup/debugsup-ntos.def (added) +++ trunk/reactos/lib/debugsup/debugsup-ntos.def Sat Mar 10 06:51:27 2007 @@ -1,0 +1,10 @@ +EXPORTS +DbgBreakPoint@0 +DbgBreakPointWithStatus@4 +DbgPrint +DbgPrompt@12 +DbgPrintEx +RtlAssert@16 +RtlUnwind@16 + +;EOF
Added: trunk/reactos/lib/debugsup/debugsup.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/debugsup/debugsup.rbuil... ============================================================================== --- trunk/reactos/lib/debugsup/debugsup.rbuild (added) +++ trunk/reactos/lib/debugsup/debugsup.rbuild Sat Mar 10 06:51:27 2007 @@ -1,0 +1,8 @@ +<group> +<module name="debugsup_ntoskrnl" type="staticlibrary"> + <importlibrary definition="debugsup-ntos.def" dllname="ntoskrnl.exe" /> +</module> +<module name="debugsup_ntdll" type="staticlibrary"> + <importlibrary definition="debugsup-ntos.def" dllname="ntdll.dll" /> +</module> +</group>
Modified: trunk/reactos/lib/lib.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/lib.rbuild?rev=26051&am... ============================================================================== --- trunk/reactos/lib/lib.rbuild (original) +++ trunk/reactos/lib/lib.rbuild Sat Mar 10 06:51:27 2007 @@ -64,5 +64,8 @@ <directory name="wdmguid"> <xi:include href="wdmguid/wdmguid.rbuild" /> </directory> +<directory name="debugsup"> + <xi:include href="debugsup/debugsup.rbuild" /> +</directory> </group>
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Sat Mar 10 06:51:27 2007 @@ -418,7 +418,7 @@
if ( iend == 0 ) return; - + for ( size_t i = 0; i < iend; i++ ) { const Dependency& dependency = *module.dependencies[i]; @@ -506,7 +506,7 @@ } else newExtension = ".o"; - + if ( module.type == BootSector ) directoryTree = backend->outputDirectory; else @@ -547,7 +547,7 @@ { if ( module.type == Alias ) return; - + fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() ); @@ -604,7 +604,7 @@ const vector<CompilationUnit*>& compilationUnits = module.non_if_data.compilationUnits; if ( compilationUnits.size () == 0 ) return ""; - + string objectFilenames ( "" ); for ( size_t i = 0; i < compilationUnits.size (); i++ ) { @@ -636,7 +636,7 @@ return parameters; }
-string +string MingwModuleHandler::GenerateGccDefineParameters () const { string parameters = GenerateGccDefineParametersFromVector ( module.project.non_if_data.defines ); @@ -824,7 +824,7 @@ GenerateMacro ( assignmentOperation, windresflagsMacro, data ); - + if ( linkerFlags != NULL ) { string linkerParameters = GenerateLinkerParametersFromVector ( *linkerFlags ); @@ -874,7 +874,7 @@ "+=", rIf.data, NULL ); - fprintf ( + fprintf ( fMakefile, "endif\n\n" ); } @@ -957,7 +957,7 @@ "+=", rIf.data, NULL ); - fprintf ( + fprintf ( fMakefile, "endif\n\n" ); } @@ -997,7 +997,7 @@ dependencies += " " + extraDependencies; if ( module.pch && use_pch ) dependencies += " " + GetPrecompiledHeaderFilename (); - + /* WIDL generated headers may be used */ vector<string> rpcDependencies; GetRpcHeaderDependencies ( rpcDependencies ); @@ -1172,7 +1172,7 @@ return PassThruCacheDirectory ( basename + "_s.h", backend->intermediateDirectory ); } - + void MingwModuleHandler::GenerateWidlCommandsServer ( const CompilationUnit& compilationUnit, @@ -1397,7 +1397,7 @@ GetBasename ( module.GetPath () ) + ".map", backend->outputDirectory ); CLEAN_FILE ( mapFilename ); - + fprintf ( fMakefile, "\t$(ECHO_OBJDUMP)\n" ); fprintf ( fMakefile, @@ -1438,14 +1438,14 @@ GetBasename ( filename ) + ".nostrip" + GetExtension ( filename ), backend->outputDirectory ); CLEAN_FILE ( nostripFilename ); - + fprintf ( fMakefile, "\t$(ECHO_CP)\n" ); fprintf ( fMakefile, "\t${cp} %s %s 1>$(NUL)\n", outputFilename.c_str (), nostripFilename.c_str () ); - + fprintf ( fMakefile, "endif\n" ); } @@ -1562,14 +1562,14 @@ { string temp_exp = ros_temp + module.name + ".temp.exp"; CLEAN_FILE ( temp_exp ); - + fprintf ( fMakefile, "\t${dlltool} --dllname %s --def %s --output-exp %s %s\n", targetName.c_str (), definitionFilename.c_str (), temp_exp.c_str (), killAt.c_str () ); - + fprintf ( fMakefile, "\t%s %s %s %s -o %s %s %s %s\n", linker.c_str (), @@ -1580,7 +1580,7 @@ objectsMacro.c_str (), libsMacro.c_str (), GetLinkerMacro ().c_str () ); - + fprintf ( fMakefile, "\t$(Q)$(PEFIXUP_TARGET) %s -exports %s\n", target.c_str (), @@ -1601,7 +1601,7 @@ objectsMacro.c_str (), libsMacro.c_str (), GetLinkerMacro ().c_str () ); - + #if 0 // causes crashes sometimes fprintf ( fMakefile, "\t${objcopy} -R .edata %s\n", @@ -1639,7 +1639,7 @@ const string& widlflagsMacro ) { size_t i; - + const vector<CompilationUnit*>& compilationUnits = data.compilationUnits; for ( i = 0; i < compilationUnits.size (); i++ ) { @@ -1728,7 +1728,7 @@ const string& objs_macro ) const { string archiveFilename ( GetModuleArchiveFilename () ); - + fprintf ( fMakefile, "%s: %s | %s\n", archiveFilename.c_str (), @@ -1908,7 +1908,7 @@ // Always force disabling of sibling calls optimisation for GCC // (TODO: Move to version-specific once this bug is fixed in GCC) globalCflags += " -fno-optimize-sibling-calls"; - + fprintf ( fMakefile, "%s += $(PROJECT_CFLAGS) %s\n", @@ -2047,7 +2047,7 @@ { if ( module.invocations.size () == 0 ) return; - + size_t iend = module.invocations.size (); for ( size_t i = 0; i < iend; i++ ) { @@ -2122,7 +2122,7 @@ GetModuleDependencies ( dependencies );
GetInvocationDependencies ( module, dependencies ); - + if ( dependencies.size() ) { fprintf ( fMakefile, @@ -2179,7 +2179,7 @@ string library_target ( GetImportLibraryFilename ( module, &clean_files ) ); string defFilename = GetDefinitionFilename (); - + string_list deps; GetDefinitionDependencies ( deps );
@@ -2256,6 +2256,33 @@ } }
+enum DebugSupportType +{ + DebugKernelMode, + DebugUserMode +}; + +static void +MingwAddDebugSupportLibraries ( Module& module, DebugSupportType type ) +{ + Library* pLibrary; + + switch(type) + { + case DebugKernelMode: + pLibrary = new Library ( module, "debugsup_ntoskrnl" ); + break; + + case DebugUserMode: + pLibrary = new Library ( module, "debugsup_ntdll" ); + break; + + default: + assert(0); + } + + module.non_if_data.libraries.push_back(pLibrary); +}
MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module& module_ ) : MingwModuleHandler ( module_ ) @@ -2283,7 +2310,7 @@ linker = "${host_gpp}"; else linker = "${host_gcc}"; - + fprintf ( fMakefile, "%s: %s %s | %s\n", targetMacro.c_str (), objectsMacro.c_str (), @@ -2396,6 +2423,12 @@ }
void +MingwKernelModeDLLModuleHandler::AddImplicitLibraries ( Module& module ) +{ + MingwAddDebugSupportLibraries ( module, DebugKernelMode ); +} + +void MingwKernelModeDLLModuleHandler::Process () { GenerateKernelModeDLLModuleTarget (); @@ -2443,6 +2476,12 @@ }
void +MingwKernelModeDriverModuleHandler::AddImplicitLibraries ( Module& module ) +{ + MingwAddDebugSupportLibraries ( module, DebugKernelMode ); +} + +void MingwKernelModeDriverModuleHandler::Process () { GenerateKernelModeDriverModuleTarget (); @@ -2491,6 +2530,12 @@ }
void +MingwNativeDLLModuleHandler::AddImplicitLibraries ( Module& module ) +{ + MingwAddDebugSupportLibraries ( module, DebugUserMode ); +} + +void MingwNativeDLLModuleHandler::Process () { GenerateNativeDLLModuleTarget (); @@ -2504,7 +2549,7 @@ string objectsMacro = GetObjectsMacro ( module ); string linkDepsMacro = GetLinkingDependenciesMacro (); string libsMacro = GetLibsMacro (); - + GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 ) @@ -2538,6 +2583,12 @@ }
void +MingwNativeCUIModuleHandler::AddImplicitLibraries ( Module& module ) +{ + MingwAddDebugSupportLibraries ( module, DebugUserMode ); +} + +void MingwNativeCUIModuleHandler::Process () { GenerateNativeCUIModuleTarget (); @@ -2551,7 +2602,7 @@ string objectsMacro = GetObjectsMacro ( module ); string linkDepsMacro = GetLinkingDependenciesMacro (); string libsMacro = GetLibsMacro (); - + GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 ) @@ -2618,6 +2669,7 @@ MingwWin32DLLModuleHandler::AddImplicitLibraries ( Module& module ) { MingwAddImplicitLibraries ( module ); + MingwAddDebugSupportLibraries ( module, DebugUserMode ); }
void @@ -2677,6 +2729,7 @@ MingwWin32CUIModuleHandler::AddImplicitLibraries ( Module& module ) { MingwAddImplicitLibraries ( module ); + MingwAddDebugSupportLibraries ( module, DebugUserMode ); }
void @@ -2736,6 +2789,7 @@ MingwWin32GUIModuleHandler::AddImplicitLibraries ( Module& module ) { MingwAddImplicitLibraries ( module ); + MingwAddDebugSupportLibraries ( module, DebugUserMode ); }
void @@ -2901,7 +2955,7 @@ linkDepsMacro.c_str (), payload->name.c_str (), GetDirectory(GetTargetFilename(module,NULL)).c_str () ); - + fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" );
fprintf ( fMakefile, "\t$(BOOTPROG_PREPARE) $(OUTPUT)$(SEP)%s %s\n",
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h (original) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h Sat Mar 10 06:51:27 2007 @@ -104,7 +104,7 @@ string_list* pclean_files ) const;
std::string GetObjectFilenames (); - + std::string GetPreconditionDependenciesName () const; std::string GetCFlagsMacro () const; static std::string GetObjectsMacro ( const Module& ); @@ -280,6 +280,7 @@ virtual void Process (); std::string TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; } std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } + void AddImplicitLibraries ( Module& module ); private: void GenerateKernelModeDLLModuleTarget (); }; @@ -293,6 +294,7 @@ virtual void Process (); std::string TypeSpecificCFlags() { return "-D__NTDRIVER__ -D_SEH_NO_NATIVE_NLG"; } std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } + void AddImplicitLibraries ( Module& module ); private: void GenerateKernelModeDriverModuleTarget (); }; @@ -306,6 +308,7 @@ virtual void Process (); std::string TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; } std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } + void AddImplicitLibraries ( Module& module ); private: void GenerateNativeDLLModuleTarget (); }; @@ -319,6 +322,7 @@ virtual void Process (); std::string TypeSpecificCFlags() { return "-D__NTAPP__ -D_SEH_NO_NATIVE_NLG"; } std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } + void AddImplicitLibraries ( Module& module ); private: void GenerateNativeCUIModuleTarget (); };