[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs

Example adb Program: adbsamp3

The following sample program adbsamp3.c contains an infinite recursion of subfunction calls. If you run this program to completion, it causes a memory fault error and quits.

int     fcnt,gcnt,hcnt;
h(x,y)
int x,y;
{
        int hi;
        register int hr;
        hi = x+1;
        hr = x-y+1;
        hcnt++;
        hj:
        f(hr,hi);
}
g(p,q)
int p,q;
{
        int gi;
        register int gr;
        gi = q-p;
        gr = q-p+1;
        gcnt++;
        gj:
        h(gr,gi);
}
f(a,b)
int a,b;
{
        int fi;
        register int fr;
        fi = a+2*b;
        fr = a+b;
        fcnt++;
        fj:
        g(fr,fi);
}
main()
{
        f(1,1);
}

Compile the program using the cc command to create the adbsamp3 file with the following command:

cc -g adbsamp3.c -o adbsamp3

To start the debug session, enter:

adb adbsamp3

Related Information

adb Debug Program Overview.

adb Debug Program Expressions

Example adb Program: adbsamp.

Example adb Program: adbsamp2.

The adb command.


[ Previous | Next | Contents | Glossary | Home | Search ]