summaryrefslogtreecommitdiff
path: root/devel/mprof/files/patch-01
blob: 8fbd8b855975121c7792a9c2d3d07080c64f9746 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
*** ../m/mprof_mon.c	Tue Apr 20 13:36:09 1993
--- mprof_mon.c	Fri Sep 17 17:09:01 1993
***************
*** 411,417 ****
  #ifdef sun
      on_exit(mprof_exit, NULL);
  #endif
! #ifdef mips
      atexit(mprof_exit);
  #endif    
      
--- 411,417 ----
  #ifdef sun
      on_exit(mprof_exit, NULL);
  #endif
! #if defined(mips) || defined(__FreeBSD__)
      atexit(mprof_exit);
  #endif    
      
*** ../m/mprof.h	Tue Apr 20 13:36:07 1993
--- mprof.h	Fri Sep 17 16:53:52 1993
***************
*** 109,115 ****
  
  extern	char	*strdup();
  
! #if (defined(vax) || (defined(sun) && !defined(sun4)))
  #define get_current_fp(first_local) ((unsigned)&(first_local) + 4)
  #endif
  
--- 109,115 ----
  
  extern	char	*strdup();
  
! #if (defined(vax) || (defined(sun) && !defined(sun4))) || defined(__FreeBSD__)
  #define get_current_fp(first_local) ((unsigned)&(first_local) + 4)
  #endif
  
***************
*** 120,126 ****
  #define ret_addr_from_fp(fp)	(unsigned)(((struct frame *)(fp))->fr_savpc)
  #endif
  
!   
  /* for ultrix 0x38, 4.3 bsd 0x3d, other?
  */
    
--- 120,130 ----
  #define ret_addr_from_fp(fp)	(unsigned)(((struct frame *)(fp))->fr_savpc)
  #endif
  
! #if defined(__FreeBSD__)
! #define prev_fp_from_fp(fp)	*((unsigned *) fp)
! #define ret_addr_from_fp(fp)	*((unsigned *) (fp+4))
! #endif
! 
  /* for ultrix 0x38, 4.3 bsd 0x3d, other?
  */
    
***************
*** 134,137 ****
--- 138,145 ----
  
  #ifdef mips
  #define CRT0_ADDRESS		0x0  /* to be filled in later */
+ #endif
+ 
+ #ifdef __FreeBSD__
+ #define CRT0_ADDRESS		0x10d3
  #endif
*** ../m/mpgraph.c	Tue Apr 20 13:36:04 1993
--- mpgraph.c	Wed Sep 15 23:27:07 1993
***************
*** 114,120 ****
      vertex	from, to;
      mpdata	data;
      int		mark;
!     struct edge_struct *save
  } *edge, edge_item;
  
  edge
--- 114,120 ----
      vertex	from, to;
      mpdata	data;
      int		mark;
!     struct edge_struct *save;
  } *edge, edge_item;
  
  edge
