typewv.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 627 行 · 第 1/2 页
C
627 行
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Watcom debug format type processing.
*
****************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <setjmp.h>
#include "wdglb.h"
#include "dumpwv.h"
#include "wdfunc.h"
/*
* scalar_type - dump type of scalar item
*/
static void scalar_type( unsigned_8 type )
/****************************************/
{
Puthex( type, 2 );
switch( type >> 4 ) {
case 0:
Wdputslc( ", integer" );
break;
case 1:
Wdputslc( ", unsigned" );
break;
case 2:
Wdputslc( ", float" );
break;
case 3:
Wdputslc( ", void" );
break;
case 4:
Wdputslc( ", complex" );
break;
}
} /* scalar_type */
/*
* attribute_byte - dump type of scalar item
*/
static void attribute_byte( unsigned_8 type )
/*******************************************/
{
Puthex( type, 2 );
if( type & 0x1 ) {
Wdputslc( ", internal" );
}
if( type & 0x2 ) {
Wdputslc( ", public" );
}
if( type & 0x4 ) {
Wdputslc( ", protected" );
}
if( type & 0x8 ) {
Wdputslc( ", private" );
}
} /* attribute_byte */
/*
* base_type_index - dump info
*/
static char *base_type_index( char *buff )
/****************************************/
{
unsigned_16 index;
char *ptr;
Wdputs( " base type idx = " );
ptr = Get_type_index( buff, &index );
Putdec( index );
Wdputslc( "\n" );
return( ptr );
}
/*
* near_ptr - dump info
*/
static void near_ptr( char *buff )
/********************************/
{
unsigned_16 index;
char *ptr;
index = 3;
ptr = buff+2;
if( *ptr & 0x80 ) {
index = 4;
}
ptr = base_type_index( ptr );
if( buff[0] > index ) {
Wdputs( " base locator = " );
Dump_location_expression( ptr, " " );
}
}
/*
* param_type_index - dump info
*/
static void param_type_index( unsigned_8 num_params, char * ptr )
/***************************************************************/
{
unsigned_8 i;
unsigned_16 index;
if( *ptr & 0x80 ) {
num_params /= 2;
}
for( i = 0; i < num_params; i++ ) {
Wdputslc( "\n" );
Wdputs( " param " );
Putdec( i+1 );
Wdputs( ": type idx = " );
ptr = Get_type_index( ptr, &index );
Putdec( index );
}
Wdputslc( "\n" );
}
/*
* near_far_proc - dump info
*/
static void near_far_proc( char *buff )
/*************************************/
{
char *ptr;
unsigned_16 index;
unsigned_8 num_parms;
ptr = buff+2;
Wdputs( " return type = " );
num_parms = buff[0] - 4;
if( *ptr & 0x80 ) {
num_parms--;
}
ptr = Get_type_index( ptr, &index );
Putdec( index );
ptr++;
param_type_index( num_parms, ptr );
}
/*
* array_index - dump info
*/
static void array_index( char *ptr, unsigned_8 size )
/***************************************************/
{
Wdputs( " high bound = " );
Puthex( *ptr, 2*size );
base_type_index( ptr+size );
}
/*
* bit_field_struct - dump info
*/
static void bit_field_struct( char *buff, unsigned_8 size, bool bit )
/*******************************************************************/
{
char *ptr;
unsigned_16 index;
char name[256];
ptr = buff+2+size;
if( bit ) {
ptr += 2;
}
ptr = Get_type_index( ptr, &index );
Get_local_name( name, ptr, buff );
Wdputs( " \"" );
Wdputs( name );
Wdputs( "\" offset = " );
ptr = buff+2;
Puthex( *ptr, 2*size );
Wdputs( " type idx = " );
Putdec( index );
if( bit ) {
Wdputslc( "\n start bit = " );
ptr++;
Puthex( *ptr, 2 );
Wdputslc( " bit size = " );
ptr++;
Puthex( *ptr, 2 );
}
Wdputslc( "\n" );
}
/*
* bit_field_class - dump info
*/
static void bit_field_class( char *buff, bool bit )
/*************************************************/
{
char *ptr;
unsigned_16 index;
char name[256];
ptr = buff+3;
Wdputs( " field locator = " );
ptr = Dump_location_expression( ptr, " " );
if( bit ) {
ptr += 2;
}
ptr = Get_type_index( ptr, &index );
Get_local_name( name, ptr, buff );
Wdputs( " name = \"" );
Wdputs( name );
Wdputs( "\" type idx = " );
Putdec( index );
Wdputslc( "\n attribute = " );
attribute_byte( buff[2] );
if( bit ) {
Wdputslc( " start bit = " );
ptr++;
Puthex( *ptr, 2 );
Wdputslc( " bit size = " );
ptr++;
Puthex( *ptr, 2 );
}
Wdputslc( "\n" );
}
/*
* range - dump info
*/
static void range( char *ptr, unsigned_8 size )
/*********************************************/
{
Wdputs( " low bound = " );
Puthex( *ptr, 2*size );
Wdputs( " high bound = " );
ptr += size;
Puthex( *ptr, 2*size );
ptr += size;
base_type_index( ptr );
}
/*
* enum_const - dump info
*/
static void enum_const( char *buff, unsigned_8 size )
/***************************************************/
{
char name[256];
Get_local_name( name, buff+2+size, buff );
Wdputs( " \"" );
Wdputs( name );
Wdputs( "\" value = " );
Puthex( *(buff+2), 2*size );
Wdputslc( "\n" );
}
/*
* desc_array - dump info
*/
static void desc_array( char *ptr, bool is386 )
/*********************************************/
{
addr32_ptr *p32;
addr48_ptr *p48;
Wdputs( " scalar type 1 = " );
scalar_type( ptr[0] );
Wdputs( " scalar type 2 = " );
scalar_type( ptr[1] );
ptr += 2;
Wdputslc( "\n addr = " );
if( is386 ) {
p48 = (addr48_ptr *)ptr;
ptr += sizeof(addr48_ptr);
Puthex( p48->segment, 4 );
Wdputc( ':' );
Puthex( p48->offset, 8 );
} else {
p32 = (addr32_ptr *)ptr;
ptr += sizeof(addr32_ptr);
Puthex( p32->segment, 4 );
Wdputc( ':' );
Puthex( p32->offset, 4 );
}
base_type_index( ptr );
} /* desc_array */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?