/* wb_cb : WAD browser callback. This function is called whenever a user presses an entry in the browser. */ void wb_cb(FL_OBJECT *a, long l) { int line; Int4 index; int RetVal; const char *ch; line = fl_get_browser(a); /* get line number in browser */ if ( line == 1 ) /* first line is the legend */ return; index = LinearMap[line]; /* check appropriate choice-box to see if we should handle this ourself, or spawn an external program */ switch ( pEntryTag[index] ) { case TAG_SFX : ch = fl_get_choice_text( snd_cho ); break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : ch = fl_get_choice_text( img_cho ); break; case TAG_HIRES: ch = fl_get_choice_text( img_cho ); if ( !strcmp( ch, INTERNALLY_STR ) ) Message("Entry type %s cannot be handled internally, " "spawning external... \n", TagString(pEntryTag[index]) ); /* fallthrough */ case TAG_MUS : ch = EXTERNALLY_STR; break; default : ch = NULL; break; } if ( !strcmp( ch, EXTERNALLY_STR ) ) { /* handle externally, but we must determine if we have an external program */ switch (pEntryTag[index]) { case TAG_MUS : RetVal = (Ext_MUS_Player[0] != '\0') ? 0 : 1; break; case TAG_SFX : RetVal = (Ext_WAV_Player[0] != '\0') ? 0 : 1; break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : case TAG_HIRES: RetVal = (Ext_PCX_Viewer[0] != '\0') ? 0 : 1; break; default : RetVal = 1; break; } if (RetVal) { Message("No external program defined for type %s\n", TagString(pEntryTag[index]) ); return; } SpawnExternal( index ); } else /* handle internally */ HandleInternal( index ); /* Dump (flush) all X-events before we return, so e.g. if a user keeps the "down"-key pressed, the effect will be as expected. */ XSync( fl_get_display(), True ); }
DBDAT* DbaseLookup( char* opath, TAG keytag ) { static char path[1000] ; DBDAT* dbdat = (DBDAT*) 0 ; FOLDER* folder = &DbaseRoot ; (void) strcpy( path, DataBasePath ) ; dbdat = folder->EntryFind( keytag ) ; for( TAG* list = DbasePathtoList( opath ) ; *list ; list++ ) { (void) strcat( path, "/" ) ; (void) strcat( path, TagString( *list ) ) ; FOLDER* son = (FOLDER*) TreeFind( folder->kids, kid_cmp, *list ) ; if( !son ) { IOerror( IO_WARN, "DbaseLookup", "no such directory %s\n", path ) ; return dbdat ; } if( !son->loaded ) DbaseLoadDir( path, son ) ; folder = son ; if( DBDAT* new_dbdat = folder->EntryFind( keytag ) ) dbdat = new_dbdat ; } return dbdat ; }
void DwarfVariableFinder::getInfo(const DWARFDie &die) { auto tagString = TagString(die.getTag()); if (tagString.empty()) { outs() << format("DW_TAG_Unknown_%x", die.getTag()); } auto formVal = die.find(dwarf::DW_AT_name); formVal->dump(outs()); }
void PrintFolder( FOLDER* folder ) { if( !folder->loaded ) { Indent() ; IOreport( "%s {}\t\t# unloaded\n", TagString( folder->tag ) ) ; return ; } Indent() ; IOreport( "%s\n", TagString( folder->tag ) ) ; indent++ ; Indent() ; IOreport( "{\n" ) ; // TreeSpan( ( (FOLDER*) folder )->entries, (void (*)(void*)) PrintEntry ) ; TreeSpan( ( (FOLDER*) folder )->kids, (void (*)(void*)) PrintFolder ) ; Indent() ; IOreport( "}\n" ) ; indent-- ; }
void PrintEntry( ENTRY* entry ) { Indent() ; IOreport( "%s = ", TagString( entry->tag ) ) ; if( entry->data ) ExprIOreport( (EXPR*) entry->data ) ; else IOreport( "(blank!)" ) ; IOreport( "\n" ) ; }
FOLDER* DbaseAddFolder( FOLDER* folder, TAG tag ) { FOLDER** gnew ; gnew = (FOLDER**) TreeInsert( folder->kids, kid_cmp, tag ) ; if( *gnew ) { IOerror( IO_WARN, "DbaseAddFolder", "%s/%s already exists\n", TagString( folder->tag ), TagString( tag ) ) ; return *gnew ; // already exists! } *gnew = new FOLDER ; (*gnew)->tag = tag ; return *gnew ; }
/* fill the browser */ void FillBrowser(Int4 entries ) { Int4 index; Int4 real_index; char bl[100]; fl_freeze_form(xew_mainf); fl_clear_browser(wad_brow); /* make a legend */ sprintf(bl,"@_@fName Type Index"); fl_add_browser_line(wad_brow, bl); for ( index = 0; index < entries; index++ ) { real_index = LinearMap[index+2]; sprintf(bl,"%-8.8s %-7.7s %5d", pDirEnt[real_index].name, TagString( pEntryTag[real_index] ), real_index ); fl_add_browser_line(wad_brow, bl); } fl_select_browser_line(wad_brow,1); fl_unfreeze_form(xew_mainf); }
// this function is meant to be called from under debugger to see the // proprieties of the given type id extern "C" void DumpTI(ULONG ti) { SYMBOL_INFO sym = { sizeof(SYMBOL_INFO) }; sym.ModBase = 0x400000; // it's a constant under Win32 sym.TypeIndex = ti; wxDbgHelpDLL::SymbolTag tag = wxDbgHelpDLL::SYMBOL_TAG_NULL; DoGetTypeInfo(&sym, TI_GET_SYMTAG, &tag); DoGetTypeInfo(&sym, TI_GET_TYPEID, &ti); OutputDebugString(wxString::Format(_T("Type 0x%x: "), sym.TypeIndex)); wxString name = wxDbgHelpDLL::GetSymbolName(&sym); if ( !name.empty() ) { OutputDebugString(wxString::Format(_T("name=\"%s\", "), name.c_str())); } DWORD nested; if ( !DoGetTypeInfo(&sym, TI_GET_NESTED, &nested) ) { nested = FALSE; } OutputDebugString(wxString::Format(_T("tag=%s%s"), nested ? _T("nested ") : wxEmptyString, TagString(tag).c_str())); if ( tag == wxDbgHelpDLL::SYMBOL_TAG_UDT ) { wxDbgHelpDLL::UdtKind udtKind; if ( DoGetTypeInfo(&sym, TI_GET_UDTKIND, &udtKind) ) { OutputDebugString(_T(" (") + UdtKindString(udtKind) + _T(')')); } } wxDbgHelpDLL::DataKind kind = wxDbgHelpDLL::DATA_UNKNOWN; if ( DoGetTypeInfo(&sym, TI_GET_DATAKIND, &kind) ) { OutputDebugString(wxString::Format( _T(", kind=%s"), KindString(kind).c_str())); if ( kind == wxDbgHelpDLL::DATA_MEMBER ) { DWORD ofs = 0; if ( DoGetTypeInfo(&sym, TI_GET_OFFSET, &ofs) ) { OutputDebugString(wxString::Format(_T(" (ofs=0x%x)"), ofs)); } } } wxDbgHelpDLL::BasicType bt = GetBasicType(&sym); if ( bt ) { OutputDebugString(wxString::Format(_T(", type=%s"), TypeString(bt).c_str())); } if ( ti != sym.TypeIndex ) { OutputDebugString(wxString::Format(_T(", next ti=0x%x"), ti)); } OutputDebugString(_T("\r\n")); }
std::shared_ptr<TypeInfo> DwarfVariableFinder::makeType(const DWARFDie &die) { if (!die.isValid()) { return std::make_shared<TypeInfo>("", ~0u); } auto opSize = die.find(dwarf::DW_AT_byte_size); unsigned size = 1; if(opSize.hasValue()) { size = opSize.getValue().getAsUnsignedConstant().getValue(); } std::string type_encoding = ""; raw_string_ostream SS(type_encoding); switch (die.getTag()) { case dwarf::DW_TAG_base_type: { auto opForm = die.find(dwarf::DW_AT_encoding); auto opEnc = opForm->getAsUnsignedConstant(); assert(opEnc < HANDLE_DW_ATE_SIZE); SS << HANDLE_DW_ATE[*opEnc]; opForm = die.find(dwarf::DW_AT_name); opForm->dump(SS); return std::make_shared<TypeInfo>(SS.str(), size); } case dwarf::DW_TAG_reference_type: case dwarf::DW_TAG_rvalue_reference_type: case dwarf::DW_TAG_pointer_type: { auto baseType = getType(die.getAttributeValueAsReferencedDie(dwarf::DW_AT_type)); SS << "*" << baseType->getName(); return std::make_shared<TypeInfo>(SS.str(), size); } case dwarf::DW_TAG_array_type: { auto baseType = getType(die.getAttributeValueAsReferencedDie(dwarf::DW_AT_type)); SS << baseType->getName(); size *= baseType->getSize(); for (auto childDie = die.getFirstChild(); childDie && childDie.getTag(); childDie = childDie.getSibling()) { std::shared_ptr<TypeInfo> rangeInfo = makeType(childDie); SS << "["; SS << rangeInfo->getName(); SS << "]"; size *= rangeInfo->getSize(); } return std::make_shared<TypeInfo>(SS.str(), size); } case dwarf::DW_TAG_subrange_type: { uint64_t count = 0; auto opCount = die.find(dwarf::DW_AT_count); if(opCount.hasValue()) { count = opCount.getValue().getAsUnsignedConstant().getValue(); } else { opCount = die.find(dwarf::DW_AT_upper_bound); assert(opCount.hasValue()); count = opCount.getValue().getAsUnsignedConstant().getValue() +1; } return std::make_shared<TypeInfo>(std::to_string(count), count); } case dwarf::DW_TAG_typedef: { return getType(die.getAttributeValueAsReferencedDie(dwarf::DW_AT_type)); } case dwarf::DW_TAG_structure_type: case dwarf::DW_TAG_class_type: case dwarf::DW_TAG_union_type: { SS << "struct" << dwarf::toString(die.find(dwarf::DW_AT_name), "None"); auto structType = std::make_shared<TypeInfo>(SS.str(), size); // Add subentries for various pieces of the struct. for (auto childDie = die.getFirstChild(); childDie && childDie.getTag(); childDie = childDie.getSibling()) { if (childDie.getTag() != dwarf::DW_TAG_inheritance && childDie.getTag() != dwarf::DW_TAG_member) { continue; } uint64_t dataMemOffset = dwarf::toUnsigned(childDie.find(dwarf::DW_AT_data_member_location), ~0U); structType->getFields().emplace_back(makeType(childDie), dataMemOffset); } return structType; } case dwarf::DW_TAG_inheritance: case dwarf::DW_TAG_member: { return getType(die.getAttributeValueAsReferencedDie(dwarf::DW_AT_type)); } default: { auto tagString = TagString(die.getTag()); if (tagString.empty()) { llvm::errs() << format("DW_TAG_Unknown_%x", die.getTag()); } die.dump(llvm::errs(), 10); return std::make_shared<TypeInfo>("", ~0u); } } }