Пример #1
0
extern void WPInit( void )
/************************/
{
    char        *rover;
    bint        do_report;
    char        buff[256];

#ifdef TRMEM
    TRMemOpen();
    TRMemRedirect( STDOUT_FILENO );
#endif
    SamplePath[0] = 0;
    InitPaths();
    rover = getenv( "WPROF" );
    if( rover != NULL ) {
        procCmd( rover );
    }
    getcmd( buff );
    do_report = procCmd( buff );
    WndInit( "Open Watcom Profiler" );
    WPWndInitDone = P_TRUE;
    InitMADInfo();
    WPDipInit();
    if( do_report ) {
        if( GetSampleInfo() ) {
            ReportSampleInfo();
        }
        exit( 0 );
    }
}
Пример #2
0
int main( int argc, const char * argv[] )
/*********************************/
{
    int     contok;
    int     retcode;

    TRMemOpen();

    contok = ScanParams( argc, argv );

    if (CmdLineParms.PrintHelp) {
        PrintUsageMessage( argv[0] );
    }

    if (contok) {
        retcode = DumpFile();
    } else {
        retcode = 1;
    }

    FreeParams();

    switch (retcode) {
    case 1:         /* reading parameters */
        break;
    case 2:         /* reading input file */
        puts( "Error reading input file" );
        break;
    }

    TRMemClose();

    return( retcode );
}
Пример #3
0
static void MemTrackInit( void )
{
    char        name[FILENAME_MAX];

    TrackFile = STDERR_FILENO;
    if( DUIEnvLkup( "TRMEMFILE", name, sizeof( name ) ) ) {
        TrackFile = open( name, O_CREAT+O_RDWR+O_TEXT+O_TRUNC );
    }
    TRMemOpen();
}
Пример #4
0
void main( void ) {
//*****************

    int         ctr;
    char        in_str[80];
    asmreloc    *reloc, *next;

    TRMemOpen();

    AsmInit();
    curLine = 0;
    AsmCodeBuffer = (unsigned char*)buffer;
    AsmCodeAddress = 0;
    printf( "AsmCodeAddress = %u.\n", (unsigned)AsmCodeAddress );
    gets( in_str );
    while( strcmp( in_str, "q" ) != 0 ) {
        curLine++;
        AsmLine( in_str );
        printf( "AsmCodeAddress = %u.\n", (unsigned)AsmCodeAddress );
        // AsmCodeAddress is now updated, and code is filled from
        // AsmCodeBuffer[0] to AsmCodeBuffer[AsmCodeAddress/ins_size-1]
        // inclusive.
        gets( in_str );
    }

    printf( "Generated [before internal fixup]:\n" );
    for( ctr = 0; ctr < AsmCodeAddress / sizeof( buffer[0] ); ctr++ ) {
        printf( " [%#010x]\n", buffer[ctr] );
    }
    AsmFini();
    printf( "Generated [after internal fixup]:\n" );
    for( ctr = 0; ctr < AsmCodeAddress / sizeof( buffer[0] ); ctr++ ) {
        printf( " [%#010x]\n", buffer[ctr] );
    }

    for( reloc = AsmRelocs; reloc; reloc = next ) {
        next = reloc->next;
        printf( "Reloc:\tname = %s\n"
                "\toffset = %#010x\n"
                "\ttype = %s\n",
                reloc->name, reloc->offset, typeName[reloc->type] );
        AsmFree( reloc->name );
        AsmFree( reloc );
    }

#ifdef TRMEM
    TRMemPrtList();
#endif
    TRMemClose();
}
Пример #5
0
void main( int argc, char *argv[] )
{
    HelpFp              fp;
    HelpHdl             hdl;
    char                name[_MAX_PATH];
    char                *cur;
    HelpSrchInfo        cursor;
    unsigned            i;

    if( argc != 2 ) {
        printf( "USAGE:\n" );
        printf( "exename <help file>\n" );
        return;
    }
    fp = HelpOpen( argv[1], HELP_OPEN_RDONLY | HELP_OPEN_BINARY );
    if( fp == -1 ) {
        printf( "Unable to open %s\n", argv[1] );
        return;
    }
    TRMemOpen();
    hdl = InitHelpSearch( fp );
    for( ;; ) {
        gets( name );
        if( !strcmp( name, "bob" ) ) break;
        cur = HelpFindFirst( hdl, name, &cursor );
        for( i=0; i < 5; i++ ) {
            if( cur == NULL ) break;
            printf( "     %s\n", cur );
            HelpMemFree( cur );
            cur = HelpFindNext( &cursor );
        }
        if( cur != NULL ) {
            HelpMemFree( cur );
        }
    }
    FiniHelpSearch( hdl );
    HelpClose( fp );
    TRMemClose();
}
Пример #6
0
int main( int argc, const char * argv[] )
/***************************************/
{
    int     error;          /* 1 if an error has occured, 0 otherwise */
    bool    contok;         /* true if OK to continue after scanning arg */

    TRMemOpen();

    contok = ScanParams( argc, argv );
    if( CmdLineParms.PrintHelp ) {
        PrintUsageMesage( argv[0] );
    }

    if( contok ) {
        error = ConvertFiles();
    } else {
        error = 1;
    }

    TRMemClose();

    return( error );
}
Пример #7
0
int main( int argc, char *argv[] )
/********************************/
{
    orl_handle                  o_hnd;
    orl_file_handle             o_fhnd;
    orl_funcs                   funcs;
    int                         file;
    orl_file_flags              file_flags;
    orl_machine_type            machine_type;
    orl_file_type               file_type;
    orl_file_format             type;
    int                         c;
    int                         sep;
    char                        *secs[MAX_SECS];
    int                         num_secs = 0;

    if( argc < 2 ) {
        printf( "Usage:  objread [-ahrsSx] [-o<section>] <objfile>\n" );
        printf( "Where <objfile> is a COFF, ELF or OMF object file\n" );
        printf( "objread reads and dumps an object using ORL\n" );
        printf( "Options: -a     dumps all information (except hex dump)\n" );
        printf( "         -h     dumps file header information\n" );
        printf( "         -r     dumps relocation information\n" );
        printf( "         -s     dumps symbol table\n" );
        printf( "         -S     dumps section information\n" );
        printf( "         -x     get hex dump of section content\n" );
        printf( "         -o     only scan <section> for info\n" );
        return( 1 );
    }
    while( (c = getopt( argc, argv, "axhrsSo:" )) != EOF ) {
        switch( c ) {
            case 'a':
                dump.relocs++;
                dump.header++;
                dump.symbols++;
                dump.sections++;
                break;
            case 'x':
                dump.sec_contents++;
                break;
            case 'h':
                dump.header++;
                break;
            case 'r':
                dump.relocs++;
                break;
            case 's':
                dump.symbols++;
                break;
            case 'S':
                dump.sections++;
                break;
            case 'o':
                secs[num_secs++] = optarg;
                break;
            default:
                // error occured
                exit(1);
        };
    };
    if( optind != argc - 1 ) {
        fprintf( stderr, "must specify 1 filename\n" );
        exit(1);
    }

    file = open( argv[optind], O_BINARY | O_RDONLY );
    if( file == -1 ) {
        printf( "Error opening file.\n" );
        return( 2 );
    }
    TRMemOpen();
    funcs.read = &objRead;
    funcs.seek = &objSeek;
    funcs.alloc = &TRMemAlloc;
    funcs.free = &TRMemFree;
    o_hnd = ORLInit( &funcs );
    if( o_hnd == NULL ) {
        printf( "Got NULL orl_handle.\n" );
        return( 2 );
    }
    type = ORLFileIdentify( o_hnd, (void *)file );
    if( type == ORL_UNRECOGNIZED_FORMAT ) {
        printf( "The object file is not in either ELF, COFF or OMF format." );
        return( 1 );
    }
    switch( type ) {
    case ORL_ELF:
        printf( "ELF" );
        break;
    case ORL_COFF:
        printf( "COFF" );
        break;
    case ORL_OMF:
        printf( "OMF" );
        break;
    default:
        printf( "Unknown" );
        break;
    }
    printf( " object file.\n" );
    o_fhnd = ORLFileInit( o_hnd, (void *)file, type );
    if( o_fhnd == NULL ) {
        printf( "Got NULL orl_file_handle.\n" );
        return( 2 );
    }
    if( dump.header ) {
        printf( "File %s:\n", argv[optind] );
        machine_type = ORLFileGetMachineType( o_fhnd );
        printf( "Machine Type: " );
        if( machine_type >= ( sizeof( machType ) / sizeof( *machType ) ) ) {
            // We've probably added some new types?
            printf( "?(%d)", machine_type );
        } else {
            printf( "%s", machType[ machine_type ] );
        }
        file_type = ORLFileGetType( o_fhnd );
        printf( " (" );
        switch( file_type ) {
            case ORL_FILE_TYPE_NONE:
                printf( "file_type_none" );
                break;
            case ORL_FILE_TYPE_OBJECT:
                printf( "object file" );
                break;
            case ORL_FILE_TYPE_EXECUTABLE:
                printf( "executable" );
                break;
            case ORL_FILE_TYPE_SHARED_OBJECT:
                printf( "shared object" );
                break;
            case ORL_FILE_TYPE_DLL:
                printf( "DLL" );
                break;
            default:
                printf( "unknown file type?" );
                break;
        }
        printf( ")\n" );
        file_flags = ORLFileGetFlags( o_fhnd );
        //printf(" File flags=0x%x\n", file_flags );
        sep = 0;
        if( file_flags & ORL_FILE_FLAG_LINE_NUMS_STRIPPED ) {
            printf( "line number info stripped" );
            sep = 1;
        }
        if( file_flags & ORL_FILE_FLAG_RELOCS_STRIPPED ) {
            if( sep++ ) printf( ", " );
            printf( "relocs stripped" );
        }
        if( file_flags & ORL_FILE_FLAG_LOCAL_SYMS_STRIPPED ) {
            if( sep++ ) printf( ", " );
            printf( "local symbols stripped" );
        }
        if( file_flags & ORL_FILE_FLAG_DEBUG_STRIPPED ) {
            if( sep++ ) printf( ", " );
            printf( "debug info stripped" );
        }
        if( file_flags & ORL_FILE_FLAG_16BIT_MACHINE ) {
            if( sep++ ) printf( ", " );
            printf( "for 16-bit machine" );
        }
        if( file_flags & ORL_FILE_FLAG_32BIT_MACHINE ) {
            if( sep++ ) printf( ", " );
            printf( "for 32-bit machine" );
        }
        if( file_flags & ORL_FILE_FLAG_64BIT_MACHINE ) {
            if( sep++ ) printf( ", " );
            printf( "for 64-bit machine" );
        }
        if( file_flags & ORL_FILE_FLAG_LITTLE_ENDIAN ) {
            if( sep++ ) printf( ", " );
            printf( "little-endian byte order" );
        }
        if( file_flags & ORL_FILE_FLAG_BIG_ENDIAN ) {
            if( sep++ ) printf( ", " );
            printf( "big-endian byte order" );
        }
        if( file_flags & ORL_FILE_FLAG_SYSTEM ) {
            if( sep++ ) printf( ", " );
            printf( "system file" );
        }
        if( sep ) printf( "\n" );
    }
    if( num_secs ) {
        for( c = 0; c < num_secs; c++ ) {
            sectionFound = 0;
            if( ORLFileScan( o_fhnd, secs[c], &PrintSecInfo ) != ORL_OKAY ) {
                printf( "Error occured in scanning section '%s'.\n", secs[c] );
            }
            if( !sectionFound ) {
                printf( "Section '%s' not found in object.\n", secs[c] );
            }
        }
    } else {
        if( ORLFileScan( o_fhnd, NULL, &PrintSecInfo ) != ORL_OKAY ) {
            printf( "Error occured in scanning file.\n" );
            return( 2 );
        }
    }
    if( ORLFileScan( o_fhnd, ".symtab", &PrintSymTable ) != ORL_OKAY ) {
        printf( "Error occured in scanning file for symbol table\n" );
        return( 2 );
    }
    if( ORLFileFini( o_fhnd ) != ORL_OKAY ) {
        printf( "Error calling ORLFileFini.\n" );
        return( 2 );
    }
    if( close( file ) == -1 ) {
        printf( "Error closing file.\n" );
        return( 2 );
    }
    if( ORLFini( o_hnd ) != ORL_OKAY ) {
        printf( "Error calling ORLFini.\n" );
    }
    freeBuffList();
#ifdef TRMEM
    TRMemPrtList();
#endif
    TRMemClose();
    return( 0 );
}
Пример #8
0
int main( int argc, char *argv[] )
/********************************/
{
    orl_handle                  o_hnd;
    orl_file_handle             o_fhnd;
    orl_file_format             type;
    orl_file_flags              o_flags;
    FILE                        *fp;
    int                         c;
    char                        *secs[MAX_SECS];
    int                         num_secs = 0;
    ORLSetFuncs( orl_cli_funcs, objRead, objSeek, TRMemAlloc, TRMemFree );

    if( argc < 2 ) {
        printf( "Usage:  dwdump <file>\n" );
        printf( "Where <file> is a COFF, ELF or OMF object file\n" );
        printf( "dwdump reads and dumps DWARF debugging information\n" );
        return( EXIT_SUCCESS );
    }

    dump.sections++;

    fp = fopen( argv[1], "rb" );
    if( fp == NULL ) {
        printf( "Error opening file.\n" );
        return( EXIT_FAILURE );
    }
    TRMemOpen();
    o_hnd = ORLInit( &orl_cli_funcs );
    if( o_hnd == NULL ) {
        printf( "Got NULL orl_handle.\n" );
        return( EXIT_FAILURE );
    }
    type = ORLFileIdentify( o_hnd, fp );
    if( type == ORL_UNRECOGNIZED_FORMAT ) {
        printf( "The object file is not in either ELF, COFF or OMF format." );
        return( EXIT_FAILURE );
    }
    switch( type ) {
    case ORL_OMF:
        printf( "OMF" );
        break;
    case ORL_ELF:
        printf( "ELF" );
        break;
    case ORL_COFF:
        printf( "COFF" );
        break;
    default:
        printf( "Unknown" );
        break;
    }
    printf( " object file.\n" );
    o_fhnd = ORLFileInit( o_hnd, fp, type );
    if( o_fhnd == NULL ) {
        printf( "Got NULL orl_file_handle.\n" );
        return( EXIT_FAILURE );
    }

    o_flags = ORLFileGetFlags( o_fhnd );

#ifdef __BIG_ENDIAN__
    if( o_flags & ORL_FILE_FLAG_LITTLE_ENDIAN ) {
        byte_swap = true;
    }
#else
    if( o_flags & ORL_FILE_FLAG_BIG_ENDIAN ) {
        byte_swap = true;
    }
#endif

    if( num_secs ) {
        for( c = 0; c < num_secs; c++ ) {
            sectionFound = 0;
            if( ORLFileScan( o_fhnd, secs[c], &DoSection ) != ORL_OKAY ) {
                printf( "Error occured in scanning section '%s'.\n", secs[c] );
            }
            if( !sectionFound ) {
                printf( "Section '%s' not found in object.\n", secs[c] );
            }
        }
    } else {
        if( ORLFileScan( o_fhnd, NULL, &DoSection ) != ORL_OKAY ) {
            printf( "Error occured in scanning file.\n" );
            return( EXIT_FAILURE );
        }
    }

    setSects( o_fhnd );

    if( ORLFileFini( o_fhnd ) != ORL_OKAY ) {
        printf( "Error calling ORLFileFini.\n" );
        return( EXIT_FAILURE );
    }
    if( fclose( fp ) ) {
        printf( "Error closing file.\n" );
        return( EXIT_FAILURE );
    }
    if( ORLFini( o_hnd ) != ORL_OKAY ) {
        printf( "Error calling ORLFini.\n" );
    }

    DumpSections();

    freeBuffList();
#ifdef TRMEM
    TRMemPrtList();
#endif
    TRMemClose();
    return( EXIT_SUCCESS );
}