Lines Matching defs:bb
3 /*--- bb.c ---*/
32 /*--- Basic block (BB) operations ---*/
35 /* BB hash, resizable */
44 bbs.table = (BB**) CLG_MALLOC("cl.bb.ibh.1",
45 bbs.size * sizeof(BB*));
57 * - BB base as object file offset
65 /* double size of bb table */
70 BB **new_table, *curr, *next;
74 new_table = (BB**) CLG_MALLOC("cl.bb.rbt.1",
75 new_size * sizeof(BB*));
104 CLG_DEBUG(0, "Resize BB Hash: %u => %d (entries %u, conflicts %d/%d)\n",
115 * Allocate new BB structure (including space for event type list)
119 static BB* new_bb(obj_node* obj, PtrdiffT offset,
122 BB* bb;
125 /* check fill degree of bb hash table and resize if needed (>80%) */
130 size = sizeof(BB) + instr_count * sizeof(InstrInfo)
132 bb = (BB*) CLG_MALLOC("cl.bb.nb.1", size);
133 VG_(memset)(bb, 0, size);
135 bb->obj = obj;
136 bb->offset = offset;
138 bb->instr_count = instr_count;
139 bb->cjmp_count = cjmp_count;
140 bb->cjmp_inverted = cjmp_inverted;
141 bb->jmp = (CJmpInfo*) &(bb->instr[instr_count]);
142 bb->instr_len = 0;
143 bb->cost_count = 0;
144 bb->sect_kind = VG_(DebugInfo_sect_kind)(NULL, offset + obj->offset);
145 bb->fn = 0;
146 bb->line = 0;
147 bb->is_entry = 0;
148 bb->bbcc_list = 0;
149 bb->last_bbcc = 0;
151 /* insert into BB hash table */
153 bb->next = bbs.table[idx];
154 bbs.table[idx] = bb;
164 CLG_(print_bb)(0, bb);
169 CLG_(get_fn_node)(bb);
171 return bb;
175 /* get the BB structure for a BB start address */
177 BB* lookup_bb(obj_node* obj, PtrdiffT offset)
179 BB* bb;
183 bb = bbs.table[idx];
185 while(bb) {
186 if ((bb->obj == obj) && (bb->offset == offset)) break;
187 bb = bb->next;
191 obj->name, (UWord)offset, bb);
192 return bb;
225 /* Get the BB structure for a BB start address.
226 * If the BB has to be created, the IRBB is needed to
231 * is called from CLG_(instrument)() and a BB already exists:
233 * - The ELF object of the BB was unmapped and mapped again.
235 * looking up a BB keyed by (obj_node, file offset).
237 * bbIn==0 is possible for artificial BB without real code.
238 * Such a BB is created when returning to an unknown function.
240 BB* CLG_(get_bb)(Addr addr, IRSB* bbIn, /*OUT*/ Bool *seen_before)
242 BB* bb;
247 CLG_DEBUG(5, "+ get_bb(BB %#lx)\n", addr);
250 bb = lookup_bb(obj, addr - obj->offset);
256 *seen_before = bb ? True : False;
258 if (bb->instr_count != n_instrs) {
260 "ERROR: BB Retranslation Mismatch at BB %#lx\n", addr);
267 bb->obj->name, (UWord)bb->obj->offset,
268 (UWord)bb->offset, bb->instr_count);
269 CLG_ASSERT(bb->instr_count == n_instrs );
271 CLG_ASSERT(bb->cjmp_count == n_jmps );
274 CLG_DEBUG(5, "- get_bb(BB %#lx): seen before.\n", addr);
275 return bb;
278 bb = new_bb(obj, addr - obj->offset, n_instrs, n_jmps, cjmp_inverted);
280 CLG_DEBUG(5, "- get_bb(BB %#lx)\n", addr);
282 return bb;
285 /* Delete the BB info for the bb with unredirected entry-point
289 BB *bb, *bp;
296 bb = bbs.table[idx];
298 /* bb points at the current bb under consideration, and bp is the
301 while(bb) {
302 if ((bb->obj == obj) && (bb->offset == offset)) break;
303 bp = bb;
304 bb = bb->next;
307 if (bb == NULL) {
313 * was off at BB translation time, ie. no BB was created.
322 tl_assert(bb == bbs.table[idx]);
323 bbs.table[idx] = bb->next;
325 tl_assert(bb != bbs.table[idx]);
326 bp->next = bb->next;
330 obj->name, (UWord)offset, bb, bb->bbcc_list);
332 if (bb->bbcc_list == 0) {
337 size = sizeof(BB)
338 + bb->instr_count * sizeof(InstrInfo)
339 + (bb->cjmp_count+1) * sizeof(CJmpInfo);
340 VG_(memset)( bb, 0xAA, size );
341 CLG_FREE(bb);
344 CLG_DEBUG(3, " delete_bb: BB in use, can not free!\n");