void ExprSymbol( stack_entry *entry, sym_handle *sh ) { SET_TH( entry ); if( SymType( sh, entry->th ) != DS_OK ) entry->th = NULL; ClassifyEntry( entry, &entry->info ); SET_SH( entry ); HDLAssign( sym, entry->v.sh, sh ); entry->flags |= SF_SYM; }
/** * WalkSymList callback, the module pass. * * @returns WR_CONTINUE; * @param info Symbol walk info. * @param sym The Symbol. * @param _idx Pointer to the symbol index number. */ static walk_result Sym2Callback( sym_walk_info info, sym_handle *sym, void *_idx ) { int *idx = (int *)_idx; char buff[2048]; unsigned len; dip_status rc; location_list ll = {0}; sym_info sinfo; int i; /* index */ printf( "%5d ", ++*idx ); /* symbol info */ rc = SymInfo( sym, NULL, &sinfo ); if( rc == DS_OK ) { switch( sinfo.kind ) { case SK_NONE: printf( "NONE " ); break; case SK_CODE: printf( "CODE " ); break; case SK_DATA: printf( "DATA " ); break; case SK_CONST: printf( "CNST " ); break; case SK_TYPE: printf( "TYPE " ); break; case SK_PROCEDURE: printf( "PROC " ); break; case SK_NAMESPACE: printf( "NSPC " ); break; default: printf( "kind=%#x! ", sinfo.kind ); break; } } else { printf( "rc=%#x ", rc ); memset( &sinfo, 0, sizeof( sinfo ) ); sinfo.kind= SK_NONE; } /* location (i.e. address) */ ll.num = MAX_LOC_ENTRIES; rc = SymLocation( sym, NULL, &ll ); if( rc == DS_OK ) { if( ll.num > 0 ) { if( ll.e[0].type == LT_ADDR ) { printf( "%04x:%08lx ", ll.e[0].u.addr.mach.segment, (long)ll.e[0].u.addr.mach.offset ); } else { printf( "%p ", ll.e[0].u.p ); /// what's this? } } else { printf( " "); } } else if( sinfo.kind == SK_CONST ) { ll.num = 0; memset( buff, 0, sizeof( buff ) ); rc = SymValue( sym, NULL, &buff[0] ); if( rc == DS_OK ) { switch( sinfo.ret_modifier ) { } printf( " " ); } else { printf( "SymValue rc=%#x ", rc ); } } else if( sinfo.kind == SK_NONE || sinfo.kind == SK_TYPE || sinfo.kind == SK_NAMESPACE ) { printf( " " ); ll.num = 0; } else { printf( "rc=%#x ", rc ); ll.num = 0; } /* info */ switch( info ) { case SWI_SYMBOL: printf( "SYMBOL " ); break; case SWI_INHERIT_START: printf( "INH-STRT " ); break; case SWI_INHERIT_END: printf( "INH-END " ); break; default: printf( "%#d ", info ); break; } /* finally, the name. */ /* try get the name */ buff[0] = '\0'; len = SymName( sym, NULL, SN_DEMANGLED, buff, sizeof( buff ) ); if( len == 0 ) { len = SymName( sym, NULL, SN_OBJECT, buff, sizeof( buff ) ); } if( len == 0 ) { len = SymName( sym, NULL, SN_SOURCE, buff, sizeof( buff ) ); } if( len > 0 ) { printf( "%s\n", buff ); } else { printf( "(len=%u)\n", len ); } /* Get more stuff, mainly to test the APIs. */ if( 1 ) { type_handle *type = alloca( DIPHandleSize( HK_TYPE, false ) ); rc = SymType( sym, type ); if( rc ) { } #if 0 mod_handle SymMod( sym_handle * ); unsigned SymName( sym_handle *, location_context *, symbol_name, char *buff, unsigned buff_size ); dip_status SymType( sym_handle *, type_handle * ); dip_status SymValue( sym_handle *, location_context *, void * ); dip_status SymInfo( sym_handle *, location_context *, sym_info * ); dip_status SymParmLocation( sym_handle *, location_context *, location_list *, unsigned p ); dip_status SymObjType( sym_handle *, type_handle *, dip_type_info * ); dip_status SymObjLocation( sym_handle *, location_context *, location_list * ); search_result AddrSym( mod_handle, address, sym_handle * ); search_result LookupSym( symbol_source, void *, lookup_item *, void * ); search_result LookupSymEx( symbol_source, void *, lookup_item *, location_context *, void * ); search_result AddrScope( mod_handle, address, scope_block * ); search_result ScopeOuter( mod_handle, scope_block *, scope_block * ); int SymCmp( sym_handle *, sym_handle * ); dip_status SymAddRef( sym_handle * ); dip_status SymRelease( sym_handle * ); dip_status SymFreeAll(); #endif } /* more locations. */ for( i = 1; i < ll.num; i++ ) { if( ll.e[0].type == LT_ADDR ) { printf( " %04x:%08lx\n", ll.e[i].u.addr.mach.segment, (long)ll.e[i].u.addr.mach.offset ); } else { printf( " %p\n", ll.e[i].u.p); /// what's this? } } /* * Perform alternative lookups to the those interfaces. */ return( WR_CONTINUE ); }