[Bug gdb/34416] Incorrect loss of sign in 64-bit multiply (e.g.: DW_OP_mul in DWARF evaluation)
wmessmer at microsoft dot com via Gdb-prs <[email protected]>
| Newsgroups | gmane.comp.gdb.bugs.discuss |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://sourceware.org/bugzilla/show_bug.cgi?id=34416 --- Comment #2 from Bill Messmer <wmessmer at microsoft dot com> --- It absolutely is the DW_OP_mul. I generally avoid looking at the GDB source, so I let copilot completely drive this (asking it to show me the DWARF eval stack at every step of the EE) and this is what is spat out (by setting a breakpoint in the GDB DWARF EE): (gdb) cont Continuing. op=DW_OP_entry_value depth=0 op=DW_OP_consts depth=0 op=DW_OP_plus_uconst depth=1 [0] 0xf07380bc176f5c0b op=DW_OP_entry_value depth=1 [0] 0x61e2f02e176f5c12 op=DW_OP_consts depth=1 [0] 0x61e2f02e176f5c12 op=DW_OP_plus_uconst depth=2 [0] 0x61e2f02e176f5c12 [1] 0xf07380bc176f5c0b op=DW_OP_lit17 depth=2 [0] 0x61e2f02e176f5c12 [1] 0x61e2f02e176f5c12 op=DW_OP_shr depth=3 [0] 0x61e2f02e176f5c12 [1] 0x61e2f02e176f5c12 [2] 0x0000000000000011 op=DW_OP_xor depth=2 [0] 0x61e2f02e176f5c12 [1] 0x000030f178170bb7 op=DW_OP_consts depth=1 [0] 0x61e2c0df6f7857a5 op=DW_OP_mul depth=2 [0] 0x61e2c0df6f7857a5 [1] 0xff51afd7ed558ccd op=DW_OP_entry_value depth=1 [0] 0xbf5e897211ea94df op=DW_OP_consts depth=1 [0] 0xbf5e897211ea94df op=DW_OP_plus_uconst depth=2 [0] 0xbf5e897211ea94df [1] 0xf07380bc176f5c0b op=DW_OP_entry_value depth=2 [0] 0xbf5e897211ea94df [1] 0x61e2f02e176f5c12 op=DW_OP_consts depth=2 [0] 0xbf5e897211ea94df [1] 0x61e2f02e176f5c12 op=DW_OP_plus_uconst depth=3 [0] 0xbf5e897211ea94df [1] 0x61e2f02e176f5c12 [2] 0xf07380bc176f5c0b op=DW_OP_lit17 depth=3 [0] 0xbf5e897211ea94df [1] 0x61e2f02e176f5c12 [2] 0x61e2f02e176f5c12 op=DW_OP_shr depth=4 [0] 0xbf5e897211ea94df [1] 0x61e2f02e176f5c12 [2] 0x61e2f02e176f5c12 [3] 0x0000000000000011 op=DW_OP_xor depth=3 [0] 0xbf5e897211ea94df [1] 0x61e2f02e176f5c12 [2] 0x000030f178170bb7 op=DW_OP_consts depth=2 [0] 0xbf5e897211ea94df [1] 0x61e2c0df6f7857a5 op=DW_OP_mul depth=3 [0] 0xbf5e897211ea94df [1] 0x61e2c0df6f7857a5 [2] 0xff51afd7ed558ccd op=DW_OP_lit31 depth=2 [0] 0xbf5e897211ea94df [1] 0xbf5e897211ea94df op=DW_OP_shr depth=3 [0] 0xbf5e897211ea94df [1] 0xbf5e897211ea94df [2] 0x000000000000001f op=DW_OP_xor depth=2 [0] 0xbf5e897211ea94df [1] 0x000000017ebd12e4 op=DW_OP_consts depth=1 [0] 0xbf5e89736f57863b op=DW_OP_mul depth=2 [0] 0xbf5e89736f57863b [1] 0xc4ceb9fe1a85ec53 op=DW_OP_entry_value depth=1 [0] 0x3cf688b683c5e921 op=DW_OP_consts depth=1 [0] 0x3cf688b683c5e921 op=DW_OP_plus_uconst depth=2 [0] 0x3cf688b683c5e921 [1] 0xf07380bc176f5c0b op=DW_OP_entry_value depth=2 [0] 0x3cf688b683c5e921 [1] 0x61e2f02e176f5c12 op=DW_OP_consts depth=2 [0] 0x3cf688b683c5e921 [1] 0x61e2f02e176f5c12 op=DW_OP_plus_uconst depth=3 [0] 0x3cf688b683c5e921 [1] 0x61e2f02e176f5c12 [2] 0xf07380bc176f5c0b op=DW_OP_lit17 depth=3 [0] 0x3cf688b683c5e921 [1] 0x61e2f02e176f5c12 [2] 0x61e2f02e176f5c12 op=DW_OP_shr depth=4 [0] 0x3cf688b683c5e921 [1] 0x61e2f02e176f5c12 [2] 0x61e2f02e176f5c12 [3] 0x0000000000000011 op=DW_OP_xor depth=3 [0] 0x3cf688b683c5e921 [1] 0x61e2f02e176f5c12 [2] 0x000030f178170bb7 op=DW_OP_consts depth=2 [0] 0x3cf688b683c5e921 [1] 0x61e2c0df6f7857a5 op=DW_OP_mul depth=3 [0] 0x3cf688b683c5e921 [1] 0x61e2c0df6f7857a5 [2] 0xff51afd7ed558ccd op=DW_OP_entry_value depth=2 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df op=DW_OP_consts depth=2 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df op=DW_OP_plus_uconst depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0xf07380bc176f5c0b op=DW_OP_entry_value depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2f02e176f5c12 op=DW_OP_consts depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2f02e176f5c12 op=DW_OP_plus_uconst depth=4 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2f02e176f5c12 [3] 0xf07380bc176f5c0b op=DW_OP_lit17 depth=4 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2f02e176f5c12 [3] 0x61e2f02e176f5c12 op=DW_OP_shr depth=5 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2f02e176f5c12 [3] 0x61e2f02e176f5c12 [4] 0x0000000000000011 op=DW_OP_xor depth=4 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2f02e176f5c12 [3] 0x000030f178170bb7 op=DW_OP_consts depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2c0df6f7857a5 op=DW_OP_mul depth=4 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x61e2c0df6f7857a5 [3] 0xff51afd7ed558ccd op=DW_OP_lit31 depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0xbf5e897211ea94df op=DW_OP_shr depth=4 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0xbf5e897211ea94df [3] 0x000000000000001f op=DW_OP_xor depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e897211ea94df [2] 0x000000017ebd12e4 op=DW_OP_consts depth=2 [0] 0x3cf688b683c5e921 [1] 0xbf5e89736f57863b op=DW_OP_mul depth=3 [0] 0x3cf688b683c5e921 [1] 0xbf5e89736f57863b [2] 0xc4ceb9fe1a85ec53 op=DW_OP_const1u depth=2 [0] 0x3cf688b683c5e921 [1] 0x3cf688b683c5e921 op=DW_OP_shr depth=3 [0] 0x3cf688b683c5e921 [1] 0x3cf688b683c5e921 [2] 0x0000000000000020 op=DW_OP_xor depth=2 [0] 0x3cf688b683c5e921 [1] 0x000000003cf688b6 op=DW_OP_stack_value depth=1 [0] 0x3cf688b6bf336197 That **FIRST** DW_OP_mul.... Take a look at that and what's on the evaluator stack afterward: op=DW_OP_mul depth=2 [0] 0x61e2c0df6f7857a5 [1] 0xff51afd7ed558ccd op=DW_OP_entry_value depth=1 [0] 0xbf5e897211ea94df Whether those values are 64-bit signed or unsigned, you should end up with: 0x61e2c0df6f7857a5 * 0xff51afd7ed558ccd == 0x40a1768dee156b21 But it does *NOT*. The DW_OP_mul produces 0xbf5e897211ea94df. That **IS** in fact: 0x61e2c0df6f7857a5 * | 0xff51afd7ed558ccd | == 0x61e2c0df6f7857a5 * 0xae502812aa7333 == 0xbf5e897211ea94df The operation here is not multiplying the two values on the stack. It's multiplying the magnitude (abs) of the two values on the evaluator stack and discarding the resulting sign. -- You are receiving this mail because: You are on the CC list for the bug.