Skip to content

Commit 29a39c1

Browse files
committed
Now builds a new opscounttab which has the change in
the size of the expression stack for each DW_OP. To enable the print_die.c changes. modified: src/bin/buildopstab/buildopscounttab.c modified: src/bin/dwarfdump/opscounttab.c (regenerated) modified: src/bin/dwarfdump/opscounttab.h (new field added) Unless the expression is trivial printing expressions (DW_OP_swap etc) -v -i now adds a line like DW_OPs= 13 maxstackdepth= 4 endingstackdepth= 3 at the end of the list of DW_OP expression operations as a shorthand for the instructions and their use of an expression stack. If there are expression loops It adds loopcount= <n> to the end of the line (counting the instances of a DW_OP_bra or DW_OP_skip in a negative direction). modified: src/bin/dwarfdump/print_die.c The old names of these functions were a bit misleading. They are for all expressions. dwarfdump_print_location_operations -> dwarfdump_print_expression_operations print_location_operations -> print_expression_operations modified: src/bin/dwarfdump/esb_using_functions.h modified: src/bin/dwarfdump/print_frames.c modified: src/bin/dwarfdump/print_frames.h modified: src/bin/dwarfdump/print_hipc_lopc_attr.c modified: src/bin/dwarfdump/print_tag_attributes_usage.c
1 parent f3e04e9 commit 29a39c1

File tree

9 files changed

+433
-352
lines changed

9 files changed

+433
-352
lines changed

src/bin/buildopstab/buildopscounttab.c

Lines changed: 100 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct ops_table_s {
4141
unsigned char ot_first;
4242
unsigned char ot_last;
4343
signed char ot_opcount;
44+
signed char ot_stackchange;
4445
};
4546

