+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1998, 1999, 2001, 2003, 2004, Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
/* Test GDB's ability to restore saved registers from stack frames
when using the `return' command.
Jim Blandy <jimb@cygnus.com> --- December 1998 */
(defun caller (n) (format "caller%d" n))
(defun local (n) (format "l%d" n))
(defun local-sum (n)
- (let ((j 1))
- (while (<= j n)
- (insert (local j))
- (if (< j n) (insert "+"))
- (setq j (1+ j)))))
+ (if (zerop n) (insert "0")
+ (let ((j 1))
+ (while (<= j n)
+ (insert (local j))
+ (if (< j n) (insert "+"))
+ (setq j (1+ j))))))
(defun local-chain (n previous first-end)
(let ((j 1))
(while (<= j n)
" = increment (" previous ");")
(if first-end
(progn
- (insert " /" "* " first-end " *" "/")
+ (insert " /" "* " first-end " prologue *" "/")
(setq first-end nil)))
(insert "\n")
(setq previous (local j))
(insert "{\n")
(local-chain i "n" (callee i))
(insert " return ")
- (if (<= i 0) (insert "n")
- (local-sum i))
+ (local-sum i)
(insert ";\n")
(insert "}\n\n")
(setq i (1+ i))))
int
callee0 (int n)
{
- return n;
+ return 0;
}
/* Returns n * 1 + 1 */
int
callee1 (int n)
{
- register int l1 = increment (n); /* callee1 */
+ register int l1 = increment (n); /* callee1 prologue */
return l1;
}
int
callee2 (int n)
{
- register int l1 = increment (n); /* callee2 */
+ register int l1 = increment (n); /* callee2 prologue */
register int l2 = increment (l1);
return l1+l2;
}
int
callee3 (int n)
{
- register int l1 = increment (n); /* callee3 */
+ register int l1 = increment (n); /* callee3 prologue */
register int l2 = increment (l1);
register int l3 = increment (l2);
return l1+l2+l3;
int
callee4 (int n)
{
- register int l1 = increment (n); /* callee4 */
+ register int l1 = increment (n); /* callee4 prologue */
register int l2 = increment (l1);
register int l3 = increment (l2);
register int l4 = increment (l3);
int
callee5 (int n)
{
- register int l1 = increment (n); /* callee5 */
+ register int l1 = increment (n); /* callee5 prologue */
register int l2 = increment (l1);
register int l3 = increment (l2);
register int l4 = increment (l3);
int
caller1 (void)
{
- register int l1 = increment (0x7eeb); /* caller1 */
+ register int l1 = increment (0x7eeb); /* caller1 prologue */
register int n;
n = callee0 (l1);
n = callee1 (n + l1);
int
caller2 (void)
{
- register int l1 = increment (0x7eeb); /* caller2 */
+ register int l1 = increment (0x7eeb); /* caller2 prologue */
register int l2 = increment (l1);
register int n;
n = callee0 (l2);
int
caller3 (void)
{
- register int l1 = increment (0x7eeb); /* caller3 */
+ register int l1 = increment (0x7eeb); /* caller3 prologue */
register int l2 = increment (l1);
register int l3 = increment (l2);
register int n;
int
caller4 (void)
{
- register int l1 = increment (0x7eeb); /* caller4 */
+ register int l1 = increment (0x7eeb); /* caller4 prologue */
register int l2 = increment (l1);
register int l3 = increment (l2);
register int l4 = increment (l3);
int
caller5 (void)
{
- register int l1 = increment (0x7eeb); /* caller5 */
+ register int l1 = increment (0x7eeb); /* caller5 prologue */
register int l2 = increment (l1);
register int l3 = increment (l2);
register int l4 = increment (l3);
#endif
driver ();
printf("exiting\n");
+ return 0;
}