static void log_macro( const struct asym *sym ) /*********************************************/ { int i = sym->name_size; const char *pdots; const char *type = (sym->isfunc) ? strings[LS_FUNC] : strings[LS_PROC]; pdots = ((i >= DOTSMAX) ? "" : dots + i + 1 ); LstPrintf( "%s %s %s", sym->name, pdots ,type ); #ifdef DEBUG_OUT LstPrintf( " %5lu", ((struct dsym *)sym)->e.macroinfo->count ); #endif LstNL(); return; }
static void log_struct( const struct asym *sym, const char *name, int_32 ofs ) /****************************************************************************/ { unsigned i; struct dsym *dir; const char *pdots; struct struct_info *si; struct sfield *f; static int prefix = 0; dir = (struct dsym *)sym; /* filter typedefs and records */ //if ( dir->sym.typekind != TYPE_STRUCT && // dir->sym.typekind != TYPE_UNION ) // return; si = dir->e.structinfo; if ( !name ) name = sym->name; i = strlen ( name ); pdots = (( (i+prefix) >= DOTSMAX) ? "" : dots + i + prefix + 1 ); for ( i = 0; i < prefix; i++ ) LstPrintf(" "); if ( prefix == 0 ) if ( dir->e.structinfo->alignment > 1) LstPrintf( "%s %s %8" I32_SPEC "X (%u)", name, pdots, sym->total_size, si->alignment ); else LstPrintf( "%s %s %8" I32_SPEC "X", name, pdots, sym->total_size ); else LstPrintf( "%s %s %8" I32_SPEC "X", name, pdots, sym->offset + ofs); LstNL(); prefix += 2; for( f = si->head; f; f = f->next ) { /* recursion if an embedded struct occurs */ /* v2.09: field init_dir removed */ //if ( f->sym->mem_type == MT_TYPE && f->init_dir == NULL ) { if ( f->sym.mem_type == MT_TYPE && f->ivalue[0] == NULLC ) { log_struct( f->sym.type, f->sym.name, f->sym.offset + ofs ); } else { /* don't list unstructured fields without name */ /* but do list them if they are structured */ if (*(f->sym.name) || (f->sym.mem_type == MT_TYPE)) { i = f->sym.name_size + prefix; pdots = ((i >= DOTSMAX) ? "" : dots + i + 1 ); for ( i = 0; i < prefix; i++ ) LstPrintf(" "); LstPrintf( "%s %s %8" I32_SPEC "X ", f->sym.name, pdots, f->sym.offset + sym->offset + ofs); LstPrintf( "%s", GetMemtypeString( &f->sym, NULL ) ); if ( f->sym.isarray ) LstPrintf( "[%u]",f->sym.total_length ); LstNL(); } } } prefix -= 2; }
static void log_typedef( const struct asym *sym ) /***********************************************/ { //struct dsym *dir = (struct dsym *)sym; //struct struct_info *si = dir->e.structinfo; char *p; int i = sym->name_size; const char *pdots; //char buffer[256]; pdots = (( i >= DOTSMAX ) ? "" : dots + i + 1 ); p = StringBufferEnd; *p = NULLC; if ( sym->mem_type == MT_PROC && sym->target_type ) { /* typedef proto? */ strcat( p, strings[LS_PROC] ); strcat( p, " " ); if ( *sym->target_type->name ) { /* the name may be "" */ strcat( p, sym->target_type->name ); strcat( p," "); } /* v2.11: target_type has state SYM_TYPE (since v2.09). * This state isn't handled properly by GetSymOfsSize(), which is called by GetMemtypeString(), * so get the strings here. */ //strcat( p, GetMemtypeString( sym->target_type, NULL ) ); strcat( p, strings[( sym->target_type->mem_type == MT_NEAR ? LS_LNEAR16 : LS_LFAR16 ) + sym->Ofssize ] ); strcat( p," " ); strcat( p, GetLanguage( sym->target_type ) ); } else p = (char *)GetMemtypeString( sym, p ); LstPrintf( "%s %s %8" I32_SPEC "u %s", sym->name, pdots, sym->total_size, p ); LstNL(); }
static void log_segment( const struct asym *sym, const struct asym *group ) /*************************************************************************/ { char buffer[32]; struct seg_info *seg = ((struct dsym *)sym)->e.seginfo; if( seg->group == group ) { int i = sym->name_size; const char *pdots; pdots = (( i >= DOTSMAX ) ? "" : dots + i + 1); LstPrintf( "%s %s ", sym->name, pdots ); if( seg->Ofssize == USE32 ) { //LstPrintf( "32 Bit %08" I32_SPEC "X ", seg->current_loc ); LstPrintf( "32 Bit %08" I32_SPEC "X ", sym->max_offset ); #if AMD64_SUPPORT } else if( seg->Ofssize == USE64 ) { LstPrintf( "64 Bit %08" I32_SPEC "X ", sym->max_offset ); #endif } else { //LstPrintf( "16 Bit %04" I32_SPEC "X ", seg->current_loc ); LstPrintf( "16 Bit %04" I32_SPEC "X ", sym->max_offset ); } LstPrintf( "%-7s %-8s", get_seg_align( seg, buffer ), get_seg_combine( seg ) ); LstPrintf( "'%s'", seg->clsym ? seg->clsym->name : "" ); #if 0 if ( group != NULL ) LstPrintf( " %s", group->name ); #endif LstNL(); } }
static void LstCaption( const char *caption, int prefNL ) /*******************************************************/ { for (; prefNL; prefNL--) LstNL(); LstPrintf( caption ); LstNL(); LstNL(); }
static void log_record( const struct asym *sym ) /**********************************************/ { #if AMD64_SUPPORT uint_64 mask; #else uint_32 mask; #endif struct dsym *dir = (struct dsym *)sym; struct struct_info *si = dir->e.structinfo; struct sfield *f; int i = sym->name_size; const char *pdots; pdots = ((i >= DOTSMAX) ? "" : dots + i + 1 ); for( i = 0,f = si->head; f; f = f->next,i++ ); LstPrintf( "%s %s %6" I32_SPEC "X %7X", sym->name, pdots, sym->total_size*8, i ); LstNL(); for( f = si->head; f; f = f->next ) { i = f->sym.name_size + 2; pdots = ((i >= DOTSMAX) ? "" : dots + i + 1 ); for ( i = f->sym.offset, mask = 0; i < f->sym.offset + f->sym.total_size; i++ ) #if AMD64_SUPPORT #if defined(LLONG_MAX) || defined(__GNUC__) || defined(__TINYC__) mask |= 1ULL << i; #else mask |= 1i64 << i; #endif if ( sym->total_size > 4 ) LstPrintf( " %s %s %6" I32_SPEC "X %7" I32_SPEC "X %016" I64_SPEC "X %s", f->sym.name, pdots, f->sym.offset, f->sym.total_size, mask, f->ivalue[0] ? f->ivalue : "?" ); else LstPrintf( " %s %s %6" I32_SPEC "X %7" I32_SPEC "X %08" I32_SPEC "X %s", f->sym.name, pdots, f->sym.offset, f->sym.total_size, (uint_32)mask, f->ivalue[0] ? f->ivalue : "?" ); #else mask |= 1 << i; LstPrintf( " %s %s %6" I32_SPEC "X %7" I32_SPEC "X %08" I32_SPEC "X %s", f->sym.name, pdots, f->sym.offset, f->sym.total_size, mask, f->ivalue[0] ? f->ivalue : "?" ); #endif LstNL(); } }
void PutMsg( FILE *fp, int severity, int msgnum, va_list args ) /********************************************************************/ { int i,j; char *type; char msgbuf[MAXMSGSIZE]; char buffer[MAX_LINE_LEN]; if( fp != NULL ) { MsgGet( msgnum, msgbuf ); switch (severity ) { case 1: type = MsgGetEx( MSG_FATAL_PREFIX ); break; case 2: type = MsgGetEx( MSG_ERROR_PREFIX ); break; case 4: type = MsgGetEx( MSG_WARNING_PREFIX ); break; default: type = NULL; i = 0; break; } if ( type ) i = sprintf( buffer, "%s A%4u: ", type, severity * 1000 + msgnum ); i += vsprintf( buffer+i, msgbuf, args ); //buffer[i] = NULLC; if ( severity && (j = GetCurrSrcPos( msgbuf ))) { fwrite( msgbuf, 1, j, fp ); } else j = 0; fwrite( buffer, 1, i, fp ); fwrite( "\n", 1, 1, fp ); /* if in Pass 1, add the error msg to the listing */ if ( FileInfo.file[LST] && severity && Parse_Pass == PASS_1 && fp == FileInfo.file[ERR] ) { LstWrite( LSTTYPE_DIRECTIVE, GetCurrOffset(), 0 ); LstPrintf( " %s", buffer ); LstNL(); } } }
static void log_group( const struct asym *grp, const struct dsym *segs ) /**********************************************************************/ { unsigned i; const char *pdots; struct seg_item *curr; i = grp->name_size; pdots = (( i >= DOTSMAX ) ? "" : dots + i + 1); LstPrintf( "%s %s %s", grp->name, pdots, strings[LS_GROUP] ); LstNL(); /* the FLAT groups is always empty */ if ( grp == (struct asym *)ModuleInfo.flat_grp ) { for( ; segs; segs = segs->next ) { log_segment( (struct asym *)segs, grp ); } } else for( curr = ((struct dsym *)grp)->e.grpinfo->seglist; curr; curr = curr->next ) { log_segment( (struct asym *)curr->seg, grp ); } }
static void log_symbol( const struct asym *sym ) /**********************************************/ { int i = sym->name_size; const char *pdots; //char buffer[MAX_LINE_LEN]; pdots = ((i >= DOTSMAX) ? "" : dots + i + 1 ); switch ( sym->state ) { case SYM_UNDEFINED: case SYM_INTERNAL: case SYM_EXTERNAL: LstPrintf( "%s %s ", sym->name, pdots ); if ( sym->isarray ) { i = sprintf( StringBufferEnd, "%s[%u]", GetMemtypeString( sym, NULL ), sym->total_length ); LstPrintf( "%-10s ", StringBufferEnd ); } else if ( sym->state == SYM_EXTERNAL && sym->iscomm == TRUE ) { LstPrintf( "%-10s ", strings[LS_COMM] ); } else LstPrintf( "%-10s ", GetMemtypeString( sym, NULL ) ); /* print value */ /* v2.07: MT_ABS is obsolete */ //if ( sym->mem_type == MT_ABS ) if ( sym->state == SYM_EXTERNAL && sym->iscomm == TRUE ) LstPrintf( " %8" I32_SPEC "Xh ", sym->total_size / sym->total_length ); else if ( sym->mem_type == MT_EMPTY ) { /* also check segment? might be != NULL for equates (var = offset x) */ if ( sym->value3264 != 0 && sym->value3264 != -1 ) LstPrintf( " %" I64_SPEC "Xh ", sym->uvalue, sym->value3264 ); else if ( sym->value3264 < 0 ) LstPrintf( "-%08" I32_SPEC "Xh ", 0 - sym->uvalue ); else LstPrintf( " %8" I32_SPEC "Xh ", sym->offset ); } else LstPrintf( " %8" I32_SPEC "Xh ", sym->offset ); /* print segment */ //if ( sym->mem_type == MT_ABS || sym->state == SYM_UNDEFINED ) // ; //else if ( sym->segment ) LstPrintf( "%s ", get_sym_seg_name( sym ) ); #ifdef DEBUG_OUT if ( sym->fwdref ) LstPrintf( "(F) " ); #endif if ( sym->state == SYM_EXTERNAL && sym->iscomm == TRUE ) LstPrintf( "%s=%u ", szCount, sym->total_length ); if( sym->ispublic ) LstPrintf( "%s ", strings[LS_PUBLIC] ); if ( sym->state == SYM_EXTERNAL ) { LstPrintf( sym->weak ? "*%s " : "%s ", strings[LS_EXTERNAL] ); } else if ( sym->state == SYM_UNDEFINED ) { LstPrintf( "%s ", strings[LS_UNDEFINED] ); } LstPrintf( "%s", GetLanguage( sym ) ); LstNL(); break; case SYM_TMACRO: //GetLiteralValue( buffer, sym->string_ptr ); //strcpy( buffer, sym->string_ptr ); LstPrintf( "%s %s %s %s", sym->name, pdots, strings[LS_TEXT], sym->string_ptr ); LstNL(); break; case SYM_ALIAS: LstPrintf( "%s %s %s %s", sym->name, pdots, strings[LS_ALIAS], sym->substitute->name ); LstNL(); break; } }
static void log_proc( const struct asym *sym ) /********************************************/ { struct dsym *f; struct dsym *l; const char *p; struct dsym *dir = (struct dsym *)sym; int i = sym->name_size; char Ofssize = GetSymOfssize( sym ); const char *pdots; pdots = (( i >= DOTSMAX ) ? "" : dots + i + 1 ); if ( Ofssize ) p = "%s %s P %-6s %08" I32_SPEC "X %-8s "; else p = "%s %s P %-6s %04" I32_SPEC "X %-8s "; LstPrintf( p, sym->name, pdots, get_proc_type( sym ), sym->offset, get_sym_seg_name( sym )); /* externals (PROTO) don't have a size. Masm always prints 0000 or 00000000 */ LstPrintf( "%0*" I32_SPEC "X ", Ofssize > USE16 ? 8 : 4, sym->state == SYM_INTERNAL ? sym->total_size : 0 ); #ifdef DEBUG_OUT if ( sym->fwdref ) LstPrintf( "(F) " ); #endif if( sym->ispublic ) { LstPrintf( "%-9s", strings[LS_PUBLIC] ); } else if ( sym->state == SYM_INTERNAL ) { LstPrintf( "%-9s", strings[LS_PRIVATE] ); } else { LstPrintf( sym->weak ? "*%-8s " : "%-9s ", strings[LS_EXTERNAL] ); #if DLLIMPORT if ( sym->dll ) LstPrintf( "(%.8s) ", sym->dll->name ); #endif } LstPrintf( "%s", GetLanguage( sym ) ); LstNL(); /* for PROTOs, list optional altname */ if ( sym->state == SYM_EXTERNAL && sym->altname ) { struct asym *sym2 = sym->altname; LstPrintf( " "); LstPrintf( p, sym2->name, pdots+2, get_proc_type( sym2 ), sym2->offset, get_sym_seg_name( sym2 )); LstNL(); } /* for PROCs, list parameters and locals */ if ( sym->state == SYM_INTERNAL ) { /* print the procedure's parameters */ if ( sym->langtype == LANG_C || sym->langtype == LANG_SYSCALL || sym->langtype == LANG_STDCALL || sym->langtype == LANG_FASTCALL ) { int cnt; /* position f2 to last param */ for ( cnt = 0, f = dir->e.procinfo->paralist; f; f = f->nextparam ) cnt++; for ( ; cnt; cnt-- ) { int curr; for ( curr = 1,f = dir->e.procinfo->paralist; curr < cnt;f = f->nextparam, curr++ ); i = f->sym.name_size; pdots = (( i >= DOTSMAX-2 ) ? "" : dots + i + 1 + 2 ); /* FASTCALL: parameter may be a text macro (=register name) */ if ( f->sym.state == SYM_TMACRO ) LstPrintf( " %s %s %-17s %s", f->sym.name, pdots, GetMemtypeString( &f->sym, NULL ), f->sym.string_ptr ); else LstPrintf( szFmtProcStk, f->sym.name, pdots, f->sym.is_vararg ? strings[LS_VARARG] : GetMemtypeString( &f->sym, NULL ), #if STACKBASESUPP GetResWName( dir->e.procinfo->basereg, NULL ), #else GetResWName( basereg[Ofssize], NULL ), #endif '+', f->sym.offset ); LstNL(); } } else { for ( f = dir->e.procinfo->paralist; f; f = f->nextparam ) { i = f->sym.name_size; pdots = (( i >= DOTSMAX-2 ) ? "" : dots + i + 1 + 2 ); LstPrintf( szFmtProcStk, f->sym.name, pdots, GetMemtypeString( &f->sym, NULL ), #if STACKBASESUPP GetResWName( dir->e.procinfo->basereg, NULL ), #else GetResWName( basereg[Ofssize], NULL ), #endif '+', f->sym.offset ); LstNL(); } } /* print the procedure's locals */ for ( l = dir->e.procinfo->locallist; l; l = l->nextlocal ) { char buffer[32]; i = l->sym.name_size; pdots = (( i >= DOTSMAX-2 ) ? "" : dots + i + 1 + 2); if ( l->sym.isarray ) sprintf( buffer, "%s[%" I32_SPEC "u]", GetMemtypeString(&l->sym, NULL), l->sym.total_length ); else strcpy( buffer, GetMemtypeString( &l->sym, NULL ) ); LstPrintf( szFmtProcStk, l->sym.name, pdots, buffer, #if STACKBASESUPP GetResWName( dir->e.procinfo->basereg, NULL ), l->sym.offset >= 0 ? '+' : '-', l->sym.offset >= 0 ? l->sym.offset : - l->sym.offset ); #else GetResWName( basereg[Ofssize], NULL ), '-', - l->sym.offset ); #endif LstNL(); } for ( l = dir->e.procinfo->labellist; l ; l = l->e.nextll ) { struct dsym *l2; for ( l2 = l; l2; l2 = (struct dsym *)l2->sym.nextitem ) { /* filter params and locals! */ if ( l2->sym.state == SYM_STACK || l2->sym.state == SYM_TMACRO ) continue; i = l2->sym.name_size; pdots = (( i >= DOTSMAX-2 ) ? "" : dots + i + 1 + 2); if ( Ofssize ) p = " %s %s L %-6s %08" I32_SPEC "X %s"; else p = " %s %s L %-6s %04" I32_SPEC "X %s"; LstPrintf( p, l2->sym.name, pdots, get_proc_type( &l2->sym ), l2->sym.offset, get_sym_seg_name( &l2->sym )); #ifdef DEBUG_OUT if ( l2->sym.fwdref ) LstPrintf( " (F)" ); #endif LstNL(); } } } }