Move `compute_probe_arg' and `compile_probe_arg' to probe.c
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / run.c
1 /*
2 * This simple classical example of recursion is useful for
3 * testing stack backtraces and such.
4 */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 int factorial (int);
10
11 int
12 main (int argc, char **argv, char **envp)
13 {
14 #ifdef FAKEARGV
15 printf ("%d\n", factorial (1)); /* commands.exp: hw local_var out of scope */
16 #else
17 if (argc != 2) {
18 printf ("usage: factorial <number>\n");
19 return 1;
20 } else {
21 printf ("%d\n", factorial (atoi (argv[1])));
22 }
23 #endif
24 return 0;
25 }
26
27 int factorial (int value)
28 {
29 int local_var;
30
31 if (value > 1) {
32 value *= factorial (value - 1);
33 }
34 local_var = value;
35 return (value);
36 } /* commands.exp: local_var out of scope */
This page took 0.031184 seconds and 4 git commands to generate.