Author: tkreuzer
Date: Sat May 2 01:39:47 2009
New Revision: 40765
URL:
http://svn.reactos.org/svn/reactos?rev=40765&view=rev
Log:
fix compilation of raddr2line, by moving it into the rsym folder, too. Thanks BugBoy for
noticing.
Added:
trunk/reactos/tools/rsym/raddr2line.c
- copied unchanged from r40759, trunk/reactos/tools/raddr2line.c
trunk/reactos/tools/rsym/raddr2line.mak
- copied, changed from r40669, trunk/reactos/tools/raddr2line.mak
Removed:
trunk/reactos/tools/raddr2line.c
trunk/reactos/tools/raddr2line.mak
Modified:
trunk/reactos/tools/tools.mak
Removed: trunk/reactos/tools/raddr2line.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/raddr2line.c?rev=407…
==============================================================================
--- trunk/reactos/tools/raddr2line.c [iso-8859-1] (original)
+++ trunk/reactos/tools/raddr2line.c (removed)
@@ -1,188 +1,0 @@
-/*
- * Usage: raddr2line input-file address/offset
- *
- * This is a tool and is compiled using the host compiler,
- * i.e. on Linux gcc and not mingw-gcc (cross-compiler).
- * Therefore we can't include SDK headers and we have to
- * duplicate some definitions here.
- * Also note that the internal functions are "old C-style",
- * returning an int, where a return of 0 means success and
- * non-zero is failure.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "rsym.h"
-
-size_t fixup_offset ( size_t ImageBase, size_t offset )
-{
-// if ( offset >= ImageBase )
-// offset -= ImageBase;
- return offset;
-}
-
-long
-my_atoi ( const char* a )
-{
- int i = 0;
- const char* fmt = "%x";
-
- if ( *a == '0' )
- {
- switch ( *++a )
- {
- case 'x':
- fmt = "%x";
- ++a;
- break;
- case 'd':
- fmt = "%d";
- ++a;
- break;
- default:
- fmt = "%o";
- break;
- }
- }
- sscanf ( a, fmt, &i );
- return i;
-}
-
-PIMAGE_SECTION_HEADER
-find_rossym_section ( PIMAGE_FILE_HEADER PEFileHeader,
- PIMAGE_SECTION_HEADER PESectionHeaders )
-{
- size_t i;
- for ( i = 0; i < PEFileHeader->NumberOfSections; i++ )
- {
- if ( 0 == strcmp ( (char*)PESectionHeaders[i].Name, ".rossym" ) )
- return &PESectionHeaders[i];
- }
- return NULL;
-}
-
-int
-find_and_print_offset (
- void* data,
- size_t offset )
-{
- PSYMBOLFILE_HEADER RosSymHeader = (PSYMBOLFILE_HEADER)data;
- PROSSYM_ENTRY Entries = (PROSSYM_ENTRY)((char*)data + RosSymHeader->SymbolsOffset);
- char* Strings = (char*)data + RosSymHeader->StringsOffset;
- size_t symbols = RosSymHeader->SymbolsLength / sizeof(ROSSYM_ENTRY);
- size_t i;
-
- //if ( RosSymHeader->SymbolsOffset )
-
- for ( i = 0; i < symbols; i++ )
- {
- if ( Entries[i].Address > offset )
- {
- if ( !i-- )
- return 1;
- else
- {
- PROSSYM_ENTRY e = &Entries[i];
- printf ( "%s:%u (%s)\n",
- &Strings[e->FileOffset],
- (unsigned int)e->SourceLine,
- &Strings[e->FunctionOffset] );
- return 0;
- }
- }
- }
- return 1;
-}
-
-int
-process_data ( const void* FileData, size_t FileSize, size_t offset )
-{
- PIMAGE_DOS_HEADER PEDosHeader;
- PIMAGE_FILE_HEADER PEFileHeader;
- PIMAGE_OPTIONAL_HEADER PEOptHeader;
- PIMAGE_SECTION_HEADER PESectionHeaders;
- PIMAGE_SECTION_HEADER PERosSymSectionHeader;
- size_t ImageBase;
- int res;
-
- /* Check if MZ header exists */
- PEDosHeader = (PIMAGE_DOS_HEADER)FileData;
- if (PEDosHeader->e_magic != IMAGE_DOS_MAGIC || PEDosHeader->e_lfanew == 0L)
- {
- perror("Input file is not a PE image.\n");
- return 1;
- }
-
- /* Locate PE file header */
- /* sizeof(ULONG) = sizeof(MAGIC) */
- PEFileHeader = (PIMAGE_FILE_HEADER)((char *)FileData + PEDosHeader->e_lfanew +
sizeof(ULONG));
-
- /* Locate optional header */
- PEOptHeader = (PIMAGE_OPTIONAL_HEADER)(PEFileHeader + 1);
- ImageBase = PEOptHeader->ImageBase;
-
- /* Locate PE section headers */
- PESectionHeaders = (PIMAGE_SECTION_HEADER)((char *) PEOptHeader +
PEFileHeader->SizeOfOptionalHeader);
-
- /* make sure offset is what we want */
- offset = fixup_offset ( ImageBase, offset );
-
- /* find rossym section */
- PERosSymSectionHeader = find_rossym_section (
- PEFileHeader, PESectionHeaders );
- if ( !PERosSymSectionHeader )
- {
- fprintf ( stderr, "Couldn't find rossym section in executable\n" );
- return 1;
- }
- res = find_and_print_offset ( (char*)FileData +
PERosSymSectionHeader->PointerToRawData,
- offset );
- if ( res )
- printf ( "??:0\n" );
- return res;
-}
-
-int
-process_file ( const char* file_name, size_t offset )
-{
- void* FileData;
- size_t FileSize;
- int res = 1;
-
- FileData = load_file ( file_name, &FileSize );
- if ( !FileData )
- {
- fprintf ( stderr, "An error occured loading '%s'\n", file_name );
- }
- else
- {
- res = process_data ( FileData, FileSize, offset );
- free ( FileData );
- }
-
- return res;
-}
-
-int main ( int argc, const char** argv )
-{
- char* path;
- size_t offset;
- int res;
-
- if ( argc != 3 )
- {
- fprintf(stderr, "Usage: raddr2line <exefile> <offset>\n");
- exit(1);
- }
-
- path = convert_path ( argv[1] );
- offset = my_atoi ( argv[2] );
-
- res = process_file ( path, offset );
-
- free ( path );
-
- return res;
-}
Removed: trunk/reactos/tools/raddr2line.mak
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/raddr2line.mak?rev=4…
==============================================================================
--- trunk/reactos/tools/raddr2line.mak [iso-8859-1] (original)
+++ trunk/reactos/tools/raddr2line.mak (removed)
@@ -1,41 +1,0 @@
-RADDR2LINE_BASE = $(TOOLS_BASE)
-RADDR2LINE_BASE_ = $(RADDR2LINE_BASE)$(SEP)
-
-RADDR2LINE_INT = $(INTERMEDIATE_)$(RADDR2LINE_BASE)
-RADDR2LINE_INT_ = $(RADDR2LINE_INT)$(SEP)
-RADDR2LINE_OUT = $(OUTPUT_)$(RADDR2LINE_BASE)
-RADDR2LINE_OUT_ = $(RADDR2LINE_OUT)$(SEP)
-
-RADDR2LINE_TARGET = \
- $(RADDR2LINE_OUT_)raddr2line$(EXEPOSTFIX)
-
-RADDR2LINE_SOURCES = \
- $(RADDR2LINE_BASE_)raddr2line.c \
- $(RADDR2LINE_BASE_)rsym_common.c
-
-RADDR2LINE_OBJECTS = \
- $(addprefix $(INTERMEDIATE_), $(RADDR2LINE_SOURCES:.c=.o))
-
-RADDR2LINE_HOST_CFLAGS = $(TOOLS_CFLAGS)
-
-RADDR2LINE_HOST_LFLAGS = $(TOOLS_LFLAGS)
-
-.PHONY: raddr2line
-raddr2line: $(RADDR2LINE_TARGET)
-
-$(RADDR2LINE_TARGET): $(RADDR2LINE_OBJECTS) | $(RADDR2LINE_OUT)
- $(ECHO_HOSTLD)
- ${host_gcc} $(RADDR2LINE_OBJECTS) $(RADDR2LINE_HOST_LFLAGS) -o $@
-
-$(RADDR2LINE_INT_)raddr2line.o: $(RADDR2LINE_BASE_)raddr2line.c | $(RADDR2LINE_INT)
- $(ECHO_HOSTCC)
- ${host_gcc} $(RADDR2LINE_HOST_CFLAGS) -c $< -o $@
-
-#$(RADDR2LINE_INT_)rsym_common.o: $(RADDR2LINE_BASE_)rsym_common.c | $(RADDR2LINE_INT)
-# $(ECHO_HOSTCC)
-# ${host_gcc} $(RADDR2LINE_HOST_CFLAGS) -c $< -o $@
-
-.PHONY: raddr2line_clean
-raddr2line_clean:
- -@$(rm) $(RADDR2LINE_TARGET) $(RADDR2LINE_OBJECTS) 2>$(NUL)
-clean: raddr2line_clean
Copied: trunk/reactos/tools/rsym/raddr2line.mak (from r40669,
trunk/reactos/tools/raddr2line.mak)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rsym/raddr2line.mak?…
==============================================================================
--- trunk/reactos/tools/raddr2line.mak [iso-8859-1] (original)
+++ trunk/reactos/tools/rsym/raddr2line.mak [iso-8859-1] Sat May 2 01:39:47 2009
@@ -1,4 +1,4 @@
-RADDR2LINE_BASE = $(TOOLS_BASE)
+RADDR2LINE_BASE = $(TOOLS_BASE)$(SEP)rsym
RADDR2LINE_BASE_ = $(RADDR2LINE_BASE)$(SEP)
RADDR2LINE_INT = $(INTERMEDIATE_)$(RADDR2LINE_BASE)
Modified: trunk/reactos/tools/tools.mak
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/tools.mak?rev=40765&…
==============================================================================
--- trunk/reactos/tools/tools.mak [iso-8859-1] (original)
+++ trunk/reactos/tools/tools.mak [iso-8859-1] Sat May 2 01:39:47 2009
@@ -49,6 +49,6 @@
include tools/ofw_interface/ofw_interface.mak
endif
include tools/pefixup.mak
-include tools/raddr2line.mak
+include tools/rsym/raddr2line.mak
include tools/rbuild/rbuild.mak
include tools/rsym/rsym.mak