[PATCH] Fix "thiscall" method calling convention for inferior calls (PR15559)

Julian Brown julian@codesourcery.com
Wed Mar 26 13:23:00 GMT 2014


Hi,

This is an adaptation of the patch in PR15559 that handles calling
inferior methods (on win32/mingw32) using the "thiscall" calling
convention -- i.e. with the "this" pointer in the ecx register. Instead
of attempting to detect the GCC version used to compile a particular
function/method to determine the calling convention to use (which didn't
seem to work well for me), I've introduced a new GNU-specific Dwarf code
to represent the calling convention in question.

GCC does not emit the tag at present: I will submit the GCC part of the
fix (to emit the Dwarf tag as appropriate) shortly.

Testing (cross to mingw32 from Linux) gives testsuite result
improvements as follows:

FAIL -> PASS: default/gdb.sum:gdb.cp/bs15503.exp: print (const char *) (s=s.substr(0,4))
FAIL -> PASS: default/gdb.sum:gdb.cp/bs15503.exp: print (const char *) s
FAIL -> PASS: default/gdb.sum:gdb.cp/bs15503.exp: print (const char *) s.substr(0,4)
FAIL -> PASS: default/gdb.sum:gdb.cp/bs15503.exp: print s.length()
FAIL -> PASS: default/gdb.sum:gdb.cp/bs15503.exp: print s[0]
FAIL -> PASS: default/gdb.sum:gdb.cp/bs15503.exp: print s[s.length()-1]
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aptr_a (&g_A)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aptr_a (&g_B)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aptr_x (&g_A)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aptr_x (&g_B)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aref_a (g_A)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aref_a (g_B)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aref_x (g_A)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aref_x (g_B)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aval_a (g_A)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aval_a (g_B)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aval_x (g_A)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: call class_param.Aval_x (g_B)
FAIL -> PASS: default/gdb.sum:gdb.cp/classes.exp: calling method for small class
FAIL -> PASS: default/gdb.sum:gdb.cp/gdb2384.exp: gdb2384
FAIL -> PASS: default/gdb.sum:gdb.cp/gdb2384.exp: gdb2384 (second)
FAIL -> PASS: default/gdb.sum:gdb.cp/gdb2384.exp: print d1.meth ()
FAIL -> PASS: default/gdb.sum:gdb.cp/gdb2384.exp: print d2.meth()
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print bar(a)
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print bar(b)
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print bar(c)
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print bar(d)
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 10 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 11 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 2 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 3 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 4 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 5 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 6 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 7 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 8 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func 9 args
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func char arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func char\* arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func double arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func float arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func int arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func int\* arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func long arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func short arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func signed char arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func unsigned char arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func unsigned int arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func unsigned long arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func unsigned short arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print call overloaded func void arg
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: print foo_instance1.overloadfnarg(23, intintfunc)
FAIL -> PASS: default/gdb.sum:gdb.cp/overload.exp: re-selected 'main' frame after inferior call
FAIL -> PASS: default/gdb.sum:gdb.cp/smartp.exp: p sp4->a
FAIL -> PASS: default/gdb.sum:gdb.cp/smartp.exp: p sp4->b
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: continue to line 770
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: print fint
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: print fvpchar
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: print t5i.value()
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype bazint
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype bazint2
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype bint
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype bint2
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype fchar
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype fint
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype quxint
FAIL -> PASS: default/gdb.sum:gdb.cp/templates.exp: ptype siip
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print !one
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print ++one
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print +one
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print --one
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print -one
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one % two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one & two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one && two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one * two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one + two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one += 7
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one - two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one ^ two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one | two
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one++
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print one--
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print two = one
FAIL -> PASS: default/gdb.sum:gdb.cp/userdef.exp: print ~one
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: next to pAa->f call
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: next to pDe->vg call
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pADe->vg()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pBe->vvb()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pDd->vg()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pDe->vg()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pDe->vvb()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pEe->fvb()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pEe->vd()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pEe->vvb()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: print pVB->vvb()
FAIL -> PASS: default/gdb.sum:gdb.cp/virtfunc.exp: step through thunk into E::vg
Removed FAIL: default/gdb.sum:gdb.cp/templates.exp: ptype fvpchar
Removed FAIL: default/gdb.sum:gdb.cp/virtfunc.exp: print pEe->D::vg()

OK to apply (pending approval of the GCC part of the patch), or any
comments?

Thanks,

Julian

ChangeLog

    include/
    * dwarf2.h (enum dwarf_calling_convention): Add code for
    DW_CC_GNU_thiscall_i386.

    gdb/
    * dwarf2read.c (dwarf2_add_member_fn): Add calling convention
    argument to smash_to_method_type call.
    (quirk_gcc_member_function_pointer): Likewise.
    (read_tag_ptr_to_member_type): Likewise.
    (smash_to_method_type): Add CALLING_CONVENTION argument. Initialise
    func-specific type for method types, and set the calling convention
    as appropriate.
    (init_type): Call INIT_FUNC_SPECIFIC for method types as well as
    function types.
    * gdbtypes.h (struct main_type): Adjust comment for FUNC_STUFF.
    (struct func_type): Adjust comment.
    * stabsread.c (read_type): Add dummy calling-convention argument to
    smash_to_method_type call.
    * i386-tdep.c (utils.h, infcall.h, dwarf2.h): Include files.
    (i386_push_dummy_call): Handle "thiscall" calling convention.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-thiscall-fsf-2.diff
Type: text/x-patch
Size: 6263 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20140326/1fb020b1/attachment.bin>


More information about the Gdb-patches mailing list