*** /dev/null	Tue Nov 22 00:34:22 1994
--- Makefile.i386	Tue Nov 22 01:03:41 1994
***************
*** 0 ****
--- 1,148 ----
+ #	%M% %I% %G% %U%	
+ #	Copyright (c) 1987, Benjamin G. Zorn
+ #
+ # Makefile for MPROF data generation
+ #
+ 
+ CC = cc
+ 
+ # mips 			CFLAGS = -I. -g -DDEBUG
+ # sun4 			CFLAGS = -I. -g -Dsun4
+ # sun3,vax, i386	CFLAGS = -I. -g
+ 
+ # sun4			ASFLAGS = -P -Dsun4
+ # sun3,vax,mips, i386 	ASFLAGS =
+ 
+ CFLAGS = -I. -g -static
+ ASFLAGS =
+ BIN = .
+ MPLIB = $(BIN)/libc_mp.a
+ LINTFLAGS = -bhx
+ 
+ # sun4,mips 		ASM_SRC = md.s
+ # sun4,mips 		ASM_OBJ = md.o
+ # vax,sun3 		ASM_SRC =
+ # vax,sun3 		ASM_OBJ =
+ 
+ ASM_SRC =
+ ASM_OBJ =
+ 
+ MPROF_MON_SRCS = leak.c malloc.c mpattach.c mprof_mon.c mpstruct.c $(ASM_SRC)
+ MPROF_MON_OBJS = leak.o malloc.o mpattach.o mprof_mon.o mpstruct.o $(ASM_OBJ)
+ 
+ MPROF_SRCS = mprof.c mpstruct.c mpgraph.c
+ MPROF_OBJS = mprof.o mpstruct.o mpgraph.o
+ 
+ DOC_SRC = mprof.1
+ DOC_OBJS = mprof.man
+ 
+ DISTNAME = mprof-3.0
+ 
+ TEST_SRCS = test1.c test2.c
+ TEST_OBJS = test1.o test2.o
+ 
+ all: mprof $(MPROF_MON_OBJS) $(DOC_OBJS) $(MPLIB)
+ 
+ mips $(MPLIB): $(MPROF_MON_OBJS)
+ 	ar cr libc_mp.a $(MPROF_MON_OBJS)
+ 	ranlib libc_mp.a
+ 
+ # sun3, sun4		LIB_REPLACE = memalign.o
+ # vax			LIB_REPLACE = exit.o
+ # mips			LIB_REPLACE = 
+ 
+ LIB_REPLACE = exit.o
+ 
+ #$(MPLIB): $(MPROF_MON_OBJS)
+ #	cp /lib/libc.a libc_mp.a
+ #	ar d libc_mp.a malloc.o valloc.o $(LIB_REPLACE)
+ #	ar r libc_mp.a $(MPROF_MON_OBJS)
+ #	ranlib libc_mp.a
+ 
+ test: $(TEST_OBJS) test1-demo test2-demo
+ 
+ mprof-mon-lint:
+ 	lint $(LINTFLAGS) $(MPROF_MON_SRCS) > mprof.lint
+ 
+ mprof-lint:
+ 	lint $(LINTFLAGS) $(MPROF_SRCS) > mprof.lint
+ 
+ clean:
+ 	rm -f *.o mprof.lint mprof-mon.lint \
+ 	$(DOC_OBJS) \
+ 	$(TEST_OBJS) \
+ 	test1 test1.data test1.mprof \
+ 	test2 test2.data test2.mprof \
+ 	libc_mp.a mprof mprof.data
+ 
+ leak.o: leak.c
+ mprof_mon.o: mprof_mon.c
+ mpstruct.o: mpstruct.c
+ mpgraph.o: mpgraph.c
+ mprof.o: mprof.c
+ md.o: md.s
+ 	$(AS) $(ASFLAGS) -o md.o md.s
+ 
+ malloc.o: malloc.c
+ 	$(CC) $(CFLAGS) -Dmalloc=__malloc__ -Dfree=__free__ -Drealloc=__realloc__ malloc.c -c
+ 
+ mprof: $(MPROF_OBJS)
+ 	$(CC) $(CFLAGS) -o mprof $(MPROF_OBJS)
+ 
+ mprof.man: mprof.1
+ 	nroff -man mprof.1 > mprof.man
+ 
+ dist: MANIFEST
+ 	tar cvf $(DISTNAME).tar `cat MANIFEST`
+ 	compress $(DISTNAME).tar
+ 
+ #
+ # Examples to test if MPROF is installed correctly
+ #
+ 
+ # A very simple test (tests calloc and valloc)
+ 
+ test1-demo: test1.data
+ 	$(BIN)/mprof -normal test1 test1.data > test1.mprof
+ 
+ test1.mprof: test1.data
+ 	$(BIN)/mprof -normal test1 test1.data > test1.mprof
+ 
+ test1.data: test1
+ 	test1
+ 	cp mprof.data test1.data
+ 
+ test1: test1.o $(MPLIB)
+ 	$(CC) $(CFLAGS) -o test1 test1.o $(MPLIB)
+ 
+ test1.o: test1.c
+ 
+ 
+ # test2 program (example from paper)
+ 
+ test2-demo: test2.data
+ 	$(BIN)/mprof -normal test2 test2.data > test2.mprof
+ 
+ test2.mprof: test2.data
+ 	$(BIN)/mprof -normal test2 test2.data > test2.mprof
+ 
+ test2.data: test2
+ 	test2
+ 	cp mprof.data test2.data
+ 
+ test2: test2.o $(MPLIB)
+ 	$(CC) $(CFLAGS) -o test2 test2.o $(MPLIB)
+ 
+ test2.o: test2.c
+ 
+ 
+ ###
+ leak.o: /usr/include/stdio.h mprof.h /usr/include/sys/types.h
+ malloc.o: /usr/include/sys/types.h /usr/include/stdio.h
+ mprof.o: /usr/include/stdio.h /usr/include/sys/file.h /usr/include/ctype.h \
+ 	/usr/include/a.out.h /usr/include/sys/exec.h /usr/include/stab.h \
+ 	mprof.h /usr/include/sys/types.h
+ mprof_mon.o: /usr/include/stdio.h /usr/include/sys/file.h mprof.h \
+ 	/usr/include/sys/types.h
+ mpstruct.o: /usr/include/stdio.h mprof.h /usr/include/sys/types.h
+ mpgraph.o: /usr/include/stdio.h mprof.h /usr/include/sys/types.h