"Fossies" - the Fresh Open Source Software Archive 
Member "mpr-2.8/config/btgcc.c" (14 Mar 2001, 1359 Bytes) of package /linux/misc/old/mpr-2.8.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /*
2 * This file contains generic C code to print call chains, assuming
3 * you have GCC >= 2. It is neither pretty nor (space and time)
4 * efficient. On some architectures it could be terribly inefficient,
5 * e.g. on a sparc, each expansion of __builtin_return_address()
6 * might flush the register windows.
7 *
8 * It is therefore preferable to have an architecture specific version
9 * of mprbt(). For a hint on how to do this, you could examine the
10 * assembly source listing produced for function mprbt().
11 */
12
13 #if __GNUC__ < 2
14 #error you need gcc >= 2 to use this abomination
15 #endif
16
17 #undef ulong
18 #define ulong unsigned long
19
20 extern int mprprint(int, char *, ...);
21
22 #define printpc(n) \
23 if ((pc = (ulong)__builtin_return_address(n))) \
24 mprprint(fd, "%U:", pc); \
25 else \
26 return;
27
28 void
29 mprbt(int fd)
30 {
31 ulong pc;
32
33 printpc( 0); printpc( 1); printpc( 2); printpc( 3); printpc( 4);
34 printpc( 5); printpc( 6); printpc( 7); printpc( 8); printpc( 9);
35 printpc(10); printpc(11); printpc(12); printpc(13); printpc(14);
36 printpc(15); printpc(16); printpc(17); printpc(18); printpc(19);
37 printpc(20); printpc(21); printpc(22); printpc(23); printpc(24);
38 printpc(25); printpc(26); printpc(27); printpc(28); printpc(29);
39 printpc(30); printpc(31); printpc(32); printpc(33); printpc(34);
40 printpc(35); printpc(36); printpc(37); printpc(38); printpc(39);
41 }