int MergeInfoSection::getFileLenDelta( MergeFile * file, MergeOffset& moff, uint_32 form ) //------------------------------------------------------------- { uint_32 oldIdx; uint_32 newIdx; int delta; switch( form ) { case DW_FORM_udata: oldIdx = file->readULEB128( DR_DEBUG_INFO, moff.offset ); break; case DW_FORM_sdata: oldIdx = file->readSLEB128( DR_DEBUG_INFO, moff.offset ); break; default: InternalAssert( 0 /* unknown form for fileLenDelta */ ); file->skipForm( DR_DEBUG_INFO, moff.offset, form, getAddrSize() ); return 0; } newIdx = _line.getNewFileIdx( moff.fileIdx, (uint_16) oldIdx ); delta = MergeFile::ULEB128Len( newIdx ); delta -= MergeFile::ULEB128Len( oldIdx ); #if ( INSTRUMENTS == INSTRUMENTS_FULL_LOGGING ) Log.printf( "FileLenDelta from %x to %x -- %d\n", oldIdx, newIdx, delta ); #endif return (DIELen_T) delta; }
bool Socket::bind() { if ( !socket() ) return( false ); if ( ::bind( mSd, mLocalAddr->getAddr(), getAddrSize() ) == -1 ) { Error( "bind(), errno = %d, error = %s", errno, strerror(errno) ); close(); return( false ); } return( true ); }
bool Socket::accept( int &newSd ) { struct sockaddr *rem_addr = mLocalAddr->getTempAddr(); socklen_t rem_addr_size = getAddrSize(); newSd = -1; if ( (newSd = ::accept( mSd, rem_addr, &rem_addr_size )) == -1 ) { Error( "accept(), errno = %d, error = %s", errno, strerror(errno) ); close(); return( false ); } return( true ); }
bool Socket::connect() { if ( !socket() ) return( false ); if ( ::connect( mSd, mRemoteAddr->getAddr(), getAddrSize() ) == -1 ) { Error( "connect(), errno = %d, error = %s", errno, strerror(errno) ); close(); return( false ); } mState = CONNECTED; return( true ); }
/** * @brief * * @return */ bool Socket::accept() { struct sockaddr *remoteAddr = mLocalAddr->getTempAddr(); socklen_t remoteAddrSize = getAddrSize(); int newSd = -1; if ( (newSd = ::accept( mSd, remoteAddr, &remoteAddrSize )) == -1 ) { Error( "accept(), errno = %d, error = %s", errno, strerror(errno) ); close(); return( false ); } mRemoteAddr = SockAddr::newSockAddr( *remoteAddr, remoteAddrSize ); ::close( mSd ); mSd = newSd; mState = CONNECTED; return( true ); }
void MergeInfoSection::readDIE( MergeFile * file, MergeOffset startOff, MergeDIE * prt, MergeOffset& moff, uint_32 abbCode ) //------------------------------------------------------------------- // read a die and all its children, adding to _dies. return false when // the abbrev code is zero (recursive) { MergeDIE * die; // one we read MergeAbbrev * abbrev; MergeOffset child; // offset of first child MergeOffset sibling; bool ext = TRUE; // external or static? bool defn = TRUE; // is a definition? const char * name = NULL; int i; DIELen_T length; int lenDelta = 0; // delta from changing file idx if( abbCode == 0 ) { length = (DIELen_T) (moff.offset - startOff.offset); MergeNameKey nmKey( abbCode, ext, NULL, 0 ); die = new MergeDIE( prt, startOff, nmKey, child, sibling, defn, length ); die = die->collision( _diesByName ); #if INSTRUMENTS if( abbrev == NULL ) { Log.printf( "zoiks! %s\n", startOff.getString() ); } #endif return; //<------------------- early return } abbrev = _abbrevs.getAbbrev( abbCode ); #if INSTRUMENTS if( abbrev == NULL ) { Log.printf( "ABBREV == NULL! offset is %s, %s\n", startOff.getString(), moff.getString() ); } #endif InfoAssert( abbrev != NULL ); // NYI throw for( i = 0; i < abbrev->entries(); i += 1 ) { MergeAttrib & att( (*abbrev)[ i ] ); switch( att.attrib() ) { case DW_AT_name: name = file->readString( DR_DEBUG_INFO, moff.offset ); if( abbrev->tag() == DW_TAG_compile_unit ) { name = MagicCompunitName; } break; case DW_AT_sibling: sibling.fileIdx = moff.fileIdx; sibling.offset = file->readDWord( DR_DEBUG_INFO, moff.offset ); break; case DW_AT_external: ext = file->readByte( DR_DEBUG_INFO, moff.offset ); break; case DW_AT_declaration: defn = !file->readByte( DR_DEBUG_INFO, moff.offset ); break; case DW_AT_decl_file: lenDelta = getFileLenDelta( file, moff, att.form() ); break; default: file->skipForm( DR_DEBUG_INFO, moff.offset, att.form(), getAddrSize() ); } } if( abbrev->hasChildren() ) { child = moff; } length = (DIELen_T)(moff.offset - startOff.offset + lenDelta); MergeNameKey nmKey( abbrev->tag(), ext, name, 0 ); die = new MergeDIE( prt, startOff, nmKey, child, sibling, defn, length ); die = die->collision( _diesByName ); getReloc().addReloc( startOff, die ); if( abbrev->hasChildren() ) { while( 1 ) { startOff = moff; abbCode = file->readULEB128( DR_DEBUG_INFO, moff.offset ); if( abbCode == 0 ) break; readDIE( file, startOff, die, moff, abbCode ); } } if( !die->siblingSet() ) { die->setSibling( moff ); } }