Lines Matching refs:be

46 buffer_ext_dump(struct buffer_ext *be, const char *msg)  in buffer_ext_dump()  argument
50 for (i = 0 ; i < be->cur_pos; i++) in buffer_ext_dump()
51 warnx("%4zu 0x%02x", i, (((char *)be->data)[i]) & 0xff); in buffer_ext_dump()
55 buffer_ext_add(struct buffer_ext *be, void *addr, size_t sz) in buffer_ext_add() argument
58 size_t be_sz = be->max_sz; in buffer_ext_add()
61 if ((be->cur_pos + sz) < be_sz) { in buffer_ext_add()
62 memcpy(be->data + be->cur_pos, addr, sz); in buffer_ext_add()
63 be->cur_pos += sz; in buffer_ext_add()
72 tmp = realloc(be->data, be_sz); in buffer_ext_add()
76 be->data = tmp; in buffer_ext_add()
77 be->max_sz = be_sz; in buffer_ext_add()
83 buffer_ext_init(struct buffer_ext *be) in buffer_ext_init() argument
85 be->data = NULL; in buffer_ext_init()
86 be->cur_pos = 0; in buffer_ext_init()
87 be->max_sz = 0; in buffer_ext_init()
91 buffer_ext_size(struct buffer_ext *be) in buffer_ext_size() argument
93 return be->cur_pos; in buffer_ext_size()
97 buffer_ext_addr(struct buffer_ext *be) in buffer_ext_addr() argument
99 return be->data; in buffer_ext_addr()
179 static void emit_uword(struct buffer_ext *be, uword data) in emit_uword() argument
181 buffer_ext_add(be, &data, sizeof(uword)); in emit_uword()
184 static void emit_string(struct buffer_ext *be, const char *s) in emit_string() argument
186 buffer_ext_add(be, (void *)s, strlen(s) + 1); in emit_string()
189 static void emit_unsigned_LEB128(struct buffer_ext *be, in emit_unsigned_LEB128() argument
197 buffer_ext_add(be, &cur, 1); in emit_unsigned_LEB128()
201 static void emit_signed_LEB128(struct buffer_ext *be, long data) in emit_signed_LEB128() argument
216 buffer_ext_add(be, &cur, 1); in emit_signed_LEB128()
220 static void emit_extended_opcode(struct buffer_ext *be, ubyte opcode, in emit_extended_opcode() argument
223 buffer_ext_add(be, (char *)"", 1); in emit_extended_opcode()
225 emit_unsigned_LEB128(be, data_len + 1); in emit_extended_opcode()
227 buffer_ext_add(be, &opcode, 1); in emit_extended_opcode()
228 buffer_ext_add(be, data, data_len); in emit_extended_opcode()
231 static void emit_opcode(struct buffer_ext *be, ubyte opcode) in emit_opcode() argument
233 buffer_ext_add(be, &opcode, 1); in emit_opcode()
236 static void emit_opcode_signed(struct buffer_ext *be, in emit_opcode_signed() argument
239 buffer_ext_add(be, &opcode, 1); in emit_opcode_signed()
240 emit_signed_LEB128(be, data); in emit_opcode_signed()
243 static void emit_opcode_unsigned(struct buffer_ext *be, ubyte opcode, in emit_opcode_unsigned() argument
246 buffer_ext_add(be, &opcode, 1); in emit_opcode_unsigned()
247 emit_unsigned_LEB128(be, data); in emit_opcode_unsigned()
250 static void emit_advance_pc(struct buffer_ext *be, unsigned long delta_pc) in emit_advance_pc() argument
252 emit_opcode_unsigned(be, DW_LNS_advance_pc, delta_pc); in emit_advance_pc()
255 static void emit_advance_lineno(struct buffer_ext *be, long delta_lineno) in emit_advance_lineno() argument
257 emit_opcode_signed(be, DW_LNS_advance_line, delta_lineno); in emit_advance_lineno()
260 static void emit_lne_end_of_sequence(struct buffer_ext *be) in emit_lne_end_of_sequence() argument
262 emit_extended_opcode(be, DW_LNE_end_sequence, NULL, 0); in emit_lne_end_of_sequence()
265 static void emit_set_file(struct buffer_ext *be, unsigned long idx) in emit_set_file() argument
267 emit_opcode_unsigned(be, DW_LNS_set_file, idx); in emit_set_file()
270 static void emit_lne_define_filename(struct buffer_ext *be, in emit_lne_define_filename() argument
273 buffer_ext_add(be, (void *)"", 1); in emit_lne_define_filename()
276 emit_unsigned_LEB128(be, strlen(filename) + 5); in emit_lne_define_filename()
277 emit_opcode(be, DW_LNE_define_file); in emit_lne_define_filename()
278 emit_string(be, filename); in emit_lne_define_filename()
280 emit_unsigned_LEB128(be, 0); in emit_lne_define_filename()
282 emit_unsigned_LEB128(be, 0); in emit_lne_define_filename()
284 emit_unsigned_LEB128(be, 0); in emit_lne_define_filename()
287 static void emit_lne_set_address(struct buffer_ext *be, in emit_lne_set_address() argument
290 emit_extended_opcode(be, DW_LNE_set_address, &address, sizeof(unsigned long)); in emit_lne_set_address()
327 static void emit_lineno_info(struct buffer_ext *be, in emit_lineno_info() argument
350 emit_lne_set_address(be, (void *)code_addr); in emit_lineno_info()
360 emit_lne_define_filename(be, ent->name); in emit_lineno_info()
362 emit_set_file(be, ++cur_file_idx); in emit_lineno_info()
370 emit_opcode(be, special_opcode); in emit_lineno_info()
376 emit_advance_lineno(be, ent->lineno - last_line); in emit_lineno_info()
384 emit_advance_pc(be, ent->addr - last_vma); in emit_lineno_info()
392 emit_opcode(be, DW_LNS_copy); in emit_lineno_info()
397 static void add_debug_line(struct buffer_ext *be, in add_debug_line() argument
404 old_size = buffer_ext_size(be); in add_debug_line()
406 buffer_ext_add(be, (void *)&default_debug_line_header, in add_debug_line()
409 buffer_ext_add(be, &standard_opcode_length, sizeof(standard_opcode_length)); in add_debug_line()
412 buffer_ext_add(be, (void *)"", 1); in add_debug_line()
415 buffer_ext_add(be, (void *)"", 1); in add_debug_line()
417 dbg_header = buffer_ext_addr(be) + old_size; in add_debug_line()
418 dbg_header->prolog_length = (buffer_ext_size(be) - old_size) - in add_debug_line()
421 emit_lineno_info(be, ent, nr_entry, code_addr); in add_debug_line()
423 emit_lne_end_of_sequence(be); in add_debug_line()
425 dbg_header = buffer_ext_addr(be) + old_size; in add_debug_line()
426 dbg_header->total_length = (buffer_ext_size(be) - old_size) - in add_debug_line()
431 add_debug_abbrev(struct buffer_ext *be) in add_debug_abbrev() argument
433 emit_unsigned_LEB128(be, 1); in add_debug_abbrev()
434 emit_unsigned_LEB128(be, DW_TAG_compile_unit); in add_debug_abbrev()
435 emit_unsigned_LEB128(be, DW_CHILDREN_yes); in add_debug_abbrev()
436 emit_unsigned_LEB128(be, DW_AT_stmt_list); in add_debug_abbrev()
437 emit_unsigned_LEB128(be, DW_FORM_data4); in add_debug_abbrev()
438 emit_unsigned_LEB128(be, 0); in add_debug_abbrev()
439 emit_unsigned_LEB128(be, 0); in add_debug_abbrev()
440 emit_unsigned_LEB128(be, 0); in add_debug_abbrev()
444 add_compilation_unit(struct buffer_ext *be, in add_compilation_unit() argument
448 size_t old_size = buffer_ext_size(be); in add_compilation_unit()
450 buffer_ext_add(be, &default_comp_unit_header, in add_compilation_unit()
453 emit_unsigned_LEB128(be, 1); in add_compilation_unit()
454 emit_uword(be, offset_debug_line); in add_compilation_unit()
456 comp_unit_header = buffer_ext_addr(be) + old_size; in add_compilation_unit()
457 comp_unit_header->total_length = (buffer_ext_size(be) - old_size) - in add_compilation_unit()