/* * Determina si el objeto dado representa un handle * que apunta al interior de alguno de los bloques * administrados por el memory manager: * * - El OBJ_FLAG_HANDLE debe estar en 1. * - El puntero debe estar dentro de alguno de los * bloques (busqueda binaria). * - El objeto apuntado debe ser el primero de la * estructura. (En el esquema de manejo de memoria * elegido no se permiten punteros "internos" a * la mitad de una estructura). * * Pre: el arreglo de bloques de mm debe estar ordenado * por BLOCK_START de menor a mayor. */ int mm_is_handle(MM *mm, Obj obj) { Block **blocks = mm->blocks; if (!(obj & OBJ_FLAG_HANDLE)) { /* not a handle */ return 0; } if (BLOCK_START(0) > obj) { return 0; } uint64 index_left = 0; uint64 index_right = mm->nblocks; while (index_right - index_left > 1) { uint64 mid = index_left + (index_right - index_left) / 2; if (BLOCK_START(mid) <= obj) { index_left = mid; } else { index_right = mid; } } return BLOCK_START(index_left) <= obj && obj < BLOCK_START(index_left) + BLOCK_SIZE_IN_BYTES(index_left) && !(*OBJ_HANDLE_TO_PTR(obj) & OBJ_FLAG_CONTINUE); }
void mm_sort_blocks(Block **blocks, int begin, int end) { if (begin + 1 >= end) { return; } uint64 pivot_index = random() % (end - begin) + begin; uint64 pivot_value = BLOCK_START(pivot_index); uint64 index_left = begin; uint64 index_right = end; while (index_left < index_right) { if (BLOCK_START(index_left) <= pivot_value) { index_left++; } else { Block *tmp = blocks[index_left]; blocks[index_left] = blocks[index_right - 1]; blocks[index_right - 1] = tmp; index_right--; } } mm_sort_blocks(blocks, begin, index_left); mm_sort_blocks(blocks, index_left, end); }
int contained_in (const struct block *a, const struct block *b) { if (!a || !b) return 0; return BLOCK_START (a) >= BLOCK_START (b) && BLOCK_END (a) <= BLOCK_END (b); }
void ConnectionDialog::safeDraw(Graphics *const graphics) { BLOCK_START("ConnectionDialog::draw") // Don't draw the window background, only draw the children safeDrawChildren(graphics); BLOCK_END("ConnectionDialog::draw") }
/* Return a 1 if any of the address ranges for block BL begins with START and any of the address ranges for BL ends with END; return a 0 otherwise. */ int block_starts_and_ends (struct block *bl, CORE_ADDR start, CORE_ADDR end) { int retval; int start_found = 0; int end_found = 0; if (!BLOCK_RANGES (bl)) retval = BLOCK_START (bl) == start && BLOCK_END (bl) == end; else { int i; for (i = 0; i < BLOCK_RANGES (bl)->nelts && !start_found && !end_found; i++) { if (BLOCK_RANGE_START (bl, i) == start) start_found = 1; if (BLOCK_RANGE_END (bl, i) == end) end_found = 1; } retval = start_found && end_found; } return retval; }
void GeneralHandler::flushNetwork() { if (!mNetwork) return; BLOCK_START("GeneralHandler::flushNetwork 1") mNetwork->flush(); BLOCK_END("GeneralHandler::flushNetwork 1") mNetwork->dispatchMessages(); BLOCK_START("GeneralHandler::flushNetwork 3") if (mNetwork->getState() == Network::NET_ERROR) { if (!mNetwork->getError().empty()) { errorMessage = mNetwork->getError(); } else { // TRANSLATORS: error message errorMessage = _("Got disconnected from server!"); } Client::setState(STATE_ERROR); } BLOCK_END("GeneralHandler::flushNetwork 3") }
int inside_main_func (CORE_ADDR pc) { if (pc == 0) return 1; if (symfile_objfile == 0) return 0; /* If the addr range is not set up at symbol reading time, set it up now. This is for FRAME_CHAIN_VALID_ALTERNATE. I do this for coff, because it is unable to set it up and symbol reading time. */ if (symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC && symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC) { struct symbol *mainsym; mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) { symfile_objfile->ei.main_func_lowpc = BLOCK_START (SYMBOL_BLOCK_VALUE (mainsym)); symfile_objfile->ei.main_func_highpc = BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym)); } } return (symfile_objfile->ei.main_func_lowpc <= pc && symfile_objfile->ei.main_func_highpc > pc); }
struct frame_info * block_innermost_frame (const struct block *block) { struct frame_info *frame; CORE_ADDR start; CORE_ADDR end; if (block == NULL) return NULL; start = BLOCK_START (block); end = BLOCK_END (block); frame = get_selected_frame_if_set (); if (frame == NULL) frame = get_current_frame (); while (frame != NULL) { struct block *frame_block = get_frame_block (frame, NULL); if (frame_block != NULL && contained_in (frame_block, block)) return frame; frame = get_prev_frame (frame); } return NULL; }
struct frame_info * block_innermost_frame (struct block *block) { struct frame_info *frame; CORE_ADDR start; CORE_ADDR end; CORE_ADDR calling_pc; if (block == NULL) return NULL; start = BLOCK_START (block); end = BLOCK_END (block); frame = NULL; while (1) { frame = get_prev_frame (frame); if (frame == NULL) return NULL; calling_pc = get_frame_address_in_block (frame); if (calling_pc >= start && calling_pc < end) return frame; } }
CORE_ADDR get_pc_function_start (CORE_ADDR pc) { struct block *bl; struct minimal_symbol *msymbol; bl = block_for_pc (pc); if (bl) { struct symbol *symbol = block_linkage_function (bl); if (symbol) { bl = SYMBOL_BLOCK_VALUE (symbol); return BLOCK_START (bl); } } msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol) { CORE_ADDR fstart = SYMBOL_VALUE_ADDRESS (msymbol); if (find_pc_section (fstart)) return fstart; } return 0; }
static struct mdebug_extra_func_info * find_proc_desc (CORE_ADDR pc) { struct block *b = block_for_pc (pc); struct mdebug_extra_func_info *proc_desc = NULL; struct symbol *sym = NULL; if (b) { CORE_ADDR startaddr; find_pc_partial_function (pc, NULL, &startaddr, NULL); if (startaddr > BLOCK_START (b)) /* This is the "pathological" case referred to in a comment in print_frame_info. It might be better to move this check into symbol reading. */ sym = NULL; else sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, 0, NULL); } if (sym) { proc_desc = (struct mdebug_extra_func_info *) SYMBOL_VALUE (sym); /* If we never found a PDR for this function in symbol reading, then examine prologues to find the information. */ if (proc_desc->pdr.framereg == -1) proc_desc = NULL; } return proc_desc; }
void ConnectionDialog::draw(gcn::Graphics *graphics) { BLOCK_START("ConnectionDialog::draw") // Don't draw the window background, only draw the children drawChildren(graphics); BLOCK_END("ConnectionDialog::draw") }
static int there_is_a_visible_common_named (char *comname) { SAVED_F77_COMMON_PTR the_common; struct frame_info *fi; char *funname = 0; struct symbol *func; if (comname == NULL) error ("Cannot deal with NULL common name!"); fi = deprecated_selected_frame; if (fi == NULL) error ("No frame selected"); /* The following is generally ripped off from stack.c's routine print_frame_info() */ func = find_pc_function (fi->pc); if (func) { /* In certain pathological cases, the symtabs give the wrong function (when we are in the first function in a file which is compiled without debugging symbols, the previous function is compiled with debugging symbols, and the "foo.o" symbol that is supposed to tell us where the file with debugging symbols ends has been truncated by ar because it is longer than 15 characters). So look in the minimal symbol tables as well, and if it comes up with a larger address for the function use that instead. I don't think this can ever cause any problems; there shouldn't be any minimal symbols in the middle of a function. FIXME: (Not necessarily true. What about text labels) */ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); if (msymbol != NULL && (SYMBOL_VALUE_ADDRESS (msymbol) > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) funname = DEPRECATED_SYMBOL_NAME (msymbol); else funname = DEPRECATED_SYMBOL_NAME (func); } else { struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc); if (msymbol != NULL) funname = DEPRECATED_SYMBOL_NAME (msymbol); } the_common = find_common_for_function (comname, funname); return (the_common ? 1 : 0); }
void Minimap::setMap(const Map *const map) { BLOCK_START("Minimap::setMap") std::string caption; if (map) caption = map->getName(); if (caption.empty()) { // TRANSLATORS: mini map window name caption = _("Map"); } setCaption(caption); deleteMapImage(); if (map) { if (config.getBoolValue("showExtMinimaps")) { SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE, map->getWidth(), map->getHeight(), 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000); if (!surface) { if (!isSticky()) setVisible(Visible_false); BLOCK_END("Minimap::setMap") return; } // I'm not sure if the locks are necessary since it's a SWSURFACE SDL_LockSurface(surface); int* data = static_cast<int*>(surface->pixels); if (!data) { if (!isSticky()) setVisible(Visible_false); BLOCK_END("Minimap::setMap") return; } const int size = surface->h * surface->w; const int mask = (BlockMask::WALL | BlockMask::AIR | BlockMask::WATER); for (int ptr = 0; ptr < size; ptr ++) *(data ++) = -!(map->mMetaTiles[ptr].blockmask & mask); SDL_UnlockSurface(surface); mMapImage = imageHelper->load(surface); mMapImage->setAlpha(settings.guiAlpha); mCustomMapImage = true; MSDL_FreeSurface(surface); } else {
static PyObject * blpy_get_start (PyObject *self, void *closure) { const struct block *block = NULL; BLPY_REQUIRE_VALID (self, block); return gdb_py_object_from_ulongest (BLOCK_START (block)); }
static PyObject * blpy_get_start (PyObject *self, void *closure) { struct block *block = NULL; BLPY_REQUIRE_VALID (self, block); return PyLong_FromUnsignedLongLong (BLOCK_START (block)); }
void OutfitWindow::draw(Graphics *graphics) { BLOCK_START("OutfitWindow::draw") Window::draw(graphics); if (mCurrentOutfit < 0 || mCurrentOutfit >= static_cast<signed int>(OUTFITS_COUNT)) { return; } for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++) { const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth); const int itemY = mPadding + mTitleBarHeight + ((i / static_cast<unsigned int>(mGridWidth)) * mBoxHeight); graphics->setColor(mBorderColor); graphics->drawRectangle(Rect(itemX, itemY, 32, 32)); graphics->setColor(mBackgroundColor); graphics->fillRectangle(Rect(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) continue; bool foundItem = false; const Inventory *const inv = PlayerInfo::getInventory(); if (inv) { const Item *const item = inv->findItem(mItems[mCurrentOutfit][i], mItemColors[mCurrentOutfit][i]); if (item) { // Draw item icon. const Image *const image = item->getImage(); if (image) { graphics->drawImage(image, itemX, itemY); foundItem = true; } } } if (!foundItem) { Image *const image = Item::getImage(mItems[mCurrentOutfit][i], mItemColors[mCurrentOutfit][i]); if (image) { graphics->drawImage(image, itemX, itemY); image->decRef(); } } } BLOCK_END("OutfitWindow::draw") }
static struct type * find_function_return_type (CORE_ADDR pc) { struct symbol *sym = find_pc_function (pc); if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc && SYMBOL_TYPE (sym) != NULL) return TYPE_TARGET_TYPE (SYMBOL_TYPE (sym)); return NULL; }
void EmoteShortcutContainer::draw(gcn::Graphics *graphics) { if (!emoteShortcut) return; BLOCK_START("EmoteShortcutContainer::draw") mAlpha = Client::getGuiAlpha(); if (Client::getGuiAlpha() != mAlpha && mBackgroundImg) mBackgroundImg->setAlpha(mAlpha); Graphics *const g = static_cast<Graphics *const>(graphics); gcn::Font *const font = getFont(); drawBackground(g); g->setColorAll(mForegroundColor, mForegroundColor2); for (unsigned i = 0; i < mMaxItems; i++) { const int emoteX = (i % mGridWidth) * mBoxWidth; const int emoteY = (i / mGridWidth) * mBoxHeight; // Draw emote keyboard shortcut. const std::string key = inputManager.getKeyValueString( Input::KEY_EMOTE_1 + i); font->drawString(g, key, emoteX + 2, emoteY + 2); } const unsigned sz = static_cast<unsigned>(mEmoteImg.size()); for (unsigned i = 0; i < mMaxItems; i++) { if (i < sz && mEmoteImg[i] && mEmoteImg[i]->sprite) { mEmoteImg[i]->sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2, (i / mGridWidth) * mBoxHeight + 10); } } if (mEmoteMoved && mEmoteMoved < static_cast<unsigned>(sz) + 1 && mEmoteMoved > 0) { // Draw the emote image being dragged by the cursor. const EmoteSprite *const sprite = mEmoteImg[mEmoteMoved - 1]; if (sprite && sprite->sprite) { const AnimatedSprite *const spr = sprite->sprite; const int tPosX = mCursorPosX - (spr->getWidth() / 2); const int tPosY = mCursorPosY - (spr->getHeight() / 2); spr->draw(g, tPosX, tPosY); } } BLOCK_END("EmoteShortcutContainer::draw") }
void RadioButton::draw(gcn::Graphics* graphics) { BLOCK_START("RadioButton::draw") drawBox(graphics); gcn::Font *const font = getFont(); static_cast<Graphics *const>(graphics)->setColorAll( mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); BLOCK_END("RadioButton::draw") }
struct blockvector * blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section, int *pindex, struct symtab *symtab) { struct block *b; int bot, top, half; struct blockvector *bl; if (symtab == 0) /* if no symtab specified by caller */ { /* First search all symtabs for one whose file contains our pc */ symtab = find_pc_sect_symtab (pc, section); if (symtab == 0) return 0; } bl = BLOCKVECTOR (symtab); b = BLOCKVECTOR_BLOCK (bl, 0); /* Then search that symtab for the smallest block that wins. */ /* Use binary search to find the last block that starts before PC. */ bot = 0; top = BLOCKVECTOR_NBLOCKS (bl); while (top - bot > 1) { half = (top - bot + 1) >> 1; b = BLOCKVECTOR_BLOCK (bl, bot + half); if (BLOCK_START (b) <= pc) bot += half; else top = bot + half; } /* Now search backward for a block that ends after PC. */ while (bot >= 0) { b = BLOCKVECTOR_BLOCK (bl, bot); if (BLOCK_END (b) > pc) { if (pindex) *pindex = bot; return bl; } bot--; } return 0; }
int block_contains_pc (const struct block *bl, CORE_ADDR pc) { int i; int contains_pc = 0; if (! BLOCK_RANGES (bl)) /* No range list; just a low & high address */ contains_pc = BLOCK_START (bl) <= pc && BLOCK_END (bl) > pc; else for (i = 0; i < BLOCK_RANGES (bl)->nelts && !contains_pc; i++) if (BLOCK_RANGE_START (bl, i) <= pc && BLOCK_RANGE_END (bl, i) > pc) contains_pc = 1; return contains_pc; }
void Game::logic() { BLOCK_START("Game::logic") handleInput(); // Handle all necessary game logic ActorSprite::actorLogic(); if (actorManager) actorManager->logic(); if (particleEngine) particleEngine->update(); if (mCurrentMap) mCurrentMap->update(); BLOCK_END("Game::logic") }
void PlayerHandler::processWalkResponse(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processWalkResponse") /* * This client assumes that all walk messages succeed, * and that the server will send a correction notice * otherwise. */ uint16_t srcX, srcY, dstX, dstY; msg.readInt32("tick"); msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path"); msg.readUInt8("(sx<<4) | (sy&0x0f)"); if (localPlayer) localPlayer->setRealPos(dstX, dstY); BLOCK_END("PlayerHandler::processWalkResponse") }
static struct mdebug_extra_func_info * find_proc_desc (CORE_ADDR pc) { const struct block *b = block_for_pc (pc); struct mdebug_extra_func_info *proc_desc = NULL; struct symbol *sym = NULL; const char *sh_name = NULL; if (b) { CORE_ADDR startaddr; find_pc_partial_function (pc, &sh_name, &startaddr, NULL); if (startaddr > BLOCK_START (b)) /* This is the "pathological" case referred to in a comment in print_frame_info. It might be better to move this check into symbol reading. */ sym = NULL; else sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, 0).symbol; } if (sym) { proc_desc = (struct mdebug_extra_func_info *) SYMBOL_VALUE_BYTES (sym); /* Correct incorrect setjmp procedure descriptor from the library to make backtrace through setjmp work. */ if (proc_desc->pdr.pcreg == 0 && strcmp (sh_name, "setjmp") == 0) { proc_desc->pdr.pcreg = ALPHA_RA_REGNUM; proc_desc->pdr.regmask = 0x80000000; proc_desc->pdr.regoffset = -4; } /* If we never found a PDR for this function in symbol reading, then examine prologues to find the information. */ if (proc_desc->pdr.framereg == -1) proc_desc = NULL; } return proc_desc; }
static struct block * find_block_in_blockvector (struct blockvector *bl, CORE_ADDR pc) { struct block *b; int bot, top, half; /* If we have an addrmap mapping code addresses to blocks, then use that. */ if (BLOCKVECTOR_MAP (bl)) return addrmap_find (BLOCKVECTOR_MAP (bl), pc); /* Otherwise, use binary search to find the last block that starts before PC. Note: GLOBAL_BLOCK is block 0, STATIC_BLOCK is block 1. They both have the same START,END values. Historically this code would choose STATIC_BLOCK over GLOBAL_BLOCK but the fact that this choice was made was subtle, now we make it explicit. */ gdb_assert (BLOCKVECTOR_NBLOCKS (bl) >= 2); bot = STATIC_BLOCK; top = BLOCKVECTOR_NBLOCKS (bl); while (top - bot > 1) { half = (top - bot + 1) >> 1; b = BLOCKVECTOR_BLOCK (bl, bot + half); if (BLOCK_START (b) <= pc) bot += half; else top = bot + half; } /* Now search backward for a block that ends after PC. */ while (bot >= STATIC_BLOCK) { b = BLOCKVECTOR_BLOCK (bl, bot); if (BLOCK_END (b) > pc) return b; bot--; } return NULL; }
struct block * allocate_block(struct obstack *obstack) { struct block *bl = (struct block *)obstack_alloc(obstack, sizeof(struct block)); BLOCK_START(bl) = 0; BLOCK_END(bl) = 0; BLOCK_FUNCTION(bl) = NULL; BLOCK_SUPERBLOCK(bl) = NULL; BLOCK_DICT(bl) = NULL; BLOCK_NAMESPACE(bl) = NULL; BLOCK_GCC_COMPILED(bl) = 0; /* APPLE LOCAL begin address ranges */ BLOCK_RANGES(bl) = NULL; /* APPLE LOCAL end address ranges */ return bl; }
void GameHandler::connect() { if (!mNetwork) return; BLOCK_START("GameHandler::connect") mNetwork->connect(mapServer); const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken(); if (client->getState() == STATE_CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses if (localPlayer) { mCharID = localPlayer->getId(); localPlayer->setId(token.account_ID); } else { mCharID = BeingId_zero; } } // Send login infos createOutPacket(CMSG_MAP_SERVER_CONNECT); outMsg.writeBeingId(token.account_ID, "account id"); outMsg.writeBeingId(mCharID, "char id"); outMsg.writeInt32(token.session_ID1, "session id1"); outMsg.writeInt32(token.session_ID2, "session id2"); outMsg.writeInt8(Being::genderToInt(token.sex), "gender"); /* if (localPlayer) { // Change the player's ID to the account ID to match what eAthena uses localPlayer->setId(token.account_ID); } */ // We get 4 useless bytes before the real answer comes in (what are these?) mNetwork->skip(4); BLOCK_END("GameHandler::connect") }
static void nlm_symfile_read (struct objfile *objfile, int mainline) { bfd *abfd = objfile->obfd; struct cleanup *back_to; CORE_ADDR offset; struct symbol *mainsym; init_minimal_symbol_collection (); back_to = make_cleanup_discard_minimal_symbols (); /* FIXME, should take a section_offsets param, not just an offset. */ offset = ANOFFSET (objfile->section_offsets, 0); /* Process the NLM export records, which become the bfd's canonical symbol table. */ nlm_symtab_read (abfd, offset, objfile); /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ install_minimal_symbols (objfile); do_cleanups (back_to); stabsect_build_psymtabs (objfile, mainline, ".stab", ".stabstr", ".text"); mainsym = lookup_symbol (main_name (), NULL, VAR_DOMAIN, NULL, NULL); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) { objfile->ei.main_func_lowpc = BLOCK_START (SYMBOL_BLOCK_VALUE (mainsym)); objfile->ei.main_func_highpc = BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym)); } /* FIXME: We could locate and read the optional native debugging format here and add the symbols to the minimal symbol table. */ }
void ActorSprite::logic() { BLOCK_START("ActorSprite::logic") // Update sprite animations update(tick_time * MILLISECONDS_IN_A_TICK); // Restart status/particle effects, if needed if (mMustResetParticles) { mMustResetParticles = false; FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects) { const StatusEffect *const effect = StatusEffectDB::getStatusEffect(*it, Enable_true); if (effect && effect->mIsPersistent) updateStatusEffect(*it, Enable_true); } } // Update particle effects mChildParticleEffects.moveTo(mPos.x, mPos.y); BLOCK_END("ActorSprite::logic") }