[LLVMdev] operator overloading fails while debugging with gdb for i386

Renato Golin rengolin at systemcall.org
Mon Dec 3 03:16:17 PST 2012


On 3 December 2012 10:42, Mayur Pandey <mayurthebond at gmail.com> wrote:
> So this seems to be the cause of the problem.

I guess you're mixing two different problems. First, is the possible
lack of conformance with the ABI you state, which I can't comment
since I don't know that ABI very well. Second, is the fact that clang
is not printing correct debug information (or is not interoperating
well enough with gdb).

Fixing the first issue will not necessarily fix the second.


> @Renato Golin:- Does the code execute correctly? Does a printf on the sum
> outputs the
> correct value? : yes the code executes correctly and some gives the correct
> value. Its only in gdb that we face this problem as gdb expects the hidden
> pointer in eax.

As I expected. Following the ABI is not a requirement to have working
code, or a debuggable code. GDB is probably expecting programs to
follow the ABI if they do not have decent Dwarf, which seems clang is
failing on both.

Debuggers have to deal with all sorts of user (and compiler) code, and
to give users the "debug illusion", they make too many guesses.
However, if the Dwarf information is correct to begin with, I
seriously hope that GDB would rely on that, rather than "expect"
values to be on specific registers.

Have a look in the Dwarf symbols clang generates with your code and
make sure that clang is not printing the correct location information
for that variable on the ranges where it lives on registers and which
registers.

If clang's info is right, there's only the ABI bug and GDB is being
silly. If the info is wrong, then we may need to fix *both* bugs (ABI
+ Dwarf), not just the ABI one.


--
cheers,
--renato

http://systemcall.org/



More information about the llvm-dev mailing list