ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2005
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
28 participants
703 discussions
Start a n
N
ew thread
[gvg] 12904: Signal the ReactOSInitDone event like smss.exe does,
by gvg@svn.reactos.com
Signal the ReactOSInitDone event like smss.exe does, prevents bugcheck when usetup is done in less than 120 sec Modified: trunk/reactos/subsys/system/usetup/usetup.c _____ Modified: trunk/reactos/subsys/system/usetup/usetup.c --- trunk/reactos/subsys/system/usetup/usetup.c 2005-01-09 04:40:01 UTC (rev 12903) +++ trunk/reactos/subsys/system/usetup/usetup.c 2005-01-09 08:20:28 UTC (rev 12904) @@ -31,6 +31,7 @@ #include <ntos/minmax.h> #include <reactos/resource.h> +#include <rosrtl/string.h> #include "usetup.h" #include "console.h" @@ -3691,6 +3692,43 @@ } +static VOID +SignalInitEvent() +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING UnicodeString; + HANDLE ReactOSInitEvent; + + RtlRosInitUnicodeStringFromLiteral(&UnicodeString, L"\\ReactOSInitDone"); + InitializeObjectAttributes(&ObjectAttributes, + &UnicodeString, + EVENT_ALL_ACCESS, + 0, + NULL); + Status = NtOpenEvent(&ReactOSInitEvent, + EVENT_ALL_ACCESS, + &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + LARGE_INTEGER Timeout; + /* This will cause the boot screen image to go away (if displayed) */ + NtPulseEvent(ReactOSInitEvent, NULL); + + /* Wait for the display mode to be changed (if in graphics mode) */ + Timeout.QuadPart = -50000000LL; /* 5 second timeout */ + NtWaitForSingleObject(ReactOSInitEvent, FALSE, &Timeout); + + NtClose(ReactOSInitEvent); + } + else + { + /* We don't really care if this fails */ + DPRINT1("USETUP: Failed to open ReactOS init notification event\n"); + } +} + + VOID STDCALL NtProcessStartup(PPEB Peb) { @@ -3702,6 +3740,8 @@ ProcessHeap = Peb->ProcessHeap; + SignalInitEvent(); + Status = AllocConsole(); if (!NT_SUCCESS(Status)) {
19 years, 10 months
1
0
0
0
[gdalsnes] 12903: experimental/useless "pretty seh"
by gdalsnes@svn.reactos.com
experimental/useless "pretty seh" Added: trunk/reactos/include/pseh/prettybased.h Modified: trunk/reactos/include/pseh/setjmp.h Modified: trunk/reactos/lib/pseh/i386/setjmp.asm _____ Added: trunk/reactos/include/pseh/prettybased.h --- trunk/reactos/include/pseh/prettybased.h 2005-01-09 03:43:26 UTC (rev 12902) +++ trunk/reactos/include/pseh/prettybased.h 2005-01-09 04:40:01 UTC (rev 12903) @@ -0,0 +1,323 @@ +/* + Copyright (c) 2004 KJK::Hyperion + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +/* +Pretty PSEH + +Made to be macro compatible with ms seh syntax and to be pretty, having the +finally block inline etc. Being pretty is not cheap. PPSEH has more +overhead than PSEH, thou mostly during exception/unwinding. Normal execution +only add the overhead of one setjmp, and only in the try/finally case. +PPSEH is probably much less portable than PSEH also..... + +ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT !ALERT! +-must always use non-native NLG cause a special version of longjmp (which doesn't +restore esp) is needed + +-compiler must use ebp as stack frame pointer, cause the finally block rely +on this to access external variables + +-all external variables that are used in the except/finally block MUST be volatile +to prevent variables from being optimized into registers. +See:
http://alphalinux.org/archives/axp-list/1998/February1998/0330.html
+ + + +USAGE: + +__TRY{ + __LEAVE; +} +__EXCEPT(_SEH_STATIC_FILTER(EXCEPTION_EXECUTE_HANDLER)){ +} +__ENDTRY; + + +__TRY{ +} +__FINALLY{ +} +__ENDTRY; + + +_SEH_FILTER(filter){ + return EXCEPTION_EXECUTE_HANDLER; +} +__TRY2{ +} +__EXCEPT2(filter){ +} +__FINALLY2{ +} +__ENDTRY2; + + + +-Gunnar + +*/ + + +#ifndef KJK_PPSEH_FRAMEBASED_H_ +#define KJK_PPSEH_FRAMEBASED_H_ + +#include <pseh/framebased/internal.h> +#include <pseh/excpt.h> +#include <malloc.h> + +#ifndef offsetof +# include <stddef.h> +#endif + +/* +Must always use non-native NLG since we need a special version of longjmp which does +not restore esp +*/ +#include <pseh/setjmp.h> + + +typedef struct __SEHFrame +{ + _SEHPortableFrame_t SEH_Header; + _SEHJmpBuf_t SEH_JmpBuf; +/* alternative: _SEHJmpBuf_t* SEH_JmpRetPtr; */ +} +_SEHFrame_t; + +/* + Note: just define __inline to an empty symbol if your C compiler doesn't + support it +*/ +#ifdef __cplusplus +# ifndef __inline +# define __inline inline +# endif +#endif + + +/* FILTER FUNCTIONS */ +/* Declares a filter function's prototype */ +#define _SEH_FILTER(NAME_) \ + long __stdcall NAME_ \ + ( \ + struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \ + struct __SEHPortableFrame * _SEHPortableFrame \ + ) + + +/* Declares a static filter */ +#define _SEH_STATIC_FILTER(ACTION_) ((_SEHFilter_t)((ACTION_) + 2)) + + +static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler +( + _SEHPortableFrame_t * frame +) +{ + _SEHFrame_t * myframe; + myframe = (_SEHFrame_t *)(((char *)frame) - offsetof(_SEHFrame_t, SEH_Header)); + _SEHLongJmp(myframe->SEH_JmpBuf, 1); +} + + + +void __stdcall _FinallyPretty +( + struct __SEHPortableFrame * frame +) +{ + _SEHFrame_t * myframe; + _SEHJmpBuf_t jmpRetBuf; + + myframe = (_SEHFrame_t *)(((char *)frame) - offsetof(_SEHFrame_t, SEH_Header)); + + if(_SEHSetJmp(jmpRetBuf) == 0) + { + _SEHLongJmp_KeepEsp(myframe->SEH_JmpBuf, (int)&jmpRetBuf); + + /* alternative: + myframe->SEH_JmpRetPtr = &jmpRetBuf; + _SEHLongJmp_KeepEsp(myframe->SEH_JmpBuf, 2); + */ + } +} + + + +#define ___EXCEPT_DUAL(filter) \ + } while(0); \ + \ + _SEHLeave(&_SEHFrame->SEH_Header); \ + \ + if (!_SEHHandlers.SH_Finally) break; \ + _loop ++; \ + } \ + else \ + { \ + _SEHHandlers.SH_Filter = (filter); \ + _SEHHandlers.SH_Finally = _FinallyPretty; \ + \ + if(_loop == 2 || (_ret = _SEHSetJmp(_SEHFrame->SEH_JmpBuf))) \ + { \ + if (_ret == 1) \ + { \ + _SEHLeave(&_SEHFrame->SEH_Header); \ + do \ + { + + + +#define ___FINALLY_DUAL \ + } while (0); \ + } \ + \ + do \ + { + + + +#define ___END_DUAL \ + \ + } while (0); \ + \ + if (_ret > 1) \ + { \ + _SEHLongJmp(*((_SEHJmpBuf_t*)_ret), 1); \ + /* alternative: _SEHLongJmp(*_SEHFrame->SEH_JmpRetPtr, 1); */ \ + } \ + break; \ + } \ + _loop ++; \ + } \ + \ + } while (0); + + + + + +#define ___EXCEPT_SINGLE(filter) \ + } while(0); \ + \ + _SEHLeave(&_SEHFrame->SEH_Header); \ + break; \ + } \ + else \ + { \ + _SEHHandlers.SH_Filter = (filter); \ + _SEHHandlers.SH_Finally = (NULL); \ + \ + if(_SEHSetJmp(_SEHFrame->SEH_JmpBuf)) \ + { \ + _SEHLeave(&_SEHFrame->SEH_Header); \ + do \ + { + + + +#define ___TRY \ + do \ + { \ + int _loop =0; int _ret = 0; \ + static _SEHHandlers_t _SEHHandlers = \ + { \ + (NULL), \ + _SEHCompilerSpecificHandler, \ + (NULL) \ + }; \ + \ + _SEHFrame_t * _SEHFrame; \ + volatile _SEHPortableFrame_t * _SEHPortableFrame; \ + \ + _SEHFrame = _alloca(sizeof(_SEHFrame_t)); \ + _SEHFrame->SEH_Header.SPF_Handlers = &_SEHHandlers; \ + \ + _SEHPortableFrame = &_SEHFrame->SEH_Header; \ + (void)_SEHPortableFrame; \ + \ + for(;;) \ + if (_loop == 1) \ + { \ + _SEHEnter(&_SEHFrame->SEH_Header); \ + \ + do \ + { + + +#define ___FINALLY_SINGLE \ + } while(0); \ + \ + _SEHLeave(&_SEHFrame->SEH_Header); \ + _loop ++; \ + } \ + else \ + { \ + _SEHHandlers.SH_Filter = _SEH_STATIC_FILTER(_SEH_CONTINUE_SEARCH); \ + _SEHHandlers.SH_Finally = _FinallyPretty; \ + \ + if(_loop == 2 || (_ret = _SEHSetJmp(_SEHFrame->SEH_JmpBuf))) \ + { \ + do \ + { + + + +#define ___END_SINGLE \ + } while (0); \ + \ + if (_ret > 1) \ + { \ + _SEHLongJmp(*((_SEHJmpBuf_t*)_ret), 1); \ + /* alternative: _SEHLongJmp(*_SEHFrame->SEH_JmpRetPtr, 1); */ \ + } \ + break; \ + } \ + _loop ++; \ + } \ + } while (0); + + + +#ifdef _MSC_VER + #define __TRY2 __try{__try + #define __EXCEPT2 __except + #define __FINALLY2 }__finally + #define __ENDTRY2 + #define __TRY __try + #define __EXCEPT __except + #define __FINALLY __finally + #define __ENDTRY + #define _SEH_STATIC_FILTER(ACTION_) (ACTION_) + #define __LEAVE __leave +#else + #define __TRY2 ___TRY + #define __EXCEPT2 ___EXCEPT_DUAL + #define __FINALLY2 ___FINALLY_DUAL + #define __ENDTRY2 ___END_DUAL + #define __TRY ___TRY + #define __EXCEPT ___EXCEPT_SINGLE + #define __FINALLY ___FINALLY_SINGLE + #define __ENDTRY ___END_SINGLE + #define __LEAVE break +#endif + + +#endif _____ Modified: trunk/reactos/include/pseh/setjmp.h --- trunk/reactos/include/pseh/setjmp.h 2005-01-09 03:43:26 UTC (rev 12902) +++ trunk/reactos/include/pseh/setjmp.h 2005-01-09 04:40:01 UTC (rev 12903) @@ -37,6 +37,7 @@ #endif extern __declspec(noreturn) void __stdcall _SEHLongJmp(_SEHJmpBuf_t, int); +extern __declspec(noreturn) void __stdcall _SEHLongJmp_KeepEsp(_SEHJmpBuf_t, int); extern int __stdcall _SEHSetJmp(_SEHJmpBuf_t); #endif _____ Modified: trunk/reactos/lib/pseh/i386/setjmp.asm --- trunk/reactos/lib/pseh/i386/setjmp.asm 2005-01-09 03:43:26 UTC (rev 12902) +++ trunk/reactos/lib/pseh/i386/setjmp.asm 2005-01-09 04:40:01 UTC (rev 12903) @@ -65,4 +65,25 @@ mov edi, [ecx+20] jmp edx + +global SEHLongJmp_KeepEsp +global __SEHLongJmp_KeepEsp@8 +SEHLongJmp_KeepEsp: +__SEHLongJmp_KeepEsp@8: + ; return value + mov eax, [esp+8] + + ; jump buffer + mov ecx, [esp+4] + + ; restore the saved context + mov ebp, [ecx+0] +; don't restore esp +; mov esp, [ecx+4] + mov edx, [ecx+8] + mov ebx, [ecx+12] + mov esi, [ecx+16] + mov edi, [ecx+20] + jmp edx + ; EOF
19 years, 10 months
1
0
0
0
[royce] 12902: use enum instead of string in more places
by royce@svn.reactos.com
use enum instead of string in more places Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-09 03:43:26 UTC (rev 12902) @@ -92,7 +92,7 @@ { MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.node.location, - module.stype ); + module.type ); h->Process ( module ); } _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 03:43:26 UTC (rev 12902) @@ -10,18 +10,16 @@ using std::vector; using std::map; -map<string,MingwModuleHandler*>* +map<ModuleType,MingwModuleHandler*>* MingwModuleHandler::handler_map = NULL; FILE* MingwModuleHandler::fMakefile = NULL; -MingwModuleHandler::MingwModuleHandler ( const char* moduletype_ ) +MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype ) { - string moduletype ( moduletype_ ); - strlwr ( &moduletype[0] ); if ( !handler_map ) - handler_map = new map<string,MingwModuleHandler*>; + handler_map = new map<ModuleType,MingwModuleHandler*>; (*handler_map)[moduletype] = this; } @@ -33,10 +31,8 @@ /*static*/ MingwModuleHandler* MingwModuleHandler::LookupHandler ( const string& location, - const string& moduletype_ ) + ModuleType moduletype ) { - string moduletype ( moduletype_ ); - strlwr ( &moduletype[0] ); if ( !handler_map ) throw Exception ( "internal tool error: no registered module handlers" ); MingwModuleHandler* h = (*handler_map)[moduletype]; @@ -386,7 +382,7 @@ { const Invoke& invoke = *module.invocations[i]; - if ( invoke.invokeModule->etype != BuildTool ) + if ( invoke.invokeModule->type != BuildTool ) throw InvalidBuildFileException ( module.node.location, "Only modules of type buildtool can be invoked." ); @@ -446,7 +442,7 @@ static MingwBuildToolModuleHandler buildtool_handler; MingwBuildToolModuleHandler::MingwBuildToolModuleHandler() - : MingwModuleHandler ( "buildtool" ) + : MingwModuleHandler ( BuildTool ) { } @@ -477,7 +473,7 @@ static MingwKernelModuleHandler kernelmodule_handler; MingwKernelModuleHandler::MingwKernelModuleHandler () - : MingwModuleHandler ( "kernelmodedll" ) + : MingwModuleHandler ( KernelModeDLL ) { } @@ -539,7 +535,7 @@ static MingwStaticLibraryModuleHandler staticlibrary_handler; MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler () - : MingwModuleHandler ( "staticlibrary" ) + : MingwModuleHandler ( StaticLibrary ) { } _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h 2005-01-09 03:43:26 UTC (rev 12902) @@ -6,14 +6,14 @@ class MingwModuleHandler { public: - static std::map<std::string,MingwModuleHandler*>* handler_map; + static std::map<ModuleType,MingwModuleHandler*>* handler_map; - MingwModuleHandler ( const char* moduletype_ ); + MingwModuleHandler ( ModuleType moduletype ); virtual ~MingwModuleHandler() {} static void SetMakefile ( FILE* f ); static MingwModuleHandler* LookupHandler ( const std::string& location, - const std::string& moduletype_ ); + ModuleType moduletype_ ); virtual void Process ( const Module& module ) = 0; protected: _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp 2005-01-09 03:43:26 UTC (rev 12902) @@ -130,9 +130,9 @@ } UnknownModuleTypeException::UnknownModuleTypeException ( const string& location, - const string& moduletype ) + int moduletype ) : InvalidBuildFileException ( location, - "module type requested: '%s'", - moduletype.c_str() ) + "module type requested: %i", + moduletype ) { } _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h --- branches/xmlbuildsystem/reactos/tools/rbuild/exception.h 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.h 2005-01-09 03:43:26 UTC (rev 12902) @@ -98,7 +98,7 @@ { public: UnknownModuleTypeException ( const std::string& location, - const std::string& moduletype ); + int moduletype ); }; #endif /* __EXCEPTION_H */ _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-01-09 03:43:26 UTC (rev 12902) @@ -38,9 +38,7 @@ att = moduleNode.GetAttribute ( "type", true ); assert(att); - stype = att->value; - strlwr ( &stype[0] ); - etype = GetModuleType ( node.location, *att ); + type = GetModuleType ( node.location, *att ); att = moduleNode.GetAttribute ( "extension", false ); if (att != NULL) @@ -154,7 +152,7 @@ string Module::GetDefaultModuleExtension () const { - switch (etype) + switch (type) { case BuildTool: return EXEPOSTFIX; _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h --- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-01-09 03:29:46 UTC (rev 12901) +++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-01-09 03:43:26 UTC (rev 12902) @@ -71,8 +71,7 @@ std::string name; std::string extension; std::string path; - ModuleType etype; - std::string stype; + ModuleType type; std::vector<File*> files; std::vector<Library*> libraries; std::vector<Include*> includes;
19 years, 10 months
1
0
0
0
[royce] 12901: add 'location' information to a couple exceptions that should have it
by royce@svn.reactos.com
add 'location' information to a couple exceptions that should have it fixed bug I introduced in MingwBackend::ProcessModule() fixed bug in std::map usage, apparently map<const char*,...> is a bad idea let make do some work, create variables to hold include list for each module Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -422,7 +422,8 @@ } if ( required ) { - throw RequiredAttributeNotFoundException ( attribute, + throw RequiredAttributeNotFoundException ( location, + attribute, name ); } return NULL; @@ -441,7 +442,8 @@ } if ( required ) { - throw RequiredAttributeNotFoundException ( attribute, + throw RequiredAttributeNotFoundException ( location, + attribute, name ); } return NULL; _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -8,25 +8,26 @@ using std::vector; using std::map; -map<const char*,Backend::Factory*>* Backend::Factory::factories = NULL; +map<string,Backend::Factory*>* Backend::Factory::factories = NULL; Backend::Factory::Factory ( const std::string& name_ ) { string name(name_); strlwr ( &name[0] ); if ( !factories ) - factories = new map<const char*,Factory*>; - (*factories)[name.c_str()] = this; + factories = new map<string,Factory*>; + (*factories)[name] = this; } /*static*/ Backend* -Backend::Factory::Create ( const std::string& name, Project& project ) +Backend::Factory::Create ( const string& name, + Project& project ) { string sname ( name ); strlwr ( &sname[0] ); if ( !factories || !factories->size() ) throw Exception ( "internal tool error: no registered factories" ); - Backend::Factory* f = (*factories)[sname.c_str()]; + Backend::Factory* f = (*factories)[sname]; if ( !f ) { throw UnknownBackendException ( sname ); _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h 2005-01-09 03:29:46 UTC (rev 12901) @@ -12,7 +12,7 @@ public: class Factory { - static std::map<const char*,Factory*>* factories; + static std::map<std::string,Factory*>* factories; protected: @@ -22,7 +22,8 @@ virtual Backend* operator() ( Project& ) = 0; public: - static Backend* Create ( const std::string& name, Project& project ); + static Backend* Create ( const std::string& name, + Project& project ); private: }; _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -90,7 +90,9 @@ void MingwBackend::ProcessModule ( Module& module ) { - MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.name ); + MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( + module.node.location, + module.stype ); h->Process ( module ); } _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -10,7 +10,7 @@ using std::vector; using std::map; -map<const char*,MingwModuleHandler*>* +map<string,MingwModuleHandler*>* MingwModuleHandler::handler_map = NULL; FILE* @@ -21,8 +21,8 @@ string moduletype ( moduletype_ ); strlwr ( &moduletype[0] ); if ( !handler_map ) - handler_map = new map<const char*,MingwModuleHandler*>; - (*handler_map)[moduletype.c_str()] = this; + handler_map = new map<string,MingwModuleHandler*>; + (*handler_map)[moduletype] = this; } /*static*/ void @@ -32,16 +32,17 @@ } /*static*/ MingwModuleHandler* -MingwModuleHandler::LookupHandler ( const string& moduletype_ ) +MingwModuleHandler::LookupHandler ( const string& location, + const string& moduletype_ ) { string moduletype ( moduletype_ ); strlwr ( &moduletype[0] ); if ( !handler_map ) throw Exception ( "internal tool error: no registered module handlers" ); - MingwModuleHandler* h = (*handler_map)[moduletype.c_str()]; + MingwModuleHandler* h = (*handler_map)[moduletype]; if ( !h ) { - throw UnknownModuleTypeException ( moduletype ); + throw UnknownModuleTypeException ( location, moduletype ); return NULL; } return h; @@ -217,6 +218,16 @@ return parameters; } +void +MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const +{ + string name ( module.name + "_INCLUDES" ); + fprintf ( fMakefile, + "%s := %s\n", + name.c_str(), + GenerateGccIncludeParameters(module).c_str() ); +} + string MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const { @@ -234,12 +245,7 @@ MingwModuleHandler::GenerateGccParameters ( const Module& module ) const { string parameters = GenerateGccDefineParameters ( module ); - string s = GenerateGccIncludeParameters ( module ); - if ( s.length () > 0 ) - { - parameters += " "; - parameters += s; - } + parameters += ssprintf(" $(%s_INCLUDES)",module.name.c_str()); return parameters; } @@ -250,6 +256,8 @@ if ( module.files.size () == 0 ) return; + GenerateGccModuleIncludeVariable ( module ); + for ( size_t i = 0; i < module.files.size (); i++ ) { string sourceFilename = module.files[i]->name; @@ -378,7 +386,7 @@ { const Invoke& invoke = *module.invocations[i]; - if ( invoke.invokeModule->type != BuildTool ) + if ( invoke.invokeModule->etype != BuildTool ) throw InvalidBuildFileException ( module.node.location, "Only modules of type buildtool can be invoked." ); _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h 2005-01-09 03:29:46 UTC (rev 12901) @@ -6,13 +6,14 @@ class MingwModuleHandler { public: - static std::map<const char*,MingwModuleHandler*>* handler_map; + static std::map<std::string,MingwModuleHandler*>* handler_map; MingwModuleHandler ( const char* moduletype_ ); virtual ~MingwModuleHandler() {} static void SetMakefile ( FILE* f ); - static MingwModuleHandler* LookupHandler ( const std::string& moduletype_ ); + static MingwModuleHandler* LookupHandler ( const std::string& location, + const std::string& moduletype_ ); virtual void Process ( const Module& module ) = 0; protected: @@ -42,6 +43,7 @@ std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const; std::string GenerateGccDefineParameters ( const Module& module ) const; std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const; + void GenerateGccModuleIncludeVariable ( const Module& module ) const; std::string GenerateGccIncludeParameters ( const Module& module ) const; std::string GenerateGccParameters ( const Module& module ) const; void GenerateObjectFileTargets ( const Module& module, _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -93,17 +93,23 @@ } -RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName, - const string& elementName ) - : InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.", +RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( + const string& location, + const string& attributeName, + const string& elementName ) + : InvalidBuildFileException ( location, + "Required attribute '%s' not found on '%s'.", attributeName.c_str (), elementName.c_str ()) { } -InvalidAttributeValueException::InvalidAttributeValueException ( const string& name, - const string& value ) - : InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.", +InvalidAttributeValueException::InvalidAttributeValueException ( + const string& location, + const string& name, + const string& value ) + : InvalidBuildFileException ( location, + "Attribute '%s' has an invalid value '%s'.", name.c_str (), value.c_str () ) { @@ -119,12 +125,14 @@ UnknownBackendException::UnknownBackendException ( const string& name ) : Exception ( "Unknown Backend requested: '%s'", - name.c_str() ) + name.c_str() ) { } -UnknownModuleTypeException::UnknownModuleTypeException ( const string& moduletype ) - : Exception ( "module type requested: '%s'", - moduletype.c_str() ) +UnknownModuleTypeException::UnknownModuleTypeException ( const string& location, + const string& moduletype ) + : InvalidBuildFileException ( location, + "module type requested: '%s'", + moduletype.c_str() ) { } _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h --- branches/xmlbuildsystem/reactos/tools/rbuild/exception.h 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.h 2005-01-09 03:29:46 UTC (rev 12901) @@ -66,7 +66,8 @@ class RequiredAttributeNotFoundException : public InvalidBuildFileException { public: - RequiredAttributeNotFoundException ( const std::string& attributeName, + RequiredAttributeNotFoundException ( const std::string& location, + const std::string& attributeName, const std::string& elementName ); }; @@ -74,7 +75,8 @@ class InvalidAttributeValueException : public InvalidBuildFileException { public: - InvalidAttributeValueException ( const std::string& name, + InvalidAttributeValueException ( const std::string& location, + const std::string& name, const std::string& value ); }; @@ -92,10 +94,11 @@ UnknownBackendException ( const std::string& name ); }; -class UnknownModuleTypeException : public Exception +class UnknownModuleTypeException : public InvalidBuildFileException { public: - UnknownModuleTypeException ( const std::string& moduletype ); + UnknownModuleTypeException ( const std::string& location, + const std::string& moduletype ); }; #endif /* __EXCEPTION_H */ _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -38,7 +38,9 @@ att = moduleNode.GetAttribute ( "type", true ); assert(att); - type = GetModuleType ( *att ); + stype = att->value; + strlwr ( &stype[0] ); + etype = GetModuleType ( node.location, *att ); att = moduleNode.GetAttribute ( "extension", false ); if (att != NULL) @@ -136,7 +138,7 @@ } ModuleType -Module::GetModuleType ( const XMLAttribute& attribute ) +Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) { if ( attribute.value == "buildtool" ) return BuildTool; @@ -144,14 +146,15 @@ return StaticLibrary; if ( attribute.value == "kernelmodedll" ) return KernelModeDLL; - throw InvalidAttributeValueException ( attribute.name, + throw InvalidAttributeValueException ( location, + attribute.name, attribute.value ); } string Module::GetDefaultModuleExtension () const { - switch (type) + switch (etype) { case BuildTool: return EXEPOSTFIX; @@ -264,7 +267,7 @@ module.name.c_str(), att->value.c_str() ); } - + for ( size_t i = 0; i < node.subElements.size (); i++ ) ProcessXMLSubElement ( *node.subElements[i] ); } _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h --- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-01-09 03:29:46 UTC (rev 12901) @@ -39,7 +39,7 @@ std::vector<Module*> modules; std::vector<Include*> includes; std::vector<Define*> defines; - + Project (); Project ( const std::string& filename ); ~Project (); @@ -71,19 +71,21 @@ std::string name; std::string extension; std::string path; - ModuleType type; + ModuleType etype; + std::string stype; std::vector<File*> files; std::vector<Library*> libraries; std::vector<Include*> includes; std::vector<Define*> defines; std::vector<Invoke*> invocations; std::vector<Dependency*> dependencies; - + Module ( const Project& project, const XMLElement& moduleNode, const std::string& modulePath ); ~Module (); - ModuleType GetModuleType (const XMLAttribute& attribute ); + ModuleType GetModuleType ( const std::string& location, + const XMLAttribute& attribute ); std::string GetBasePath() const; std::string GetPath () const; std::string GetTargets () const; _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp 2005-01-09 01:58:53 UTC (rev 12900) +++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp 2005-01-09 03:29:46 UTC (rev 12901) @@ -9,7 +9,7 @@ ARE_EQUAL(2, project.modules.size()); Module& module1 = *project.modules[0]; - IS_TRUE(module1.type == BuildTool); + IS_TRUE(module1.etype == BuildTool); ARE_EQUAL(2, module1.files.size()); ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name); ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name); @@ -17,7 +17,7 @@ ARE_EQUAL(0, module1.libraries.size()); Module& module2 = *project.modules[1]; - IS_TRUE(module2.type == KernelModeDLL); + IS_TRUE(module2.etype == KernelModeDLL); ARE_EQUAL(2, module2.files.size()); ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name); ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);
19 years, 10 months
1
0
0
0
[royce] 12900: replaced Backend Factory's vector with a map.
by royce@svn.reactos.com
replaced Backend Factory's vector with a map. added a map of the MingwModuleHandlers that's created at startup time Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/pch.h _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp 2005-01-09 01:58:53 UTC (rev 12900) @@ -6,15 +6,17 @@ using std::string; using std::vector; +using std::map; -vector<Backend::Factory*>* Backend::Factory::factories = NULL; +map<const char*,Backend::Factory*>* Backend::Factory::factories = NULL; Backend::Factory::Factory ( const std::string& name_ ) - : name(name_) { + string name(name_); + strlwr ( &name[0] ); if ( !factories ) - factories = new vector<Factory*>; - factories->push_back ( this ); + factories = new map<const char*,Factory*>; + (*factories)[name.c_str()] = this; } /*static*/ Backend* @@ -24,15 +26,13 @@ strlwr ( &sname[0] ); if ( !factories || !factories->size() ) throw Exception ( "internal tool error: no registered factories" ); - vector<Backend::Factory*>& fact = *factories; - for ( size_t i = 0; i < fact.size(); i++ ) + Backend::Factory* f = (*factories)[sname.c_str()]; + if ( !f ) { - //char* p = *fact[i]; - if ( sname == fact[i]->name ) - return (*fact[i]) ( project ); + throw UnknownBackendException ( sname ); + return NULL; } - throw UnknownBackendException ( sname ); - return NULL; + return (*f) ( project ); } Backend::Backend ( Project& project ) _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h 2005-01-09 01:58:53 UTC (rev 12900) @@ -12,8 +12,7 @@ public: class Factory { - static std::vector<Factory*>* factories; - std::string name; + static std::map<const char*,Factory*>* factories; protected: _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-09 01:58:53 UTC (rev 12900) @@ -43,6 +43,7 @@ fMakefile = fopen ( ProjectNode.makefile.c_str (), "w" ); if ( !fMakefile ) throw AccessDeniedException ( ProjectNode.makefile ); + MingwModuleHandler::SetMakefile ( fMakefile ); } void @@ -89,27 +90,10 @@ void MingwBackend::ProcessModule ( Module& module ) { - MingwModuleHandlerList moduleHandlers; - GetModuleHandlers ( moduleHandlers ); - for (size_t i = 0; i < moduleHandlers.size (); i++) - { - MingwModuleHandler& moduleHandler = *moduleHandlers[i]; - if (moduleHandler.CanHandleModule ( module ) ) - { - moduleHandler.Process ( module ); - return; - } - } + MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.name ); + h->Process ( module ); } -void -MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers ) const -{ - moduleHandlers.push_back ( new MingwBuildToolModuleHandler ( fMakefile ) ); - moduleHandlers.push_back ( new MingwKernelModuleHandler ( fMakefile ) ); - moduleHandlers.push_back ( new MingwStaticLibraryModuleHandler ( fMakefile ) ); -} - string FixupTargetFilename ( const string& targetFilename ) { _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-01-09 01:58:53 UTC (rev 12900) @@ -4,26 +4,6 @@ #include "../backend.h" #include "modulehandler.h" -class MingwModuleHandlerList : public std::vector<MingwModuleHandler*> -{ -public: - MingwModuleHandlerList() - { - } - ~MingwModuleHandlerList() - { - for ( size_t i = 0; i < size(); i++ ) - { - delete (*this)[i]; - } - } -private: - // disable copy semantics - MingwModuleHandlerList ( const MingwModuleHandlerList& ); - MingwModuleHandlerList& operator = ( const MingwModuleHandlerList& ); -}; - - class MingwBackend : public Backend { public: @@ -31,7 +11,6 @@ virtual void Process (); private: void ProcessModule ( Module& module ); - void GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers ) const; void CreateMakefile (); void CloseMakefile (); void GenerateHeader (); _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 01:58:53 UTC (rev 12900) @@ -8,12 +8,45 @@ using std::string; using std::vector; +using std::map; -MingwModuleHandler::MingwModuleHandler ( FILE* fMakefile ) - : fMakefile ( fMakefile ) +map<const char*,MingwModuleHandler*>* +MingwModuleHandler::handler_map = NULL; + +FILE* +MingwModuleHandler::fMakefile = NULL; + +MingwModuleHandler::MingwModuleHandler ( const char* moduletype_ ) { + string moduletype ( moduletype_ ); + strlwr ( &moduletype[0] ); + if ( !handler_map ) + handler_map = new map<const char*,MingwModuleHandler*>; + (*handler_map)[moduletype.c_str()] = this; } +/*static*/ void +MingwModuleHandler::SetMakefile ( FILE* f ) +{ + fMakefile = f; +} + +/*static*/ MingwModuleHandler* +MingwModuleHandler::LookupHandler ( const string& moduletype_ ) +{ + string moduletype ( moduletype_ ); + strlwr ( &moduletype[0] ); + if ( !handler_map ) + throw Exception ( "internal tool error: no registered module handlers" ); + MingwModuleHandler* h = (*handler_map)[moduletype.c_str()]; + if ( !h ) + { + throw UnknownModuleTypeException ( moduletype ); + return NULL; + } + return h; +} + string MingwModuleHandler::GetWorkingDirectory () const { @@ -352,7 +385,7 @@ string invokeTarget = module.GetInvocationTarget ( i ); fprintf ( fMakefile, "%s: %s\n\n", - invoke.GetTargets ().c_str (), + invoke.GetTargets ().c_str (), invokeTarget.c_str () ); fprintf ( fMakefile, "%s: %s\n", @@ -398,22 +431,17 @@ sourceFilenames.c_str (), preconditionDependenciesName.c_str ()); fprintf ( fMakefile, - ".PNONY: %s\n\n", + ".PHONY: %s\n\n", preconditionDependenciesName.c_str () ); } +static MingwBuildToolModuleHandler buildtool_handler; -MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( FILE* fMakefile ) - : MingwModuleHandler ( fMakefile ) +MingwBuildToolModuleHandler::MingwBuildToolModuleHandler() + : MingwModuleHandler ( "buildtool" ) { } -bool -MingwBuildToolModuleHandler::CanHandleModule ( const Module& module ) const -{ - return module.type == BuildTool; -} - void MingwBuildToolModuleHandler::Process ( const Module& module ) { @@ -438,18 +466,13 @@ GenerateObjectFileTargetsHost ( module ); } +static MingwKernelModuleHandler kernelmodule_handler; -MingwKernelModuleHandler::MingwKernelModuleHandler ( FILE* fMakefile ) - : MingwModuleHandler ( fMakefile ) +MingwKernelModuleHandler::MingwKernelModuleHandler () + : MingwModuleHandler ( "kernelmodedll" ) { } -bool -MingwKernelModuleHandler::CanHandleModule ( const Module& module ) const -{ - return module.type == KernelModeDLL; -} - void MingwKernelModuleHandler::Process ( const Module& module ) { @@ -505,18 +528,13 @@ GenerateObjectFileTargetsTarget ( module ); } +static MingwStaticLibraryModuleHandler staticlibrary_handler; -MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ( FILE* fMakefile ) - : MingwModuleHandler ( fMakefile ) +MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler () + : MingwModuleHandler ( "staticlibrary" ) { } -bool -MingwStaticLibraryModuleHandler::CanHandleModule ( const Module& module ) const -{ - return module.type == StaticLibrary; -} - void MingwStaticLibraryModuleHandler::Process ( const Module& module ) { _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h 2005-01-09 01:58:53 UTC (rev 12900) @@ -6,9 +6,15 @@ class MingwModuleHandler { public: - MingwModuleHandler ( FILE* fMakefile ); - virtual bool CanHandleModule ( const Module& module ) const = 0; + static std::map<const char*,MingwModuleHandler*>* handler_map; + + MingwModuleHandler ( const char* moduletype_ ); + virtual ~MingwModuleHandler() {} + + static void SetMakefile ( FILE* f ); + static MingwModuleHandler* LookupHandler ( const std::string& moduletype_ ); virtual void Process ( const Module& module ) = 0; + protected: std::string MingwModuleHandler::GetWorkingDirectory () const; std::string ReplaceExtension ( const std::string& filename, @@ -29,7 +35,7 @@ std::string GetInvocationParameters ( const Invoke& invoke ) const; void GenerateInvocations ( const Module& module ) const; void GeneratePreconditionDependencies ( const Module& module ) const; - FILE* fMakefile; + static FILE* fMakefile; private: std::string ConcatenatePaths ( const std::string& path1, const std::string& path2 ) const; @@ -49,8 +55,7 @@ class MingwBuildToolModuleHandler : public MingwModuleHandler { public: - MingwBuildToolModuleHandler ( FILE* fMakefile ); - virtual bool CanHandleModule ( const Module& module ) const; + MingwBuildToolModuleHandler (); virtual void Process ( const Module& module ); private: void GenerateBuildToolModuleTarget ( const Module& module ); @@ -60,8 +65,7 @@ class MingwKernelModuleHandler : public MingwModuleHandler { public: - MingwKernelModuleHandler ( FILE* fMakefile ); - virtual bool CanHandleModule ( const Module& module ) const; + MingwKernelModuleHandler (); virtual void Process ( const Module& module ); private: void GenerateKernelModuleTarget ( const Module& module ); @@ -71,8 +75,7 @@ class MingwStaticLibraryModuleHandler : public MingwModuleHandler { public: - MingwStaticLibraryModuleHandler ( FILE* fMakefile ); - virtual bool CanHandleModule ( const Module& module ) const; + MingwStaticLibraryModuleHandler (); virtual void Process ( const Module& module ); private: void GenerateStaticLibraryModuleTarget ( const Module& module ); _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp 2005-01-09 01:58:53 UTC (rev 12900) @@ -122,3 +122,9 @@ name.c_str() ) { } + +UnknownModuleTypeException::UnknownModuleTypeException ( const string& moduletype ) + : Exception ( "module type requested: '%s'", + moduletype.c_str() ) +{ +} _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h --- branches/xmlbuildsystem/reactos/tools/rbuild/exception.h 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.h 2005-01-09 01:58:53 UTC (rev 12900) @@ -92,4 +92,10 @@ UnknownBackendException ( const std::string& name ); }; +class UnknownModuleTypeException : public Exception +{ +public: + UnknownModuleTypeException ( const std::string& moduletype ); +}; + #endif /* __EXCEPTION_H */ _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/pch.h --- branches/xmlbuildsystem/reactos/tools/rbuild/pch.h 2005-01-09 01:25:16 UTC (rev 12899) +++ branches/xmlbuildsystem/reactos/tools/rbuild/pch.h 2005-01-09 01:58:53 UTC (rev 12900) @@ -9,6 +9,7 @@ #include <string> #include <vector> +#include <map> #include <stdarg.h>
19 years, 10 months
1
0
0
0
[chorns] 12899: Put global includes last.
by chorns@svn.reactos.com
Put global includes last. Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 01:13:31 UTC (rev 12898) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 01:25:16 UTC (rev 12899) @@ -187,9 +187,9 @@ string MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const { - string parameters = GenerateGccIncludeParametersFromVector ( module.project.includes ); - string s = GenerateGccIncludeParametersFromVector ( module.includes ); - if (s.length () > 0) + string parameters = GenerateGccIncludeParametersFromVector ( module.includes ); + string s = GenerateGccIncludeParametersFromVector ( module.project.includes ); + if ( s.length () > 0 ) { parameters += " "; parameters += s; @@ -202,7 +202,7 @@ { string parameters = GenerateGccDefineParameters ( module ); string s = GenerateGccIncludeParameters ( module ); - if (s.length () > 0) + if ( s.length () > 0 ) { parameters += " "; parameters += s;
19 years, 10 months
1
0
0
0
[chorns] 12898: Fix compile error
by chorns@svn.reactos.com
Fix compile error Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/invoketest.cpp _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/invoketest.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/tests/invoketest.cpp 2005-01-09 01:10:43 UTC (rev 12897) +++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/invoketest.cpp 2005-01-09 01:13:31 UTC (rev 12898) @@ -14,6 +14,6 @@ Invoke& invoke1 = *module1.invocations[0]; ARE_EQUAL(1, invoke1.output.size()); - File& file1 = *invoke1.output[0]; + InvokeFile& file1 = *invoke1.output[0]; ARE_EQUAL(".\\dir1\\file1.c", file1.name); }
19 years, 10 months
1
0
0
0
[chorns] 12897: Precondition dependencies.
by chorns@svn.reactos.com
Precondition dependencies. Modified: branches/xmlbuildsystem/reactos/ReactOS.xml Deleted: branches/xmlbuildsystem/reactos/ntoskrnl/module.xml Added: branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml Modified: branches/xmlbuildsystem/reactos/tools/buildno.c Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h Modified: branches/xmlbuildsystem/reactos/tools/tools.xml Added: branches/xmlbuildsystem/reactos/tools/wmc/wmc.xml _____ Modified: branches/xmlbuildsystem/reactos/ReactOS.xml --- branches/xmlbuildsystem/reactos/ReactOS.xml 2005-01-09 00:04:32 UTC (rev 12896) +++ branches/xmlbuildsystem/reactos/ReactOS.xml 2005-01-09 01:10:43 UTC (rev 12897) @@ -16,6 +16,6 @@ <xi:include href="lib/directory.xml" /> </directory> <directory name="ntoskrnl"> - <xi:include href="ntoskrnl/module.xml" /> + <xi:include href="ntoskrnl/ntoskrnl.xml" /> </directory> </project> _____ Deleted: branches/xmlbuildsystem/reactos/ntoskrnl/module.xml --- branches/xmlbuildsystem/reactos/ntoskrnl/module.xml 2005-01-09 00:04:32 UTC (rev 12896) +++ branches/xmlbuildsystem/reactos/ntoskrnl/module.xml 2005-01-09 01:10:43 UTC (rev 12897) @@ -1,368 +0,0 @@ -<module name="ntoskrnl" type="kernelmodedll" extension=".exe"> - <dependency>buildno</dependency> - <define name="_SEH_NO_NATIVE_NLG" /> - <define name="_DISABLE_TIDENTS" /> - <define name="__NTOSKRNL__" /> - <define name="__3GB__" /> - <include base="kjs">./include</include> - <include base="ntoskrnl">include</include> - <library>kjs</library> - <directory name="cc"> - <file>cacheman.c</file> - <file>copy.c</file> - <file>fs.c</file> - <file>mdl.c</file> - <file>pin.c</file> - <file>view.c</file> - </directory> - <directory name="cm"> - <file>import.c</file> - <file>ntfunc.c</file> - <file>regfile.c</file> - <file>registry.c</file> - <file>regobj.c</file> - <file>rtlfunc.c</file> - </directory> - <directory name="dbg"> - <if property="arch" value="i386"> - <directory name="i386"> - <if property="kdbg" value="true"> - <group> - <file>i386-dis.c</file> - <file>kdb_help.S</file> - </group> - </if> - </directory> - </if> - <if property="kdbg" value="true"> - <group> - <file>kdb.c</file> - <file>kdb_keyboard.c</file> - <file>kdb_serial.c</file> - <file>rdebug.c</file> - <file>profile.c</file> - </group> - </if> - <or> - <!-- - <if property="kdbg" value="true"> - <group> - <file>kdb_stabs.c</file> - <file>kdb_symbols.c</file> - </group> - </if> - --> - <if property="dbg" value="true"> - <group> - <file>kdb_stabs.c</file> - <file>kdb_symbols.c</file> - </group> - </if> - </or> - <file>dbgctrl.c</file> - <file>errinfo.c</file> - <file>print.c</file> - <file>user.c</file> - </directory> - <directory name="ex"> - <if property="arch" value="i386"> - <directory name="i386"> - <file>interlck.c</file> - </directory> - </if> - <file>btree.c</file> - <file>callback.c</file> - <file>fmutex.c</file> - <file>hashtab.c</file> - <file>init.c</file> - <file>interlck.c</file> - <file>list.c</file> - <file>lookas.c</file> - <file>napi.c</file> - <file>power.c</file> - <file>resource.c</file> - <file>rundown.c</file> - <file>stree.c</file> - <file>synch.c</file> - <file>sysinfo.c</file> - <file>time.c</file> - <file>util.c</file> - <file>uuid.c</file> - <file>win32k.c</file> - <file>work.c</file> - <file>zone.c</file> - </directory> - <directory name="fs"> - <file>dbcsname.c</file> - <file>filelock.c</file> - <file>mcb.c</file> - <file>mdl.c</file> - <file>name.c</file> - <file>notify.c</file> - <file>oplock.c</file> - <file>pool.c</file> - <file>tunnel.c</file> - <file>unc.c</file> - <file>util.c</file> - </directory> - <directory name="inbv"> - <file>inbv.c</file> - </directory> - <directory name="io"> - <file>adapter.c</file> - <file>arcname.c</file> - <file>bootlog.c</file> - <file>buildirp.c</file> - <file>cancel.c</file> - <file>cleanup.c</file> - <file>cntrller.c</file> - <file>create.c</file> - <file>device.c</file> - <file>deviface.c</file> - <file>dir.c</file> - <file>driver.c</file> - <file>errlog.c</file> - <file>error.c</file> - <file>event.c</file> - <file>file.c</file> - <file>flush.c</file> - <file>fs.c</file> - <file>iocomp.c</file> - <file>ioctrl.c</file> - <file>iomgr.c</file> - <file>iowork.c</file> - <file>irp.c</file> - <file>irq.c</file> - <file>lock.c</file> - <file>mailslot.c</file> - <file>mdl.c</file> - <file>npipe.c</file> - <file>page.c</file> - <file>parttab.c</file> - <file>pnpdma.c</file> - <file>pnpmgr.c</file> - <file>pnpnotify.c</file> - <file>pnpreport.c</file> - <file>pnproot.c</file> - <file>process.c</file> - <file>queue.c</file> - <file>rawfs.c</file> - <file>remlock.c</file> - <file>resource.c</file> - <file>rw.c</file> - <file>share.c</file> - <file>shutdown.c</file> - <file>symlink.c</file> - <file>timer.c</file> - <file>vpb.c</file> - <file>wdm.c</file> - <file>wmi.c</file> - <file>xhaldisp.c</file> - <file>xhaldrv.c</file> - </directory> - <directory name="kd"> - <file>dlog.c</file> - <file>gdbstub.c</file> - <file>kdebug.c</file> - <file>mda.c</file> - <file>service.c</file> - </directory> - <directory name="ke"> - <if property="arch" value="i386"> - <directory name="i386"> - <file>bios.c</file> - <file>brkpoint.c</file> - <file>bthread.S</file> - <file>exp.c</file> - <file>fpu.c</file> - <file>gdt.c</file> - <file>i386-mcount.S</file> - <file>idt.c</file> - <file>irq.c</file> - <file>irqhand.s</file> - <file>kernel.c</file> - <file>ldt.c</file> - <file>multiboot.S</file> - <file>stkswitch.S</file> - <file>syscall.S</file> - <file>thread.c</file> - <file>tlbflush.S</file> - <file>trap.S</file> - <file>tskswitch.S</file> - <file>tss.c</file> - <file>usercall.c</file> - <file>usertrap.c</file> - <file>v86m.c</file> - <file>v86m_sup.S</file> - </directory> - </if> - <file>apc.c</file> - <file>bug.c</file> - <file>catch.c</file> - <file>critical.c</file> - <file>device.c</file> - <file>dpc.c</file> - <file>error.c</file> - <file>event.c</file> - <file>gmutex.c</file> - <file>ipi.c</file> - <file>kqueue.c</file> - <file>kthread.c</file> - <file>main.c</file> - <file>mutex.c</file> - <file>process.c</file> - <file>profile.c</file> - <file>queue.c</file> - <file>sem.c</file> - <file>spinlock.c</file> - <file>timer.c</file> - <file>wait.c</file> - </directory> - <directory name="ldr"> - <file>init.c</file> - <file>loader.c</file> - <file>resource.c</file> - <file>rtl.c</file> - <file>sysdll.c</file> - <file>userldr.c</file> - </directory> - <directory name="lpc"> - <file>close.c</file> - <file>complete.c</file> - <file>connect.c</file> - <file>create.c</file> - <file>listen.c</file> - <file>port.c</file> - <file>query.c</file> - <file>queue.c</file> - <file>receive.c</file> - <file>reply.c</file> - <file>send.c</file> - </directory> - <directory name="mm"> - <if property="arch" value="i386"> - <directory name="i386"> - <file>memsafe.s</file> - <file>page.c</file> - <file>pfault.c</file> - </directory> - </if> - <file>anonmem.c</file> - <file>aspace.c</file> - <file>balance.c</file> - <file>cont.c</file> - <file>drvlck.c</file> - <file>elf32.c</file> - <file>elf64.c</file> - <file>elf.c</file> - <file>freelist.c</file> - <file>iospace.c</file> - <file>kmap.c</file> - <file>marea.c</file> - <file>mdl.c</file> - <file>mm.c</file> - <file>mminit.c</file> - <file>mpw.c</file> - <file>ncache.c</file> - <file>npool.c</file> - <file>pagefile.c</file> - <file>pageop.c</file> - <file>pager.c</file> - <file>pagfault.c</file> - <file>paging.c</file> - <file>pe.c</file> - <file>physical.c</file> - <file>pool.c</file> - <file>ppool.c</file> - <file>region.c</file> - <file>rmap.c</file> - <file>section.c</file> - <file>slab.c</file> - <file>verifier.c</file> - <file>virtual.c</file> - <file>wset.c</file> - </directory> - <directory name="nt"> - <file>channel.c</file> - <file>efi.c</file> - <file>evtpair.c</file> - <file>misc.c</file> - <file>mutant.c</file> - <file>nt.c</file> - <file>ntevent.c</file> - <file>ntsem.c</file> - <file>nttimer.c</file> - <file>plugplay.c</file> - <file>profile.c</file> - <file>vdm.c</file> - </directory> - <directory name="ob"> - <file>dirobj.c</file> - <file>handle.c</file> - <file>namespc.c</file> - <file>ntobj.c</file> - <file>object.c</file> - <file>sdcache.c</file> - <file>security.c</file> - <file>symlink.c</file> - </directory> - <directory name="po"> - <file>power.c</file> - </directory> - <directory name="ps"> - <if property="arch" value="i386"> - <directory name="i386"> - <file>continue.c</file> - </directory> - </if> - <file>cid.c</file> - <file>create.c</file> - <file>debug.c</file> - <file>idle.c</file> - <file>job.c</file> - <file>kill.c</file> - <file>locale.c</file> - <file>process.c</file> - <file>psmgr.c</file> - <file>suspend.c</file> - <file>thread.c</file> - <file>tinfo.c</file> - <file>w32call.c</file> - <file>win32.c</file> - </directory> - <directory name="rtl"> - <if property="arch" value="i386"> - <directory name="i386"> - <file>exception.c</file> - </directory> - </if> - <file>atom.c</file> - <file>capture.c</file> - <file>ctype.c</file> - <file>handle.c</file> - <file>libsupp.c</file> - <file>message.c</file> - <file>nls.c</file> - <file>purecall.c</file> - <file>rangelist.c</file> - <file>regio.c</file> - <file>sprintf.c</file> - <file>stdlib.c</file> - <file>string.c</file> - <file>strtok.c</file> - <file>swprintf.c</file> - <file>wstring.c</file> - </directory> - <directory name="se"> - <file>access.c</file> - <file>acl.c</file> - <file>audit.c</file> - <file>lsa.c</file> - <file>luid.c</file> - <file>priv.c</file> - <file>sd.c</file> - <file>semgr.c</file> - <file>sid.c</file> - <file>token.c</file> - </directory> -</module> _____ Copied: branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml (from rev 12891, branches/xmlbuildsystem/reactos/ntoskrnl/module.xml) --- branches/xmlbuildsystem/reactos/ntoskrnl/module.xml 2005-01-08 19:38:51 UTC (rev 12891) +++ branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml 2005-01-09 01:10:43 UTC (rev 12897) @@ -0,0 +1,378 @@ +<module name="ntoskrnl" type="kernelmodedll" extension=".exe"> + <dependency>buildno</dependency> + <dependency>wmc</dependency> + <define name="_SEH_NO_NATIVE_NLG" /> + <define name="_DISABLE_TIDENTS" /> + <define name="__NTOSKRNL__" /> + <define name="__3GB__" /> + <include base="kjs">./include</include> + <include base="ntoskrnl">include</include> + <library>kjs</library> + <invoke module="wmc"> + <input> + <inputfile>ntoskrnl.mc</inputfile> + </input> + <output> + <outputfile switches="-H">../include/reactos/bugcodes.h</outputfile> + <outputfile switches="-o">bugcodes.rc</outputfile> + </output> + </invoke> + <directory name="cc"> + <file>cacheman.c</file> + <file>copy.c</file> + <file>fs.c</file> + <file>mdl.c</file> + <file>pin.c</file> + <file>view.c</file> + </directory> + <directory name="cm"> + <file>import.c</file> + <file>ntfunc.c</file> + <file>regfile.c</file> + <file>registry.c</file> + <file>regobj.c</file> + <file>rtlfunc.c</file> + </directory> + <directory name="dbg"> + <if property="arch" value="i386"> + <directory name="i386"> + <if property="kdbg" value="true"> + <group> + <file>i386-dis.c</file> + <file>kdb_help.S</file> + </group> + </if> + </directory> + </if> + <if property="kdbg" value="true"> + <group> + <file>kdb.c</file> + <file>kdb_keyboard.c</file> + <file>kdb_serial.c</file> + <file>rdebug.c</file> + <file>profile.c</file> + </group> + </if> + <or> + <!-- + <if property="kdbg" value="true"> + <group> + <file>kdb_stabs.c</file> + <file>kdb_symbols.c</file> + </group> + </if> + --> + <if property="dbg" value="true"> + <group> + <file>kdb_stabs.c</file> + <file>kdb_symbols.c</file> + </group> + </if> + </or> + <file>dbgctrl.c</file> + <file>errinfo.c</file> + <file>print.c</file> + <file>user.c</file> + </directory> + <directory name="ex"> + <if property="arch" value="i386"> + <directory name="i386"> + <file>interlck.c</file> + </directory> + </if> + <file>btree.c</file> + <file>callback.c</file> + <file>fmutex.c</file> + <file>hashtab.c</file> + <file>init.c</file> + <file>interlck.c</file> + <file>list.c</file> + <file>lookas.c</file> + <file>napi.c</file> + <file>power.c</file> + <file>resource.c</file> + <file>rundown.c</file> + <file>stree.c</file> + <file>synch.c</file> + <file>sysinfo.c</file> + <file>time.c</file> + <file>util.c</file> + <file>uuid.c</file> + <file>win32k.c</file> + <file>work.c</file> + <file>zone.c</file> + </directory> + <directory name="fs"> + <file>dbcsname.c</file> + <file>filelock.c</file> + <file>mcb.c</file> + <file>mdl.c</file> + <file>name.c</file> + <file>notify.c</file> + <file>oplock.c</file> + <file>pool.c</file> + <file>tunnel.c</file> + <file>unc.c</file> + <file>util.c</file> + </directory> + <directory name="inbv"> + <file>inbv.c</file> + </directory> + <directory name="io"> + <file>adapter.c</file> + <file>arcname.c</file> + <file>bootlog.c</file> + <file>buildirp.c</file> + <file>cancel.c</file> + <file>cleanup.c</file> + <file>cntrller.c</file> + <file>create.c</file> + <file>device.c</file> + <file>deviface.c</file> + <file>dir.c</file> + <file>driver.c</file> + <file>errlog.c</file> + <file>error.c</file> + <file>event.c</file> + <file>file.c</file> + <file>flush.c</file> + <file>fs.c</file> + <file>iocomp.c</file> + <file>ioctrl.c</file> + <file>iomgr.c</file> + <file>iowork.c</file> + <file>irp.c</file> + <file>irq.c</file> + <file>lock.c</file> + <file>mailslot.c</file> + <file>mdl.c</file> + <file>npipe.c</file> + <file>page.c</file> + <file>parttab.c</file> + <file>pnpdma.c</file> + <file>pnpmgr.c</file> + <file>pnpnotify.c</file> + <file>pnpreport.c</file> + <file>pnproot.c</file> + <file>process.c</file> + <file>queue.c</file> + <file>rawfs.c</file> + <file>remlock.c</file> + <file>resource.c</file> + <file>rw.c</file> + <file>share.c</file> + <file>shutdown.c</file> + <file>symlink.c</file> + <file>timer.c</file> + <file>vpb.c</file> + <file>wdm.c</file> + <file>wmi.c</file> + <file>xhaldisp.c</file> + <file>xhaldrv.c</file> + </directory> + <directory name="kd"> + <file>dlog.c</file> + <file>gdbstub.c</file> + <file>kdebug.c</file> + <file>mda.c</file> + <file>service.c</file> + </directory> + <directory name="ke"> + <if property="arch" value="i386"> + <directory name="i386"> + <file>bios.c</file> + <file>brkpoint.c</file> + <file>bthread.S</file> + <file>exp.c</file> + <file>fpu.c</file> + <file>gdt.c</file> + <file>i386-mcount.S</file> + <file>idt.c</file> + <file>irq.c</file> + <file>irqhand.s</file> + <file>kernel.c</file> + <file>ldt.c</file> + <file>multiboot.S</file> + <file>stkswitch.S</file> + <file>syscall.S</file> + <file>thread.c</file> + <file>tlbflush.S</file> + <file>trap.S</file> + <file>tskswitch.S</file> + <file>tss.c</file> + <file>usercall.c</file> + <file>usertrap.c</file> + <file>v86m.c</file> + <file>v86m_sup.S</file> + </directory> + </if> + <file>apc.c</file> + <file>bug.c</file> + <file>catch.c</file> + <file>critical.c</file> + <file>device.c</file> + <file>dpc.c</file> + <file>error.c</file> + <file>event.c</file> + <file>gmutex.c</file> + <file>ipi.c</file> + <file>kqueue.c</file> + <file>kthread.c</file> + <file>main.c</file> + <file>mutex.c</file> + <file>process.c</file> + <file>profile.c</file> + <file>queue.c</file> + <file>sem.c</file> + <file>spinlock.c</file> + <file>timer.c</file> + <file>wait.c</file> + </directory> + <directory name="ldr"> + <file>init.c</file> + <file>loader.c</file> + <file>resource.c</file> + <file>rtl.c</file> + <file>sysdll.c</file> + <file>userldr.c</file> + </directory> + <directory name="lpc"> + <file>close.c</file> + <file>complete.c</file> + <file>connect.c</file> + <file>create.c</file> + <file>listen.c</file> + <file>port.c</file> + <file>query.c</file> + <file>queue.c</file> + <file>receive.c</file> + <file>reply.c</file> + <file>send.c</file> + </directory> + <directory name="mm"> + <if property="arch" value="i386"> + <directory name="i386"> + <file>memsafe.s</file> + <file>page.c</file> + <file>pfault.c</file> + </directory> + </if> + <file>anonmem.c</file> + <file>aspace.c</file> + <file>balance.c</file> + <file>cont.c</file> + <file>drvlck.c</file> + <file>elf32.c</file> + <file>elf64.c</file> + <file>elf.c</file> + <file>freelist.c</file> + <file>iospace.c</file> + <file>kmap.c</file> + <file>marea.c</file> + <file>mdl.c</file> + <file>mm.c</file> + <file>mminit.c</file> + <file>mpw.c</file> + <file>ncache.c</file> + <file>npool.c</file> + <file>pagefile.c</file> + <file>pageop.c</file> + <file>pager.c</file> + <file>pagfault.c</file> + <file>paging.c</file> + <file>pe.c</file> + <file>physical.c</file> + <file>pool.c</file> + <file>ppool.c</file> + <file>region.c</file> + <file>rmap.c</file> + <file>section.c</file> + <file>slab.c</file> + <file>verifier.c</file> + <file>virtual.c</file> + <file>wset.c</file> + </directory> + <directory name="nt"> + <file>channel.c</file> + <file>efi.c</file> + <file>evtpair.c</file> + <file>misc.c</file> + <file>mutant.c</file> + <file>nt.c</file> + <file>ntevent.c</file> + <file>ntsem.c</file> + <file>nttimer.c</file> + <file>plugplay.c</file> + <file>profile.c</file> + <file>vdm.c</file> + </directory> + <directory name="ob"> + <file>dirobj.c</file> + <file>handle.c</file> + <file>namespc.c</file> + <file>ntobj.c</file> + <file>object.c</file> + <file>sdcache.c</file> + <file>security.c</file> + <file>symlink.c</file> + </directory> + <directory name="po"> + <file>power.c</file> + </directory> + <directory name="ps"> + <if property="arch" value="i386"> + <directory name="i386"> + <file>continue.c</file> + </directory> + </if> + <file>cid.c</file> + <file>create.c</file> + <file>debug.c</file> + <file>idle.c</file> + <file>job.c</file> + <file>kill.c</file> + <file>locale.c</file> + <file>process.c</file> + <file>psmgr.c</file> + <file>suspend.c</file> + <file>thread.c</file> + <file>tinfo.c</file> + <file>w32call.c</file> + <file>win32.c</file> + </directory> + <directory name="rtl"> + <if property="arch" value="i386"> + <directory name="i386"> + <file>exception.c</file> + </directory> + </if> + <file>atom.c</file> + <file>capture.c</file> + <file>ctype.c</file> + <file>handle.c</file> + <file>libsupp.c</file> + <file>message.c</file> + <file>nls.c</file> + <file>purecall.c</file> + <file>rangelist.c</file> + <file>regio.c</file> + <file>sprintf.c</file> + <file>stdlib.c</file> + <file>string.c</file> + <file>strtok.c</file> + <file>swprintf.c</file> + <file>wstring.c</file> + </directory> + <directory name="se"> + <file>access.c</file> + <file>acl.c</file> + <file>audit.c</file> + <file>lsa.c</file> + <file>luid.c</file> + <file>priv.c</file> + <file>sd.c</file> + <file>semgr.c</file> + <file>sid.c</file> + <file>token.c</file> + </directory> +</module> _____ Modified: branches/xmlbuildsystem/reactos/tools/buildno.c --- branches/xmlbuildsystem/reactos/tools/buildno.c 2005-01-09 00:04:32 UTC (rev 12896) +++ branches/xmlbuildsystem/reactos/tools/buildno.c 2005-01-09 01:10:43 UTC (rev 12897) @@ -32,10 +32,8 @@ #define FALSE 0 #define TRUE 1 -/* File to (over)write */ -#define BUILDNO_INCLUDE_FILE "../include/reactos/buildno.h" - static char * argv0 = ""; +static char * filename = ""; #ifdef DBG void @@ -157,7 +155,7 @@ s = s + sprintf (s, "-%S\"\n", KERNEL_VERSION_BUILD_TYPE); s = s + sprintf (s, "#endif\n/* EOF */\n"); - h = fopen (BUILDNO_INCLUDE_FILE, "rb"); + h = fopen (filename, "rb"); if (h != NULL) { fseek(h, 0, SEEK_END); @@ -178,13 +176,13 @@ fclose(h); } - h = fopen (BUILDNO_INCLUDE_FILE, "wb"); + h = fopen (filename, "wb"); if (!h) { fprintf (stderr, "%s: can not create file \"%s\"!\n", argv0, - BUILDNO_INCLUDE_FILE); + filename); return; } fwrite(s1, 1, strlen(s1), h); @@ -196,7 +194,7 @@ { fprintf ( stderr, - "Usage: %s [-{p|q}]\n\n -p print version number and exit\n -q run in quiet mode\n", + "Usage: %s [-{p|q}] path-to-header\n\n -p print version number and exit\n -q run in quiet mode\n", argv0 ); exit (EXIT_SUCCESS); @@ -221,6 +219,7 @@ case 1: break; case 2: + case 3: if (argv[1][0] == '-') { if (argv[1][1] == 'q') @@ -235,7 +234,12 @@ { usage (); } + filename = argv[2]; } + else if (argc == 2) + { + filename = argv[1]; + } else { usage (); _____ Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 00:04:32 UTC (rev 12896) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-09 01:10:43 UTC (rev 12897) @@ -106,7 +106,7 @@ MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const { return FixupTargetFilename ( ReplaceExtension ( sourceFilename, - ".o" ) ); + ".o" ) ); } string @@ -221,12 +221,10 @@ { string sourceFilename = module.files[i]->name; string objectFilename = GetObjectFilename ( sourceFilename ); - string dependencies = GetModuleDependencies ( module ); fprintf ( fMakefile, - "%s: %s %s\n", + "%s: %s\n", objectFilename.c_str (), - sourceFilename.c_str (), - dependencies.c_str ()); + sourceFilename.c_str () ); fprintf ( fMakefile, "\t%s -c %s -o %s %s\n", cc.c_str (), @@ -293,27 +291,64 @@ for ( size_t i = 0; i < module.invocations.size (); i++ ) { Invoke& invoke = *module.invocations[i]; + if (invoke.invokeModule == &module) + /* Protect against circular dependencies */ + continue; if ( dependencies.length () > 0 ) dependencies += " "; - string invokeTarget = module.GetInvocationTarget ( i ); - dependencies += invokeTarget; + dependencies += invoke.GetTargets (); } return dependencies; } - + +string +MingwModuleHandler::GetInvocationParameters ( const Invoke& invoke ) const +{ + string parameters ( "" ); + size_t i; + for (i = 0; i < invoke.output.size (); i++) + { + if (parameters.length () > 0) + parameters += " "; + InvokeFile& invokeFile = *invoke.output[i]; + if (invokeFile.switches.length () > 0) + { + parameters += invokeFile.switches; + parameters += " "; + } + parameters += invokeFile.name; + } + + for (i = 0; i < invoke.input.size (); i++) + { + if (parameters.length () > 0) + parameters += " "; + InvokeFile& invokeFile = *invoke.input[i]; + if (invokeFile.switches.length () > 0) + { + parameters += invokeFile.switches; + parameters += " "; + } + parameters += invokeFile.name; + } + + return parameters; +} + void MingwModuleHandler::GenerateInvocations ( const Module& module ) const { if ( module.invocations.size () == 0 ) return; - if ( module.type != BuildTool ) - throw InvalidBuildFileException ( module.node.location, - "Only modules of type buildtool can be invoked." ); - for ( size_t i = 0; i < module.invocations.size (); i++ ) { - Invoke& invoke = *module.invocations[i]; + const Invoke& invoke = *module.invocations[i]; + + if ( invoke.invokeModule->type != BuildTool ) + throw InvalidBuildFileException ( module.node.location, + "Only modules of type buildtool can be invoked." ); + string invokeTarget = module.GetInvocationTarget ( i ); fprintf ( fMakefile, "%s: %s\n\n", @@ -322,17 +357,52 @@ fprintf ( fMakefile, "%s: %s\n", invokeTarget.c_str (), - FixupTargetFilename ( module.GetPath () ).c_str () ); + FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () ); fprintf ( fMakefile, - "\t%s\n\n", - FixupTargetFilename ( module.GetPath () ).c_str () ); + "\t%s %s\n\n", + FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (), + GetInvocationParameters ( invoke ).c_str () ); fprintf ( fMakefile, ".PNONY: %s\n\n", invokeTarget.c_str () ); } } +string +MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) const +{ + return ssprintf ( "%s_precondition", + module.name.c_str () ); +} +void +MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const +{ + string preconditionDependenciesName = GetPreconditionDependenciesName ( module ); + string sourceFilenames = GetSourceFilenames ( module ); + string dependencies = GetModuleDependencies ( module ); + string s = GetInvocationDependencies ( module ); + if ( s.length () > 0 ) + { + if ( dependencies.length () > 0 ) + dependencies += " "; + dependencies += s; + } + + fprintf ( fMakefile, + "%s: %s\n\n", + preconditionDependenciesName.c_str (), + dependencies.c_str () ); + fprintf ( fMakefile, + "%s: %s\n\n", + sourceFilenames.c_str (), + preconditionDependenciesName.c_str ()); + fprintf ( fMakefile, + ".PNONY: %s\n\n", + preconditionDependenciesName.c_str () ); +} + + MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( FILE* fMakefile ) : MingwModuleHandler ( fMakefile ) { @@ -347,6 +417,7 @@ void MingwBuildToolModuleHandler::Process ( const Module& module ) { [truncated at 1000 lines; 241 more skipped]
19 years, 10 months
1
0
0
0
[gvg] 12896: Install symbol files by default for DBG := 1 builds
by gvg@svn.reactos.com
Install symbol files by default for DBG := 1 builds Modified: trunk/reactos/tools/helper.mk _____ Modified: trunk/reactos/tools/helper.mk --- trunk/reactos/tools/helper.mk 2005-01-09 00:00:31 UTC (rev 12895) +++ trunk/reactos/tools/helper.mk 2005-01-09 00:04:32 UTC (rev 12896) @@ -635,9 +635,12 @@ TARGET_CFLAGS += $(MK_CFLAGS) $(STD_CFLAGS) ifeq ($(DBG),1) -TARGET_ASFLAGS += -g -TARGET_CFLAGS += -g -TARGET_LFLAGS += -g + TARGET_ASFLAGS += -g + TARGET_CFLAGS += -g + TARGET_LFLAGS += -g + ifeq ($(INSTALL_SYMBOLS),) + INSTALL_SYMBOLS := yes + endif endif TARGET_CPPFLAGS += $(MK_CPPFLAGS) $(STD_CPPFLAGS) @@ -1047,10 +1050,9 @@ forceinstall: $(SUBDIRS:%=%_install) $(MK_FULLNAME) $(MK_BASENAME).sym $(HALFVERBOSEECHO) [INSTALL] $(MK_FULLNAME) to $(MK_INSTALLDIR)/$(MK_INSTALL_FULLNAME) + -$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_INSTALL_FULLNAME) $(HALFVERBOSEECHO) [INSTALL] $(MK_BASENAME).sym to symbols/$(MK_INSTALL_BASENAME).sym - -$(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_INSTALL_FULLNAME) -$(CP) $(MK_BASENAME).sym $(INSTALL_DIR)/symbols/$(MK_INSTALL_BASENAME).sym - @echo $(MK_FULLNAME) was successfully installed. else # INSTALL_SYMBOLS
19 years, 10 months
1
0
0
0
[gvg] 12895: Include COFF symbols in our .sym files
by gvg@svn.reactos.com
Include COFF symbols in our .sym files Modified: trunk/reactos/include/coff.h Modified: trunk/reactos/include/ntos/kdbgsyms.h Modified: trunk/reactos/ntoskrnl/dbg/kdb_stabs.c Modified: trunk/reactos/ntoskrnl/dbg/kdb_symbols.c Modified: trunk/reactos/tools/rsym.c _____ Modified: trunk/reactos/include/coff.h --- trunk/reactos/include/coff.h 2005-01-08 23:36:03 UTC (rev 12894) +++ trunk/reactos/include/coff.h 2005-01-09 00:00:31 UTC (rev 12895) @@ -6,12 +6,6 @@ extern "C" { #endif -/* - * #ifndef __dj_ENFORCE_ANSI_FREESTANDING - * #ifndef __STRICT_ANSI__ - * #ifndef _POSIX_SOURCE - */ - /*** coff information for Intel 386/486. */ /********************** FILE HEADER **********************/ @@ -329,13 +323,6 @@ /* For new sections we havn't heard of before */ #define DEFAULT_SECTION_ALIGNMENT 4 -/* - * #endif /* !_POSIX_SOURCE */ - * #endif /* !__STRICT_ANSI__ */ - * #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ - */ -#ifndef __dj_ENFORCE_FUNCTION_CALLS -#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ #ifdef __cplusplus } _____ Modified: trunk/reactos/include/ntos/kdbgsyms.h --- trunk/reactos/include/ntos/kdbgsyms.h 2005-01-08 23:36:03 UTC (rev 12894) +++ trunk/reactos/include/ntos/kdbgsyms.h 2005-01-09 00:00:31 UTC (rev 12895) @@ -8,6 +8,10 @@ ULONG_PTR ImageBase; ULONG_PTR ImageSize; PVOID FileBuffer; + PVOID StabsBase; + ULONG StabsLength; + PVOID StabStringsBase; + ULONG StabStringsLength; PVOID SymbolsBase; ULONG SymbolsLength; PVOID SymbolStringsBase; _____ Modified: trunk/reactos/ntoskrnl/dbg/kdb_stabs.c --- trunk/reactos/ntoskrnl/dbg/kdb_stabs.c 2005-01-08 23:36:03 UTC (rev 12894) +++ trunk/reactos/ntoskrnl/dbg/kdb_stabs.c 2005-01-09 00:00:31 UTC (rev 12895) @@ -69,8 +69,8 @@ PVOID StabsEnd; ULONG_PTR AddrFound = 0; - StabEntry = SymbolInfo->SymbolsBase; - StabsEnd = (PVOID)((ULONG_PTR)SymbolInfo->SymbolsBase + SymbolInfo->SymbolsLength); + StabEntry = SymbolInfo->StabsBase; + StabsEnd = (PVOID)((ULONG_PTR)SymbolInfo->StabsBase + SymbolInfo->StabsLength); if (StartEntry != NULL) { ASSERT((ULONG_PTR)StartEntry >= (ULONG_PTR)StabEntry); _____ Modified: trunk/reactos/ntoskrnl/dbg/kdb_symbols.c --- trunk/reactos/ntoskrnl/dbg/kdb_symbols.c 2005-01-08 23:36:03 UTC (rev 12894) +++ trunk/reactos/ntoskrnl/dbg/kdb_symbols.c 2005-01-09 00:00:31 UTC (rev 12895) @@ -17,6 +17,34 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* + * Parts of this file based on work Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/kdb_symbols.c * PURPOSE: Getting symbol information... @@ -41,6 +69,7 @@ #include <internal/safe.h> #include <internal/kd.h> #include <rosrtl/string.h> +#include <coff.h> #define NDEBUG #include <internal/debug.h> @@ -55,6 +84,10 @@ ULONG StabsLength; ULONG StabstrOffset; ULONG StabstrLength; + ULONG SymbolsOffset; + ULONG SymbolsLength; + ULONG SymbolstrOffset; + ULONG SymbolstrLength; } SYMBOLFILE_HEADER, *PSYMBOLFILE_HEADER; typedef struct _IMAGE_SYMBOL_INFO_CACHE { @@ -62,6 +95,10 @@ ULONG RefCount; UNICODE_STRING FileName; PVOID FileBuffer; + PVOID StabsBase; + ULONG StabsLength; + PVOID StabStringsBase; + ULONG StabStringsLength; PVOID SymbolsBase; ULONG SymbolsLength; PVOID SymbolStringsBase; @@ -282,7 +319,68 @@ return TRUE; } +/*! \brief Find a COFF symbol entry... + * + * Finds the COFF symbol as close as possible before the specified address + * + * \param SymbolInfo Pointer to the symbol info. + * \param RelativeAddress Relative address of address to look for. + * + * \returns Pointer to a external_syment + * \retval NULL No entry found. + */ +static struct external_syment * +KdbpSymbolsFindEntry(IN PIMAGE_SYMBOL_INFO SymbolInfo, + IN ULONG_PTR RelativeAddress) +{ + /* + * Perform a binary search. + * + * The code below is a bit sneaky. After a comparison fails, we + * divide the work in half by moving either left or right. If lim + * is odd, moving left simply involves halving lim: e.g., when lim + * is 5 we look at item 2, so we change lim to 2 so that we will + * look at items 0 & 1. If lim is even, the same applies. If lim + * is odd, moving right again involes halving lim, this time moving + * the base up one item past p: e.g., when lim is 5 we change base + * to item 3 and make lim 2 so that we will look at items 3 and 4. + * If lim is even, however, we have to shrink it by one before + * halving: e.g., when lim is 4, we still looked at item 2, so we + * have to make lim 3, then halve, obtaining 1, so that we will only + * look at item 3. + */ + struct external_syment *Base = (struct external_syment *) SymbolInfo->SymbolsBase; + ULONG Lim; + struct external_syment *Mid, *Low; + if (SymbolInfo->SymbolsLength < sizeof(struct external_syment) + || RelativeAddress < Base->e_value) + { + return NULL; + } + + Low = Base; + for (Lim = SymbolInfo->SymbolsLength / sizeof(struct external_syment); Lim != 0; Lim >>= 1) + { + Mid = Base + (Lim >> 1); + if (RelativeAddress == Mid->e_value) + { + return Mid; + } + if (Mid->e_value < RelativeAddress) /* key > mid: move right */ + { + Low = Mid; + Base = Mid + 1; + Lim--; + } /* else move left */ + } + + ASSERT(Low->e_value < RelativeAddress); + + return Low; +} + + /*! \brief Get information for an address (source file, line number, * function name) * @@ -306,12 +404,13 @@ OUT PCH FileName OPTIONAL, OUT PCH FunctionName OPTIONAL) { - PSTAB_ENTRY FunctionEntry = NULL, FileEntry = NULL, LineEntry = NULL; + PSTAB_ENTRY StabsFunctionEntry = NULL, FileEntry = NULL, LineEntry = NULL; + struct external_syment *SymbolsFunctionEntry = NULL; DPRINT("RelativeAddress = 0x%08x\n", RelativeAddress); - if (SymbolInfo->SymbolsBase == NULL || SymbolInfo->SymbolsLength == 0 || - SymbolInfo->SymbolStringsBase == NULL || SymbolInfo->SymbolStringsLength == 0) + if (SymbolInfo->StabsBase == NULL || SymbolInfo->StabsLength == 0 || + SymbolInfo->StabStringsBase == NULL || SymbolInfo->StabStringsLength == 0) { return STATUS_UNSUCCESSFUL; } @@ -330,24 +429,24 @@ if (LineNumber != NULL || FunctionName != NULL) { /* find stab entry for function */ - FunctionEntry = KdbpStabFindEntry(SymbolInfo, N_FUN, (PVOID)RelativeAddress, NULL); - if (FunctionEntry == NULL) + StabsFunctionEntry = KdbpStabFindEntry(SymbolInfo, N_FUN, (PVOID)RelativeAddress, NULL); + if (StabsFunctionEntry == NULL) { DPRINT("No function stab entry found. RelativeAddress %p\n", RelativeAddress); } - if (LineNumber != NULL && FunctionEntry != NULL) + if (LineNumber != NULL && StabsFunctionEntry != NULL) { /* find stab entry for line number */ - ULONG_PTR FunctionRelativeAddress = RelativeAddress - FunctionEntry->n_value; + ULONG_PTR FunctionRelativeAddress = RelativeAddress - StabsFunctionEntry->n_value; ULONG_PTR AddrFound = 0; PSTAB_ENTRY NextLineEntry; - LineEntry = NextLineEntry = FunctionEntry; + LineEntry = NextLineEntry = StabsFunctionEntry; while (NextLineEntry != NULL) { NextLineEntry++; - if ((ULONG_PTR)NextLineEntry >= ((ULONG_PTR)SymbolInfo->SymbolsBase + SymbolInfo->SymbolsLength)) + if ((ULONG_PTR)NextLineEntry >= ((ULONG_PTR)SymbolInfo->StabsBase + SymbolInfo->StabsLength)) break; if (NextLineEntry->n_type == N_FUN) break; @@ -364,6 +463,14 @@ } } + if (FunctionName != NULL + && SymbolInfo->SymbolsBase != NULL && SymbolInfo->SymbolsLength != 0 + && SymbolInfo->SymbolStringsBase != NULL && SymbolInfo->SymbolStringsLength != 0) + { + /* find symbol entry for function */ + SymbolsFunctionEntry = KdbpSymbolsFindEntry(SymbolInfo, RelativeAddress); + } + if (FileName != NULL) { /* find stab entry for file name */ @@ -373,7 +480,7 @@ FileEntry = KdbpStabFindEntry(SymbolInfo, N_SO, (PVOID)RelativeAddress, NULL); if (FileEntry != NULL) { - p = (PCHAR)SymbolInfo->SymbolStringsBase + FileEntry->n_strx; + p = (PCHAR)SymbolInfo->StabStringsBase + FileEntry->n_strx; Length = strlen(p); if (p[Length - 1] == '/' || p[Length - 1] == '\\') /* source dir */ FileEntry = KdbpStabFindEntry(SymbolInfo, N_SO, (PVOID)RelativeAddress, FileEntry + 1); @@ -384,9 +491,10 @@ } } - if (((LineNumber != NULL && LineEntry == NULL) || LineNumber == NULL) && - ((FileName != NULL && FileEntry == NULL) || FileName == NULL) && - ((FunctionName != NULL && FunctionEntry == NULL) || FunctionName == NULL)) + if (((LineNumber != NULL && LineEntry == NULL) || LineNumber == NULL) && + ((FileName != NULL && FileEntry == NULL) || FileName == NULL) && + ((FunctionName != NULL && StabsFunctionEntry == NULL && SymbolsFunctionEntry == NULL) || + FunctionName == NULL)) { DPRINT("None of the requested information was found!\n"); return STATUS_UNSUCCESSFUL; @@ -403,18 +511,56 @@ PCHAR Name = ""; if (FileEntry != NULL) { - Name = (PCHAR)SymbolInfo->SymbolStringsBase + FileEntry->n_strx; + Name = (PCHAR)SymbolInfo->StabStringsBase + FileEntry->n_strx; } strcpy(FileName, Name); } if (FunctionName != NULL) { PCHAR Name = "", p; - if (FunctionEntry != NULL) - Name = (PCHAR)SymbolInfo->SymbolStringsBase + FunctionEntry->n_strx; - strcpy(FunctionName, Name); - if ((p = strchr(FunctionName, ':')) != NULL) /* remove extra info from function name */ - *p = '\0'; + if (StabsFunctionEntry != NULL) + { + if (SymbolsFunctionEntry == NULL || + SymbolsFunctionEntry->e_value <= StabsFunctionEntry->n_value) + { + Name = (PCHAR)SymbolInfo->StabStringsBase + StabsFunctionEntry->n_strx; + strcpy(FunctionName, Name); + if ((p = strchr(FunctionName, ':')) != NULL) /* remove extra info from function name */ + { + *p = '\0'; + } + } + else if (SymbolsFunctionEntry != NULL) + { + if (SymbolsFunctionEntry->e.e.e_zeroes == 0) + { + Name = (PCHAR) SymbolInfo->SymbolStringsBase + SymbolsFunctionEntry->e.e.e_offset; + strcpy(FunctionName, Name); + } + else + { + memcpy(FunctionName, SymbolsFunctionEntry->e.e_name, E_SYMNMLEN); + FunctionName[E_SYMNMLEN] = '\0'; + } + } + } + else if (SymbolsFunctionEntry != NULL) + { + if (SymbolsFunctionEntry->e.e.e_zeroes == 0) + { + Name = (PCHAR) SymbolInfo->SymbolStringsBase + SymbolsFunctionEntry->e.e.e_offset; + strcpy(FunctionName, Name); + } + else + { + memcpy(FunctionName, SymbolsFunctionEntry->e.e_name, E_SYMNMLEN); + FunctionName[E_SYMNMLEN] = '\0'; + } + } + else + { + FunctionName[0] = '\0'; + } } return STATUS_SUCCESS; @@ -449,14 +595,14 @@ FileNameLength = strlen(FileName); FuncNameLength = strlen(FuncName); - for (Entry = SymbolInfo->SymbolsBase; - (ULONG_PTR)Entry < (ULONG_PTR)(SymbolInfo->SymbolsBase + SymbolInfo->SymbolsLength); + for (Entry = SymbolInfo->StabsBase; + (ULONG_PTR)Entry < (ULONG_PTR)(SymbolInfo->StabsBase + SymbolInfo->StabsLength); Entry++) { if (Entry->n_type != N_SO) continue; - SymbolName = (PCHAR)SymbolInfo->SymbolStringsBase + Entry->n_strx; + SymbolName = (PCHAR)SymbolInfo->StabStringsBase + Entry->n_strx; Length = strlen(SymbolName); if (SymbolName[Length - 1] == '/' || SymbolName[Length - 1] == '\\') @@ -473,7 +619,7 @@ continue; Entry++; - for (;(ULONG_PTR)Entry < (ULONG_PTR)(SymbolInfo->SymbolsBase + SymbolInfo->SymbolsLength); + for (;(ULONG_PTR)Entry < (ULONG_PTR)(SymbolInfo->StabsBase + SymbolInfo->StabsLength); Entry++) { if (Entry->n_type == N_FUN) @@ -487,7 +633,7 @@ continue; else /* if (FunctionName != NULL) */ { - SymbolName = (PCHAR)SymbolInfo->SymbolStringsBase + Entry->n_strx; + SymbolName = (PCHAR)SymbolInfo->StabStringsBase + Entry->n_strx; p = strchr(SymbolName, ':'); if (p == NULL) return FALSE; @@ -589,6 +735,10 @@ ASSERT(CacheEntry->FileName.Buffer); CacheEntry->RefCount = 1; CacheEntry->FileBuffer = SymbolInfo->FileBuffer; + CacheEntry->StabsBase = SymbolInfo->StabsBase; + CacheEntry->StabsLength = SymbolInfo->StabsLength; + CacheEntry->StabStringsBase = SymbolInfo->StabStringsBase; + CacheEntry->StabStringsLength = SymbolInfo->StabStringsLength; CacheEntry->SymbolsBase = SymbolInfo->SymbolsBase; CacheEntry->SymbolsLength = SymbolInfo->SymbolsLength; CacheEntry->SymbolStringsBase = SymbolInfo->SymbolStringsBase; @@ -692,6 +842,10 @@ { DPRINT("Found cached symbol file %wZ\n", &SymFileName); SymbolInfo->FileBuffer = CachedSymbolFile->FileBuffer; + SymbolInfo->StabsBase = CachedSymbolFile->StabsBase; + SymbolInfo->StabsLength = CachedSymbolFile->StabsLength; + SymbolInfo->StabStringsBase = CachedSymbolFile->StabStringsBase; + SymbolInfo->StabStringsLength = CachedSymbolFile->StabStringsLength; SymbolInfo->SymbolsBase = CachedSymbolFile->SymbolsBase; SymbolInfo->SymbolsLength = CachedSymbolFile->SymbolsLength; SymbolInfo->SymbolStringsBase = CachedSymbolFile->SymbolStringsBase; @@ -769,16 +923,23 @@ SymbolFileHeader = (PSYMBOLFILE_HEADER) FileBuffer; SymbolInfo->FileBuffer = FileBuffer; - SymbolInfo->SymbolsBase = FileBuffer + SymbolFileHeader->StabsOffset; - SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength; - SymbolInfo->SymbolStringsBase = FileBuffer + SymbolFileHeader->StabstrOffset; - SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength; + SymbolInfo->StabsBase = FileBuffer + SymbolFileHeader->StabsOffset; + SymbolInfo->StabsLength = SymbolFileHeader->StabsLength; + SymbolInfo->StabStringsBase = FileBuffer + SymbolFileHeader->StabstrOffset; + SymbolInfo->StabStringsLength = SymbolFileHeader->StabstrLength; + SymbolInfo->SymbolsBase = FileBuffer + SymbolFileHeader->SymbolsOffset; + SymbolInfo->SymbolsLength = SymbolFileHeader->SymbolsLength; + SymbolInfo->SymbolStringsBase = FileBuffer + SymbolFileHeader->SymbolstrOffset; + SymbolInfo->SymbolStringsLength = SymbolFileHeader->SymbolstrLength; /* add file to cache */ KdbpSymAddCachedFile(&SymFileName, SymbolInfo); - DPRINT("Installed stabs: %wZ (%08x-%08x,%08x)\n", + DPRINT("Installed stabs: %wZ (%08x-%08x,%08x) (%08x-%08x,%08x)\n", FileName, + SymbolInfo->StabsBase, + SymbolInfo->StabsLength + SymbolInfo->StabsBase, + SymbolInfo->StabStringsBase, SymbolInfo->SymbolsBase, SymbolInfo->SymbolsLength + SymbolInfo->SymbolsBase, SymbolInfo->SymbolStringsBase); @@ -800,6 +961,8 @@ { KdbpSymRemoveCachedFile(SymbolInfo); SymbolInfo->FileBuffer = NULL; + SymbolInfo->StabsBase = NULL; + SymbolInfo->StabsLength = 0; SymbolInfo->SymbolsBase = NULL; SymbolInfo->SymbolsLength = 0; } @@ -955,10 +1118,14 @@ KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart); SymbolInfo->FileBuffer = SymbolFileHeader; - SymbolInfo->SymbolsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->StabsOffset; - SymbolInfo->SymbolsLength = SymbolFileHeader->StabsLength; - SymbolInfo->SymbolStringsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->StabstrOffset; - SymbolInfo->SymbolStringsLength = SymbolFileHeader->StabstrLength; + SymbolInfo->StabsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->StabsOffset; + SymbolInfo->StabsLength = SymbolFileHeader->StabsLength; + SymbolInfo->StabStringsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->StabstrOffset; + SymbolInfo->StabStringsLength = SymbolFileHeader->StabstrLength; + SymbolInfo->SymbolsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->SymbolsOffset; + SymbolInfo->SymbolsLength = SymbolFileHeader->SymbolsLength; + SymbolInfo->SymbolStringsBase = (PVOID)SymbolFileHeader + SymbolFileHeader->SymbolstrOffset; + SymbolInfo->SymbolStringsLength = SymbolFileHeader->SymbolstrLength; /* add file to cache */ RtlInitAnsiString(&AnsiString, SymbolName); @@ -966,10 +1133,13 @@ KdbpSymAddCachedFile(&UnicodeString, SymbolInfo); RtlFreeUnicodeString(&UnicodeString); - DPRINT("Installed stabs: %s@%08x-%08x (%08x-%08x,%08x)\n", + DPRINT("Installed stabs: %s@%08x-%08x (%08x-%08x,%08x) (%08x-%08x,%08x)\n", FileName, ModuleObject->Base, ModuleObject->Length + ModuleObject->Base, + SymbolInfo->StabsBase, + SymbolInfo->StabsLength + SymbolInfo->StabsBase, + SymbolInfo->StabStringsBase, SymbolInfo->SymbolsBase, SymbolInfo->SymbolsLength + SymbolInfo->SymbolsBase, SymbolInfo->SymbolStringsBase); _____ Modified: trunk/reactos/tools/rsym.c --- trunk/reactos/tools/rsym.c 2005-01-08 23:36:03 UTC (rev 12894) +++ trunk/reactos/tools/rsym.c 2005-01-09 00:00:31 UTC (rev 12895) @@ -111,6 +111,10 @@ unsigned long StabsLength; unsigned long StabstrOffset; unsigned long StabstrLength; + unsigned long SymbolsOffset; + unsigned long SymbolsLength; + unsigned long SymbolstrOffset; + unsigned long SymbolstrLength; } SYMBOLFILE_HEADER, *PSYMBOLFILE_HEADER; typedef struct _STAB_ENTRY { @@ -133,6 +137,83 @@ unsigned long Length; } STR_ENTRY, *PSTR_ENTRY; +/* COFF symbol table */ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +#define N_BTMASK (0xf) +#define N_TMASK (0x30) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + +/* derived types, in e_type */ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +#define BTYPE(x) ((x) & N_BTMASK) + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) +#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +#define C_EFCN 0xff /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + +#pragma pack(push,1) +typedef struct _EXTERNAL_SYMENT +{ + union + { + char e_name[E_SYMNMLEN]; + struct + { + unsigned long e_zeroes; + unsigned long e_offset; + } + e; + } + e; + unsigned long e_value; + short e_scnum; + unsigned short e_type; + unsigned char e_sclass; + unsigned char e_numaux; +} EXTERNAL_SYMENT, *PEXTERNAL_SYMENT; +#pragma pack(pop) + char* convert_path(char* origpath) { char* newpath; @@ -161,6 +242,52 @@ return(newpath); } +static void +RelocateString(ULONG *Offset, PSTR_ENTRY StrEntry, ULONG *StrCount, PVOID SymbolStringsBase) +{ + ULONG i; + + for (i = 0; i < *StrCount; i++) + { + if (*Offset == StrEntry[i].OldOffset) + { + *Offset = StrEntry[i].NewOffset; + return; + } + } + + StrEntry[*StrCount].OldOffset = *Offset; + StrEntry[*StrCount].Name = (char*) SymbolStringsBase + StrEntry[*StrCount].OldOffset; + StrEntry[*StrCount].Length = strlen(StrEntry[*StrCount].Name) + 1; + if (*StrCount == 0) + { + StrEntry[*StrCount].NewOffset = 0; + } + else + { + StrEntry[*StrCount].NewOffset = StrEntry[*StrCount - 1].NewOffset + + StrEntry[*StrCount - 1].Length; + } + *Offset = StrEntry[*StrCount].NewOffset; + (*StrCount)++; +} + +static int +CompareSyment(const PEXTERNAL_SYMENT SymEntry1, const PEXTERNAL_SYMENT SymEntry2) +{ + if (SymEntry1->e_value < SymEntry2->e_value) + { + return -1; + } + + if (SymEntry2->e_value < SymEntry1->e_value) + { + return +1; + } + + return 0; +} + #define TRANSFER_SIZE (65536) int main(int argc, char* argv[]) @@ -175,6 +302,10 @@ ULONG SymbolsLength; PVOID SymbolStringsBase; ULONG SymbolStringsLength; + PVOID CoffSymbolsBase; + ULONG CoffSymbolsLength; + PVOID CoffSymbolStringsBase; + ULONG CoffSymbolStringsLength; ULONG Idx; char* path1; char* path2; @@ -188,31 +319,34 @@ ULONG SymbolsCount; PSTR_ENTRY StrEntry; ULONG StrCount; - ULONG j; + PSTR_ENTRY CoffStrEntry; + ULONG CoffStrCount; + PEXTERNAL_SYMENT SymEntry; + unsigned NumAux; - if (argc != 3) - { - fprintf(stderr, "Too many arguments\n"); - exit(1); - } + if (argc != 3) + { + fprintf(stderr, "Too many arguments\n"); + exit(1); + } - path1 = convert_path(argv[1]); - path2 = convert_path(argv[2]); + path1 = convert_path(argv[1]); + path2 = convert_path(argv[2]); - in = fopen(path1, "rb"); - if (in == NULL) - { - perror("Cannot open input file"); - exit(1); - } + in = fopen(path1, "rb"); + if (in == NULL) + { + perror("Cannot open input file"); + exit(1); + } - out = fopen(path2, "wb"); - if (out == NULL) - { - perror("Cannot open output file"); - fclose(in); - exit(1); - } + out = fopen(path2, "wb"); + if (out == NULL) + { + perror("Cannot open output file"); + fclose(in); + exit(1); + } /* Check if MZ header exists */ n_in = fread(&PEDosHeader, 1, sizeof(PEDosHeader), in); @@ -302,30 +436,7 @@ for (i = 0; i < Count; i++) { - for (j = 0; j < StrCount; j++) - { - if (StabEntry[i].n_strx == StrEntry[j].OldOffset) - { - StabEntry[i].n_strx = StrEntry[j].NewOffset; - break; - } - } - if (j >= StrCount) - { - StrEntry[StrCount].OldOffset = StabEntry[i].n_strx; - StrEntry[StrCount].Name = (char*)SymbolStringsBase + StrEntry[StrCount].OldOffset; - StrEntry[StrCount].Length = strlen(StrEntry[StrCount].Name) + 1; - if (StrCount == 0) - { - StrEntry[StrCount].NewOffset = 0; - } - else - { - StrEntry[StrCount].NewOffset = StrEntry[StrCount-1].NewOffset + StrEntry[StrCount-1].Length; - } - StabEntry[i].n_strx = StrEntry[StrCount].NewOffset; - StrCount++; - } + RelocateString(&StabEntry[i].n_strx, StrEntry, &StrCount, SymbolStringsBase); } SymbolFileHeader.StabsOffset = sizeof(SYMBOLFILE_HEADER); @@ -333,12 +444,93 @@ SymbolFileHeader.StabstrOffset = SymbolFileHeader.StabsOffset + SymbolFileHeader.StabsLength; SymbolFileHeader.StabstrLength = StrEntry[StrCount-1].NewOffset + StrEntry[StrCount-1].Length; + if (0 == PEFileHeader.PointerToSymbolTable || 0 == PEFileHeader.NumberOfSymbols) + { + /* No COFF symbol table */ + SymbolFileHeader.SymbolsOffset = 0; + SymbolFileHeader.SymbolsLength = 0; + SymbolFileHeader.SymbolstrOffset = 0; + SymbolFileHeader.SymbolstrLength = 0; + } + else + { + CoffSymbolsLength = PEFileHeader.NumberOfSymbols * sizeof(EXTERNAL_SYMENT); + CoffSymbolsBase = malloc(CoffSymbolsLength); + if (NULL == CoffSymbolsBase) + { + fprintf(stderr, "Unable to allocate %u bytes for COFF symbols\n", + (unsigned) CoffSymbolsLength); + exit(1); + } + fseek(in, PEFileHeader.PointerToSymbolTable, SEEK_SET); + n_in = fread(CoffSymbolsBase, 1, CoffSymbolsLength, in); + + SymEntry = CoffSymbolsBase; + Count = 0; + for (i = 0; i < PEFileHeader.NumberOfSymbols; i++) + { + NumAux = SymEntry[i].e_numaux; + if (ISFCN(SymEntry[i].e_type)) + { + SymEntry[Count] = SymEntry[i]; + if (0 < SymEntry[Count].e_scnum) + { + if (PEFileHeader.NumberOfSections < SymEntry[Count].e_scnum) + { + fprintf(stderr, "Invalid section number %d in COFF symbols (only %d sections present)\n", + SymEntry[Count].e_scnum, PEFileHeader.NumberOfSections); + exit(1); + } + SymEntry[Count].e_value += PESectionHeaders[SymEntry[Count].e_scnum - 1].VirtualAddress; + SymEntry[Count].e_scnum = -3; + SymEntry[Count].e_numaux = 0; + } + Count++; + } + i += NumAux; + } + + qsort(CoffSymbolsBase, Count, sizeof(EXTERNAL_SYMENT), (int (*)(const void *, const void *)) CompareSyment); + + n_in = fread(&CoffSymbolStringsLength, 1, sizeof(ULONG), in); + CoffSymbolStringsBase = malloc(CoffSymbolStringsLength); + if (NULL == CoffSymbolStringsBase) + { + fprintf(stderr, "Unable to allocate %u bytes for COFF symbol strings\n", + (unsigned) CoffSymbolStringsLength); + exit(1); + } + n_in = fread((char *) CoffSymbolStringsBase + sizeof(ULONG), 1, CoffSymbolStringsLength - 4, in); + + CoffStrEntry = malloc(sizeof(STR_ENTRY) * Count); + CoffStrCount = 0; + + for (i = 0; i < Count; i++) + { + if (0 == SymEntry[i].e.e.e_zeroes) + { + RelocateString(&SymEntry[i].e.e.e_offset, CoffStrEntry, &CoffStrCount, CoffSymbolStringsBase); + } + } + + SymbolFileHeader.SymbolsOffset = SymbolFileHeader.StabstrOffset + SymbolFileHeader.StabstrLength; + SymbolFileHeader.SymbolsLength = Count * sizeof(EXTERNAL_SYMENT); + SymbolFileHeader.SymbolstrOffset = SymbolFileHeader.SymbolsOffset + SymbolFileHeader.SymbolsLength; + SymbolFileHeader.SymbolstrLength = CoffStrEntry[CoffStrCount - 1].NewOffset + + CoffStrEntry[CoffStrCount - 1].Length; + } + n_out = fwrite(&SymbolFileHeader, 1, sizeof(SYMBOLFILE_HEADER), out); n_out = fwrite(SymbolsBase, 1, SymbolFileHeader.StabsLength, out); for (i = 0; i < StrCount; i++) { fwrite(StrEntry[i].Name, 1, StrEntry[i].Length, out); } + n_out = fwrite(CoffSymbolsBase, 1, SymbolFileHeader.SymbolsLength, out); + for (i = 0; i < CoffStrCount; i++) + { + fwrite(CoffStrEntry[i].Name, 1, CoffStrEntry[i].Length, out); + } fclose(out); exit(0);
19 years, 10 months
1
0
0
0
← Newer
1
...
45
46
47
48
49
50
51
...
71
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200