@@ -148,10 +148,6 @@ int my_addr_resolve(void *ptr, my_addr_loc *loc)
148
148
char input [32 ];
149
149
size_t len ;
150
150
151
- len = my_snprintf (input , sizeof (input ), "%p\n" , ptr - offset );
152
- if (write (in [1 ], input , len ) <= 0 )
153
- return 1 ;
154
-
155
151
ssize_t total_bytes_read = 0 ;
156
152
ssize_t extra_bytes_read = 0 ;
157
153
@@ -160,6 +156,14 @@ int my_addr_resolve(void *ptr, my_addr_loc *loc)
160
156
FD_ZERO (& set );
161
157
FD_SET (out [0 ], & set );
162
158
159
+ int filename_start = -1 ;
160
+ int line_number_start = -1 ;
161
+ ssize_t i ;
162
+
163
+ len = my_snprintf (input , sizeof (input ), "%p\n" , ptr - offset );
164
+ if (write (in [1 ], input , len ) <= 0 )
165
+ return 1 ;
166
+
163
167
/* 10 ms should be plenty of time for addr2line to issue a response. */
164
168
timeout .tv_sec = 0 ;
165
169
timeout .tv_usec = 10000 ;
@@ -177,12 +181,10 @@ int my_addr_resolve(void *ptr, my_addr_loc *loc)
177
181
if (total_bytes_read == 0 )
178
182
return 1 ;
179
183
180
- int filename_start = -1 ;
181
- int line_number_start = -1 ;
182
184
/* Go through the addr2line response and get the required data.
183
185
The response is structured in 2 lnes. The first line contains the function
184
186
name, while the second one contains <filename>:<line number> */
185
- for (ssize_t i = 0 ; i < total_bytes_read ; i ++ ) {
187
+ for (i = 0 ; i < total_bytes_read ; i ++ ) {
186
188
if (output [i ] == '\n' ) {
187
189
filename_start = i + 1 ;
188
190
output [i ] = '\0' ;
0 commit comments