Lines Matching full:be
47 buffer_ext_dump(struct buffer_ext *be, const char *msg) in buffer_ext_dump() argument
51 for (i = 0 ; i < be->cur_pos; i++) in buffer_ext_dump()
52 warnx("%4zu 0x%02x", i, (((char *)be->data)[i]) & 0xff); in buffer_ext_dump()
56 buffer_ext_add(struct buffer_ext *be, void *addr, size_t sz) in buffer_ext_add() argument
59 size_t be_sz = be->max_sz; in buffer_ext_add()
62 if ((be->cur_pos + sz) < be_sz) { in buffer_ext_add()
63 memcpy(be->data + be->cur_pos, addr, sz); in buffer_ext_add()
64 be->cur_pos += sz; in buffer_ext_add()
73 tmp = realloc(be->data, be_sz); in buffer_ext_add()
77 be->data = tmp; in buffer_ext_add()
78 be->max_sz = be_sz; in buffer_ext_add()
84 buffer_ext_init(struct buffer_ext *be) in buffer_ext_init() argument
86 be->data = NULL; in buffer_ext_init()
87 be->cur_pos = 0; in buffer_ext_init()
88 be->max_sz = 0; in buffer_ext_init()
92 buffer_ext_exit(struct buffer_ext *be) in buffer_ext_exit() argument
94 zfree(&be->data); in buffer_ext_exit()
98 buffer_ext_size(struct buffer_ext *be) in buffer_ext_size() argument
100 return be->cur_pos; in buffer_ext_size()
104 buffer_ext_addr(struct buffer_ext *be) in buffer_ext_addr() argument
106 return be->data; in buffer_ext_addr()
156 .minimum_instruction_length = 1, /* could be better when min instruction size != 1 */
186 static void emit_uword(struct buffer_ext *be, uword data) in emit_uword() argument
188 buffer_ext_add(be, &data, sizeof(uword)); in emit_uword()
191 static void emit_string(struct buffer_ext *be, const char *s) in emit_string() argument
193 buffer_ext_add(be, (void *)s, strlen(s) + 1); in emit_string()
196 static void emit_unsigned_LEB128(struct buffer_ext *be, in emit_unsigned_LEB128() argument
204 buffer_ext_add(be, &cur, 1); in emit_unsigned_LEB128()
208 static void emit_signed_LEB128(struct buffer_ext *be, long data) in emit_signed_LEB128() argument
223 buffer_ext_add(be, &cur, 1); in emit_signed_LEB128()
227 static void emit_extended_opcode(struct buffer_ext *be, ubyte opcode, in emit_extended_opcode() argument
230 buffer_ext_add(be, (char *)"", 1); in emit_extended_opcode()
232 emit_unsigned_LEB128(be, data_len + 1); in emit_extended_opcode()
234 buffer_ext_add(be, &opcode, 1); in emit_extended_opcode()
235 buffer_ext_add(be, data, data_len); in emit_extended_opcode()
238 static void emit_opcode(struct buffer_ext *be, ubyte opcode) in emit_opcode() argument
240 buffer_ext_add(be, &opcode, 1); in emit_opcode()
243 static void emit_opcode_signed(struct buffer_ext *be, in emit_opcode_signed() argument
246 buffer_ext_add(be, &opcode, 1); in emit_opcode_signed()
247 emit_signed_LEB128(be, data); in emit_opcode_signed()
250 static void emit_opcode_unsigned(struct buffer_ext *be, ubyte opcode, in emit_opcode_unsigned() argument
253 buffer_ext_add(be, &opcode, 1); in emit_opcode_unsigned()
254 emit_unsigned_LEB128(be, data); in emit_opcode_unsigned()
257 static void emit_advance_pc(struct buffer_ext *be, unsigned long delta_pc) in emit_advance_pc() argument
259 emit_opcode_unsigned(be, DW_LNS_advance_pc, delta_pc); in emit_advance_pc()
262 static void emit_advance_lineno(struct buffer_ext *be, long delta_lineno) in emit_advance_lineno() argument
264 emit_opcode_signed(be, DW_LNS_advance_line, delta_lineno); in emit_advance_lineno()
267 static void emit_lne_end_of_sequence(struct buffer_ext *be) in emit_lne_end_of_sequence() argument
269 emit_extended_opcode(be, DW_LNE_end_sequence, NULL, 0); in emit_lne_end_of_sequence()
272 static void emit_set_file(struct buffer_ext *be, unsigned long idx) in emit_set_file() argument
274 emit_opcode_unsigned(be, DW_LNS_set_file, idx); in emit_set_file()
277 static void emit_lne_define_filename(struct buffer_ext *be, in emit_lne_define_filename() argument
280 buffer_ext_add(be, (void *)"", 1); in emit_lne_define_filename()
283 emit_unsigned_LEB128(be, strlen(filename) + 5); in emit_lne_define_filename()
284 emit_opcode(be, DW_LNE_define_file); in emit_lne_define_filename()
285 emit_string(be, filename); in emit_lne_define_filename()
287 emit_unsigned_LEB128(be, 0); in emit_lne_define_filename()
289 emit_unsigned_LEB128(be, 0); in emit_lne_define_filename()
291 emit_unsigned_LEB128(be, 0); in emit_lne_define_filename()
294 static void emit_lne_set_address(struct buffer_ext *be, in emit_lne_set_address() argument
297 emit_extended_opcode(be, DW_LNE_set_address, &address, sizeof(unsigned long)); in emit_lne_set_address()
320 /* This is not sufficient to ensure opcode will be in [0-256] but in get_special_opcode()
334 static void emit_lineno_info(struct buffer_ext *be, in emit_lineno_info() argument
360 emit_lne_set_address(be, (void *)code_addr); in emit_lineno_info()
371 emit_lne_define_filename(be, ent->name); in emit_lineno_info()
373 emit_set_file(be, ++cur_file_idx); in emit_lineno_info()
381 emit_opcode(be, special_opcode); in emit_lineno_info()
387 emit_advance_lineno(be, ent->lineno - last_line); in emit_lineno_info()
395 emit_advance_pc(be, ent->addr - last_vma); in emit_lineno_info()
403 emit_opcode(be, DW_LNS_copy); in emit_lineno_info()
408 static void add_debug_line(struct buffer_ext *be, in add_debug_line() argument
415 old_size = buffer_ext_size(be); in add_debug_line()
417 buffer_ext_add(be, (void *)&default_debug_line_header, in add_debug_line()
420 buffer_ext_add(be, &standard_opcode_length, sizeof(standard_opcode_length)); in add_debug_line()
423 buffer_ext_add(be, (void *)"", 1); in add_debug_line()
426 buffer_ext_add(be, (void *)"", 1); in add_debug_line()
428 dbg_header = buffer_ext_addr(be) + old_size; in add_debug_line()
429 dbg_header->prolog_length = (buffer_ext_size(be) - old_size) - in add_debug_line()
432 emit_lineno_info(be, ent, nr_entry, code_addr); in add_debug_line()
434 emit_lne_end_of_sequence(be); in add_debug_line()
436 dbg_header = buffer_ext_addr(be) + old_size; in add_debug_line()
437 dbg_header->total_length = (buffer_ext_size(be) - old_size) - in add_debug_line()
442 add_debug_abbrev(struct buffer_ext *be) in add_debug_abbrev() argument
444 emit_unsigned_LEB128(be, 1); in add_debug_abbrev()
445 emit_unsigned_LEB128(be, DW_TAG_compile_unit); in add_debug_abbrev()
446 emit_unsigned_LEB128(be, DW_CHILDREN_yes); in add_debug_abbrev()
447 emit_unsigned_LEB128(be, DW_AT_stmt_list); in add_debug_abbrev()
448 emit_unsigned_LEB128(be, DW_FORM_data4); in add_debug_abbrev()
449 emit_unsigned_LEB128(be, 0); in add_debug_abbrev()
450 emit_unsigned_LEB128(be, 0); in add_debug_abbrev()
451 emit_unsigned_LEB128(be, 0); in add_debug_abbrev()
455 add_compilation_unit(struct buffer_ext *be, in add_compilation_unit() argument
459 size_t old_size = buffer_ext_size(be); in add_compilation_unit()
461 buffer_ext_add(be, &default_comp_unit_header, in add_compilation_unit()
464 emit_unsigned_LEB128(be, 1); in add_compilation_unit()
465 emit_uword(be, offset_debug_line); in add_compilation_unit()
467 comp_unit_header = buffer_ext_addr(be) + old_size; in add_compilation_unit()
468 comp_unit_header->total_length = (buffer_ext_size(be) - old_size) - in add_compilation_unit()
540 shdr->sh_addr = 0; /* must be zero or == sh_offset -> dynamic object */ in jit_add_debug_info()
574 shdr->sh_addr = 0; /* must be zero or == sh_offset -> dynamic object */ in jit_add_debug_info()
608 shdr->sh_addr = 0; /* must be zero or == sh_offset -> dynamic object */ in jit_add_debug_info()