4647
/* the ops are 8 bits max */
@@ -54,83 +55,98 @@ struct dups_tab_s {
5455
int dups_used = 0;
5556

5657
static struct ops_table_s optabsource[]= {
57-
{DW_OP_addr , 0 , 1 },
58-
{DW_OP_deref , 0 , 0 },
59-
{DW_OP_const1u, DW_OP_consts , 1},
60-
{DW_OP_dup, DW_OP_over , 0},
61-
{DW_OP_pick, 0 , 1},
62-
{DW_OP_swap, DW_OP_plus , 0},
63-
{DW_OP_plus_uconst, 0 , 1},
64-
{DW_OP_shl, DW_OP_xor , 0},
65-
{DW_OP_bra , 0 , 1},
66-
{DW_OP_eq, DW_OP_ne , 0},
67-
{DW_OP_skip, 0 , 1},
68-
{DW_OP_lit0 , DW_OP_lit31 , 0},
69-
{DW_OP_reg0 , DW_OP_reg31 , 0},
70-
{DW_OP_breg0 , DW_OP_breg31 , 1},
71-
{DW_OP_regx , DW_OP_fbreg , 1},
72-
{DW_OP_bregx, 0, 2},
73-
{DW_OP_piece, DW_OP_xderef_size , 1},
74-
{DW_OP_nop , DW_OP_push_object_address ,0},
75-
{DW_OP_call2, DW_OP_call_ref , 1},
76-
{DW_OP_form_tls_address, DW_OP_call_frame_cfa , 0},
77-
{DW_OP_bit_piece, DW_OP_implicit_value , 2},
78-
{DW_OP_stack_value, 0, 0},
79-
{DW_OP_implicit_pointer, 0, 2},
80-
{DW_OP_addrx, DW_OP_constx , 1},
81-
{DW_OP_entry_value, 0, 2},
82-
{DW_OP_const_type, 0, 3},
83-
{DW_OP_regval_type, DW_OP_deref_type , 2},
84-
{DW_OP_xderef_type, 0, 0},
85-
{DW_OP_convert /*0xa8*/, 0, 1},
86-
{DW_OP_reinterpret /* 0xa9*/, 0, 1},
87-
{DW_OP_GNU_push_tls_address /*0xe0*/, 0, 0},
88-
{DW_OP_HP_unknown /* 0xe0*/, 0, 0},
89-
{DW_OP_LLVM_form_aspace_address /* 0xe1*/, 0, 0},
90-
{DW_OP_HP_is_value /* 0xe1*/, 0, 1},
91-
92-
{DW_OP_LLVM_push_lane /* 0xe2*/, 0, 0},
93-
{DW_OP_HP_fltconst4 /* 0xe2*/ , 0, 1},
94-
95-
{DW_OP_LLVM_offset /* 0xe3*/ , 0, 0},
96-
{DW_OP_HP_fltconst8 /* 0xe3*/ , 0, 1},
97-
98-
{DW_OP_LLVM_offset_uconst /* 0xe4*/, 0, 1},
99-
{DW_OP_HP_mod_range /* 0xe4*/, 0, 2},
100-
101-
{DW_OP_LLVM_bit_offset /* 0xe5*/, 0, 0},
102-
{DW_OP_HP_unmod_range /* 0xe5*/, 0, 2},
103-
104-
{DW_OP_LLVM_call_frame_entry_reg /* 0xe6*/, 0, 1},
105-
{DW_OP_HP_tls /* 0xe6*/, 0, 0},
106-
107-
{DW_OP_LLVM_undefined /* 0xe7*/, 0, 0},
108-
{DW_OP_LLVM_aspace_bregx /* 0xe8*/, 0, 2},
109-
{DW_OP_INTEL_bit_piece /* 0xe8*/, 0, 2},
110-
{DW_OP_LLVM_aspace_implicit_pointer /* 0xe9*/, 0, 2},
111-
{DW_OP_LLVM_piece_end /* 0xea*/, 0, 0},
112-
{DW_OP_LLVM_extend /* 0xeb*/, 0, 2},
113-
{DW_OP_LLVM_select_bit_piece /* 0xec*/, 0, 2},
114-
115-
{DW_OP_WASM_location /* 0xed*/, 0, 1},
116-
{DW_OP_WASM_location_int /* 0xee*/, 0, 1},
117-
118-
{DW_OP_GNU_uninit /* 0xf0*/, 0, 0},/*unknown opcount*/
119-
{DW_OP_APPLE_uninit /* 0xf0*/, 0, 1},
120-
{DW_OP_GNU_encoded_addr /*0xf1*/, 0, 1},/*1 is correct*/
121-
{DW_OP_GNU_implicit_pointer /*0xf2*/, 0, 1},/*1 is correct*/
122-
{DW_OP_GNU_entry_value /*0xf3*/, 0, 2},/*2 is correct*/
123-
{DW_OP_GNU_const_type /*0xf4 */, 0, 3},/*3 is correct*/
124-
{DW_OP_GNU_regval_type /* 0xf5*/, 0, 2},/*2 is correct*/
125-
{DW_OP_GNU_deref_type /*0xf6*/, 0, 2},/*2 is correct*/
126-
{DW_OP_GNU_convert /*0xf7*/, 0, 1},/*1 is correct*/
127-
{DW_OP_PGI_omp_thread_num /*0xf8*/, 0, 0},/*just pushes*/
128-
{DW_OP_GNU_reinterpret/* 0xf9*/, 0, 1},/*1 is correct*/
129-
{DW_OP_GNU_parameter_ref/* 0xfa*/, 0, 1},/*1 is correct*/
130-
{DW_OP_GNU_addr_index/* 0xfb*/, 0, 1},/*1 is correct.Fission*/
131-
{DW_OP_GNU_const_index/* 0xfc*/, 0, 1},/*1 is correct.Fission*/
132-
{DW_OP_GNU_variable_value/* 0xfd*/, 0, 1},/* GNU 2017*/
133-
{0,0,0}
58+
{DW_OP_addr , 0 , 1, 1 },
59+
{DW_OP_deref , 0 , 0, 0 },
60+
{DW_OP_const1u, DW_OP_consts , 1, 1},
61+
{DW_OP_dup, DW_OP_over , 0, 1},
62+
{DW_OP_pick, 0 , 1, 1},
63+
{DW_OP_swap, 0 , 0, 0},
64+
{DW_OP_rot, 0 , 0, 0},
65+
{DW_OP_xderef, 0 , 0, -1},
66+
{DW_OP_abs, 0 , 0, 0},
67+
{DW_OP_and, DW_OP_mul , 0, -1},
68+
{DW_OP_neg, DW_OP_not , 0, 0},
69+
{DW_OP_or, DW_OP_plus , 0, -1},
70+
{DW_OP_plus_uconst, 0 , 1, 0},
71+
72+
{DW_OP_shl, DW_OP_xor , 0, -1},
73+
{DW_OP_bra , 0 , 1, -1},
74+
{DW_OP_eq, DW_OP_ne , 0, -1},
75+
{DW_OP_skip, 0 , 1, 0},
76+
{DW_OP_lit0 , DW_OP_lit31 , 0, 1},
77+
{DW_OP_reg0 , DW_OP_reg31 , 0, 0},
78+
{DW_OP_breg0 , DW_OP_breg31 , 1, 1},
79+
{DW_OP_regx , DW_OP_fbreg , 1, 0},
80+
{DW_OP_bregx, 0 , 2, 1},
81+
{DW_OP_piece, 0 , 1, 0},
82+
{DW_OP_deref_size, 0 , 1, 0},
83+
{DW_OP_xderef_size, 0 , 1, -1},
84+
{DW_OP_nop, 0 , 0, 0},
85+
{DW_OP_push_object_address ,0 , 0, 1},
86+
/* The called expr may change the stack,
87+
but not the call itself*/
88+
{DW_OP_call2, DW_OP_call_ref , 1, 0},
89+
90+
{DW_OP_form_tls_address,0 , 0, 0},
91+
{DW_OP_call_frame_cfa ,0 , 0, 1},
92+
{DW_OP_bit_piece, 0 , 2, 0},
93+
{DW_OP_implicit_value, 0 , 2, 0},
94+
{DW_OP_stack_value, 0 , 0, 0},
95+
{DW_OP_implicit_pointer,0 , 2, 0},
96+
{DW_OP_addrx, DW_OP_constx , 1, 1},
97+
{DW_OP_entry_value, 0, 2, 1},
98+
{DW_OP_const_type, 0, 3, 1},
99+
{DW_OP_regval_type, DW_OP_deref_type , 2, 1},
100+
{DW_OP_xderef_type, 0, 0, -1},
101+
{DW_OP_convert /*0xa8*/, 0, 1, 0},
102+
{DW_OP_reinterpret /* 0xa9*/, 0, 1, 0},
103+
{DW_OP_GNU_push_tls_address /*0xe0*/, 0, 0, 1},
104+
{DW_OP_HP_unknown /* 0xe0*/, 0, 0, 0},
105+
{DW_OP_LLVM_form_aspace_address /* 0xe1*/, 0, 0, 1},
106+
{DW_OP_HP_is_value /* 0xe1*/, 0, 1, 1},
107+
108+
{DW_OP_LLVM_push_lane /* 0xe2*/, 0, 0, 1},
109+
{DW_OP_HP_fltconst4 /* 0xe2*/ , 0, 1, 1},
110+
111+
{DW_OP_LLVM_offset /* 0xe3*/ , 0, 0, 0},
112+
{DW_OP_HP_fltconst8 /* 0xe3*/ , 0, 1, 0},
113+
114+
{DW_OP_LLVM_offset_uconst /* 0xe4*/, 0, 1, 0},
115+
{DW_OP_HP_mod_range /* 0xe4*/, 0, 2, 0},
116+
117+
{DW_OP_LLVM_bit_offset /* 0xe5*/, 0, 0, 0},
118+
{DW_OP_HP_unmod_range /* 0xe5*/, 0, 2, 0},
119+
120+
{DW_OP_LLVM_call_frame_entry_reg /* 0xe6*/, 0, 1, 0},
121+
{DW_OP_HP_tls /* 0xe6*/, 0, 0, 0},
122+
123+
{DW_OP_LLVM_undefined /* 0xe7*/, 0, 0, 0},
124+
{DW_OP_LLVM_aspace_bregx /* 0xe8*/, 0, 2, 0},
125+
{DW_OP_INTEL_bit_piece /* 0xe8*/, 0, 2, 0},
126+
{DW_OP_LLVM_aspace_implicit_pointer /* 0xe9*/, 0, 2, 0},
127+
{DW_OP_LLVM_piece_end /* 0xea*/, 0, 0, 0},
128+
{DW_OP_LLVM_extend /* 0xeb*/, 0, 2, 0},
129+
130+
{DW_OP_LLVM_select_bit_piece /* 0xec*/, 0, 2, 0},
131+
{DW_OP_WASM_location /* 0xed*/, 0, 1, 1},
132+
{DW_OP_WASM_location_int /* 0xee*/, 0, 1, 1},
133+
134+
{DW_OP_GNU_uninit /* 0xf0*/, 0, 0, 0},/*unknown opcount*/
135+
{DW_OP_APPLE_uninit /* 0xf0*/, 0, 1, 0},
136+
{DW_OP_GNU_encoded_addr /*0xf1*/, 0, 1, 1},/*1 op is correct*/
137+
{DW_OP_GNU_implicit_pointer /*0xf2*/, 0, 1, 1},/*1 op is correct*/
138+
{DW_OP_GNU_entry_value /*0xf3*/, 0, 2, 1},/*2 op is correct*/
139+
{DW_OP_GNU_const_type /*0xf4 */, 0, 3,1},/*3 is correct*/
140+
{DW_OP_GNU_regval_type /* 0xf5*/, 0, 2,1},/*2 is correct*/
141+
{DW_OP_GNU_deref_type /*0xf6*/, 0, 2,1},/*2 is correct*/
142+
{DW_OP_GNU_convert /*0xf7*/, 0, 1,0},/*1 is correct*/
143+
{DW_OP_PGI_omp_thread_num /*0xf8*/, 0, 0,1},/*just pushes*/
144+
{DW_OP_GNU_reinterpret/* 0xf9*/, 0, 1,0},/*1 is correct*/
145+
{DW_OP_GNU_parameter_ref/* 0xfa*/, 0, 1,1},/*1 is correct*/
146+
{DW_OP_GNU_addr_index/* 0xfb*/, 0, 1,1},/*1 is correct.Fission*/
147+
{DW_OP_GNU_const_index/* 0xfc*/, 0, 1,1},/*1 is correct.Fission*/
148+
{DW_OP_GNU_variable_value/* 0xfd*/, 0, 1,1},/* GNU 2017*/
149+
{0,0,0,0}
134150
};
135151

136152
static void
@@ -385,6 +401,7 @@ int main(int argc, char**argv)
385401
printf("struct dwarf_opscounttab_s _dwarf_opscounttab[] = {\n");
386402
for ( ; ; ++inindex) {
387403
const char *opn = 0;
404+
int sc = 0;
388405

389406
op = &optabsource[inindex];
390407
f = op->ot_first;
@@ -403,8 +420,10 @@ int main(int argc, char**argv)
403420
}
404421
l = op->ot_last;
405422
c = op->ot_opcount;
423+
sc = op->ot_stackchange;
424+
406425
while (f > outindex) {
407-
printf("{/* %-26s 0x%02x*/ %d},\n","unused",outindex,-1);
426+
printf("{/* %-26s 0x%02x*/ %d, 0},\n","unused",outindex,-1);
408427
++outindex;
409428
}
410429
if (!l) {
@@ -416,7 +435,7 @@ int main(int argc, char**argv)
416435
}
417436
lastop = f;
418437

419-
printf("{/* %-26s 0x%02x*/ %d},\n",opn,f,c);
438+
printf("{/* %-26s 0x%02x*/ %d, %d},\n",opn,f,c,sc);
420439
{
421440
char *dup = 0;
422441
if (havedup(f,&dup)) {
@@ -435,7 +454,7 @@ int main(int argc, char**argv)
435454
f);
436455
return 1; /* effectively exit(1); */
437456
}
438-
printf("{/* %-26s 0x%2x*/ %d}",opn,j,c);
457+
printf("{/* %-26s 0x%2x*/ %d, %d}",opn,j,c,sc);
439458
printf(",\n");
440459
{
441460
/* Should NOT happen, dups should
@@ -456,7 +475,7 @@ int main(int argc, char**argv)
456475
}
457476
}
458477
while (outindex < DWOPS_ARRAY_SIZE) {
459-
printf("{/* %-26s 0x%02x*/ %d},\n","unused",outindex,-1);
478+
printf("{/* %-26s 0x%02x*/ %d, 0},\n","unused",outindex,-1);
460479
++outindex;
461480
}
462481
printf("};\n");

src/bin/dwarfdump/esb_using_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int get_attr_value(Dwarf_Debug dbg, Dwarf_Half tag,
5757

5858
void format_sig8_string(Dwarf_Sig8 *data,struct esb_s *out);
5959

60-
int dwarfdump_print_location_operations(Dwarf_Debug dbg,
60+
int dwarfdump_print_expression_operations(Dwarf_Debug dbg,
6161
Dwarf_Die die,
6262
int die_indent_level,
6363
Dwarf_Locdesc_c locs, /* 2015 interface */

0 commit comments

Comments
 (0)