Author: peterw
Date: Thu Oct 25 05:15:26 2007
New Revision: 29861
URL: http://svn.reactos.org/svn/reactos?rev=29861&view=rev
Log:
- Added a small utility (chkslash) to check if a string contains
a backslash '\', it's needed for the reladdr2line.cmd changes
below.
- Modified reladdr2line so that you can now use 'raddr2line ntdll.dll 7c90e143'
instead of 'raddr2line output-i386\dll\ntdll\ntdll.dll 7c90e143'. You can
also use part of the file name ie. 'ntdll' instead of 'ntdll.dll' and
it will match it. Searchs the current directory and all sub-directories.
(does not match directories of course)
(yes you can still specify the full path if you like)
- Some other miscellaneous cleanup.
Added:
trunk/tools/RosBE-Windows/Tools/chkslash.c (with props)
Modified:
trunk/tools/RosBE-Windows/Root/reladdr2line.cmd
trunk/tools/RosBE-Windows/Tools/chknewer.c
trunk/tools/RosBE-Windows/Tools/makefile
Modified: trunk/tools/RosBE-Windows/Root/reladdr2line.cmd
URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Root/reladdr2l…
==============================================================================
--- trunk/tools/RosBE-Windows/Root/reladdr2line.cmd (original)
+++ trunk/tools/RosBE-Windows/Root/reladdr2line.cmd Thu Oct 25 05:15:26 2007
@@ -5,64 +5,84 @@
:: PURPOSE: Converts a value to hex and displays it.
:: COPYRIGHT: Copyright 2007 Christoph von Wittich <Christoph_vW(a)reactos.org>
:: Daniel Reimer <reimer.daniel(a)freenet.de>
+:: Peter Ward <dralnix(a)gmail.com>
::
::
@echo off
-title relAddr2Line...
+title reladdr2line...
+
+::
+:: Clear variables before use.
+::
+set _1=
+set _2=
::
:: Receive the Parameters and decide what to do.
::
-
-if "%1" == "" (
- goto :MAN
+if not "%3" == "" (
+ echo ERROR: Too many parameters specified.
+ goto :EOC
)
if not "%1" == "" (
set _1=%1
- if "%2" == "" (
- goto :AUTO1
- ) else (
- set _2=%2
- goto :EOC
- )
+ call :CHECKPATH
)
+if not "%2" == "" (
+ set _2=%2
+)
+call :INTERACTIVE
-::
-:: If Parameters were set, parse them, if not, ask the user to add them.
-::
-:MAN
-set /p _1="Please enter the path to the executable to be examined: "
-:AUTO1
-set /p _2="Please enter the address you would like to analyze: "
-
-:EOC
-if not exist "%_1%\." (
- echo ERROR: The path specified doesn't seem to exist.
- goto :END
-)
-if /i "%_1%" == "" (
- echo ERROR: You must enter a valid directory.
- goto :END
-)
-if /i "%_2%" == "" (
- echo ERROR: You must enter a address to analyze.
- goto :END
-)
+:RADD2RLINE
::
:: First get the ImageBase of the File. If its smaller than the given
:: Parameter, everything is ok, because it was already added onto the
:: adress and can be given directly to raddr2line. If not, add it and
:: give the result to raddr2line.
::
+if %_1% == "" (
+ echo ERROR: You must specify a path/file to examine.
+ goto :EOC
+)
+if not exist "%_1%\." (
+ echo ERROR: The path specified doesn't seem to exist.
+ goto :EOC
+)
for /f "tokens=2" %%i in ('"objdump -p %_1% 2>NUL | findstr ImageBase"') do set baseaddr=0x%%i
if %%i lss %_2% (
- raddr2line "%_1%" "%_2%" 2>NUL
+ raddr2line "%_1%" "%_2%"
) else (
set /a baseaddr+=0x%_2%
for /f %%i in ('"echoh %baseaddr%"') do set relbase=%%i
- raddr2line "%_1%" "%relbase%" 2>NUL
+ raddr2line "%_1%" "%relbase%"
)
+goto :EOC
-:END
+::
+:: If Parameters were set, parse them, if not, ask the user to add them.
+::
+:INTERACTIVE
+if "%_1%" == "" (
+ set /p _1="Please enter the path/file to be examined: "
+ call :CHECKPATH
+)
+if "%_2%" == "" (
+ set /p _2="Please enter the address you would like to analyze: "
+)
+goto :EOF
+
+::
+:: Check if the user supplied a path, if they didn't look for
+:: the specified file in the current directory and any
+:: sub-directories.
+::
+:CHECKPATH
+ chkslash %_1%
+ if errorlevel 2 (
+ for /f "usebackq" %%i in (`"dir /a:-d /s /b %1 | findstr "%_1%""`) do set _1=%%i
+ )
+goto :EOF
+
+:EOC
title ReactOS Build Environment %_ROSBE_VERSION%
Modified: trunk/tools/RosBE-Windows/Tools/chknewer.c
URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Tools/chknewer…
==============================================================================
--- trunk/tools/RosBE-Windows/Tools/chknewer.c (original)
+++ trunk/tools/RosBE-Windows/Tools/chknewer.c Thu Oct 25 05:15:26 2007
@@ -11,11 +11,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
time_t
-StatFile(
+getfmodtime(
char* FileName
);
@@ -53,7 +52,7 @@
{
printf("%s: Error closing file \"%s\"\n", argv[0], argv[1]);
}
- file1time = StatFile(argv[1]);
+ file1time = getfmodtime(argv[1]);
if (!file1time)
{
printf("%s: Error unable to aquire stats for file: %s\n", argv[0], argv[1]);
@@ -73,7 +72,7 @@
{
printf("%s: Error closing file \"%s\"\n", argv[0], argv[2]);
}
- file2time = StatFile(argv[2]);
+ file2time = getfmodtime(argv[2]);
if (!file2time)
{
printf("%s: Error unable to aquire stats for file: %s\n", argv[0], argv[2]);
@@ -91,11 +90,11 @@
}
}
-time_t StatFile(char* FileName)
+time_t getfmodtime(char* filename)
{
struct stat filestat;
- if (!stat(FileName, &filestat))
+ if (!stat(filename, &filestat))
{
return mktime(localtime(&filestat.st_mtime));
}
Added: trunk/tools/RosBE-Windows/Tools/chkslash.c
URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Tools/chkslash…
==============================================================================
--- trunk/tools/RosBE-Windows/Tools/chkslash.c (added)
+++ trunk/tools/RosBE-Windows/Tools/chkslash.c Thu Oct 25 05:15:26 2007
@@ -1,0 +1,49 @@
+/*
+ * PROJECT: RosBE - ReactOS Build Environment for Windows.
+ * LICENSE: GPL - See LICENSE.txt in the top level directory.
+ * FILE: Tools/chkslash.c
+ * PURPOSE: Checks if a string has a backslash '\' in it or not.
+ * COPYRIGHT: Copyright 2007 Peter Ward <dralnix(a)gmail.com>
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char* argv[])
+{
+ int hasslash = 0;
+ unsigned int i = 0;
+
+ if (argc > 2)
+ {
+ printf("%s: Error too many parameters specified.\n", argv[0]);
+ return -1;
+ }
+ if ((argc == 1) ||
+ (!strncmp(argv[1], "/?", 2)) ||
+ (!strncmp(argv[1], "-h", 2)) ||
+ (!strncmp(argv[1], "--help", 6)))
+ {
+ printf("Usage: %s STRING\n", argv[0]);
+ printf("Checks if STRING has a backslash or not. Returns\n");
+ printf("1 if STRING has a backslash and 2 if not.\n\n");
+ return 0;
+ }
+ for (i = 0; i < strlen(argv[1]); i++)
+ {
+ if (argv[1][i] == '\\')
+ {
+ hasslash = 1;
+ }
+ }
+
+ if (hasslash)
+ {
+ return 1;
+ }
+ else
+ {
+ return 2;
+ }
+}
Propchange: trunk/tools/RosBE-Windows/Tools/chkslash.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/tools/RosBE-Windows/Tools/makefile
URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Tools/makefile…
==============================================================================
--- trunk/tools/RosBE-Windows/Tools/makefile (original)
+++ trunk/tools/RosBE-Windows/Tools/makefile Thu Oct 25 05:15:26 2007
@@ -7,13 +7,16 @@
LFLAGS := -s
WINVER := 0x502
-all: buildtime chknewer cpucount echoh flash getdate
+all: buildtime chknewer chkslash cpucount echoh flash getdate
buildtime: buildtime.c
${CC} ${CFLAGS} buildtime buildtime.c
chknewer: chknewer.c
${CC} ${CFLAGS} chknewer chknewer.c
+
+chkslash: chkslash.c
+ ${CC} ${CFLAGS} chkslash chkslash.c
cpucount: cpucount.c
${CC} ${CFLAGS} cpucount cpucount.c
@@ -28,4 +31,4 @@
${CC} ${CFLAGS} getdate getdate.c
clean:
- del /f buildtime.exe chknewer.exe cpucount.exe echoh.exe flash.exe getdate.exe
+ del /f buildtime.exe chknewer.exe chkslash.exe cpucount.exe echoh.exe flash.exe getdate.exe