OpenCores
Issue List
GDB does not handle functions with float args with K&R prototypes #122
Closed jeremybennett opened this issue over 13 years ago
jeremybennett commented over 13 years ago
<p> GDB has a problem passing args correctly to dummy function calls if that function takes a float argument, and is specified using a Kernigan & Ritchie style function prototype, rather than an ANSI prototype. </p> <p> Test program: </p> <ul><pre> float foo = '1'; float L;

#ifdef KR void Fun (foo) float foo; #else void Fun (float foo) #endif { L = foo;

} / Fun () /

int main () { Fun (foo);
return 0;

} / main () /

</pre></ul> <p> This can be compiled using the ANSI function prototype using: </p> <ul><pre> or32-elf-gcc -g -mor32-newlib call-test.c </pre></ul> <p> And as K&R function prototype using: </p> <ul><pre> or32-elf-gcc -g -mor32-newlib -DKR call-test.c </pre></ul> <p> This should be debugged with GDB, using the following commands </p> <ul><pre> file a.out target sim load break main run call Fun(foo) print /c L </pre></ul> <p> Fun should set the float global variable L to the value in the float global variable foo, which as a char is '1'. It works with the ANSI version, not the K&R version. </p> <p> It seems that the K&R version effectively treats the argument as double, even though declared float. However when called as a dummy function within GDB, the argument is set up as a float. </p> <p> Not clear if this is a generic GDB issue, or a fault in the OR32 function to set up a dummy call. </p> <p> No one is likely to write (and hence debug) K&R code today, but there is still a lot out there, so we should support this. For now the regression is run using -DPROTOTYPES in the C flags, which means all tests are compiled using prototypes. </p> <p> Jeremy </p> <p> -- <br /> Tel: +44 (1590) 610184<br /> Cell: +44 (7970) 676050<br /> SkypeID: jeremybennett<br /> Email: <a href="mailto:jeremy.bennett@embecosm.com">jeremy.bennett@embecosm.com</a><br /> Web: <a href="http://www.embecosm.com">www.embecosm.com</a> </p>
jeremybennett was assigned over 13 years ago
jeremybennett commented over 13 years ago
<p> The known regression test that can trigger this is in gdb.base/call-sc.exp. </p>
jeremybennett commented over 12 years ago
<p> Transferred to OpenRISC bugzilla (<a href="http://bugzilla.opencores.org/show_bug.cgi?id=22">Bug 22</a>). </p> <p> Marking closed in this bugtracker. </p>
jeremybennett closed this over 12 years ago

Assignee
jeremybennett
Labels
Bug