This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello, One of our users just came across this on an i386-linux machine. He tried to do a "finish" on a function that returns an array whose size is statically known. This is not possible in C, but this can be done in Ada. Consider the following code: package Pck is type Data_Small is array (1 .. 2) of Integer; type Data_Large is array (1 .. 4) of Integer; function Create_Small return Data_Small; function Create_Large return Data_Large; end Pck; (the body of that package is pasted at the end of this message, for better clarity) And a main procedure that uses that package: with Pck; use Pck; procedure P is Small : Data_Small; Large : Data_Large; begin Small := Create_Small; Large := Create_Large; Small (1) := Large (1); end P; To build this example program, simply do: % gnatmake -g p Doing a "finish" off function Create_Small and Create_Large currently yield these two results: (gdb) b create_small (gdb) b create_large (gdb) run (gdb) fin [...] Value returned is $1 = (-1073743720, 134566260) (gdb) c (gdb) fin [...] i386-tdep.c:1337: internal-error: Cannot extract return value of 16 bytes long. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n i386-tdep.c:1337: internal-error: Cannot extract return value of 16 bytes long. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n The problem is that the the i386 struct-return code did not expect a function whose return type is a TYPE_CODE_ARRAY. This case is not mentioned as far as I could tell in the ABI, but the array is returned the same way records would be. The attached patch implements this. 2005-10-07 Joel Brobecker <brobecker@adacore.com> * i386-tdep.c (i386_reg_struct_return_p): Allow array types as well. (i386_return_value): Add handling for functions that return array types. Tested on x86-linux, no regression. Testcase to follow shortly in a separate email. OK to apply? Thanks, -- Joel package body Pck is function Create_Small return Data_Small is begin return (others => 1); end Create_Small; function Create_Large return Data_Large is begin return (others => 2); end Create_Large; end Pck;
Attachment:
i386-tdep.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |