@@ -282,13 +282,21 @@ static struct perf_event_attr *dlfilter__attr(void *ctx)
282
282
return & d -> evsel -> core .attr ;
283
283
}
284
284
285
+ static __s32 code_read (__u64 ip , struct map * map , struct machine * machine , void * buf , __u32 len )
286
+ {
287
+ u64 offset = map__map_ip (map , ip );
288
+
289
+ if (ip + len >= map__end (map ))
290
+ len = map__end (map ) - ip ;
291
+
292
+ return dso__data_read_offset (map__dso (map ), machine , offset , buf , len );
293
+ }
294
+
285
295
static __s32 dlfilter__object_code (void * ctx , __u64 ip , void * buf , __u32 len )
286
296
{
287
297
struct dlfilter * d = (struct dlfilter * )ctx ;
288
298
struct addr_location * al ;
289
299
struct addr_location a ;
290
- struct map * map ;
291
- u64 offset ;
292
300
__s32 ret ;
293
301
294
302
if (!d -> ctx_valid )
@@ -298,27 +306,17 @@ static __s32 dlfilter__object_code(void *ctx, __u64 ip, void *buf, __u32 len)
298
306
if (!al )
299
307
return -1 ;
300
308
301
- map = al -> map ;
302
-
303
- if (map && ip >= map__start (map ) && ip < map__end (map ) &&
309
+ if (al -> map && ip >= map__start (al -> map ) && ip < map__end (al -> map ) &&
304
310
machine__kernel_ip (d -> machine , ip ) == machine__kernel_ip (d -> machine , d -> sample -> ip ))
305
- goto have_map ;
311
+ return code_read ( ip , al -> map , d -> machine , buf , len ) ;
306
312
307
313
addr_location__init (& a );
314
+
308
315
thread__find_map_fb (al -> thread , d -> sample -> cpumode , ip , & a );
309
- if (!a .map ) {
310
- ret = -1 ;
311
- goto out ;
312
- }
316
+ ret = a .map ? code_read (ip , a .map , d -> machine , buf , len ) : -1 ;
313
317
314
- map = a .map ;
315
- have_map :
316
- offset = map__map_ip (map , ip );
317
- if (ip + len >= map__end (map ))
318
- len = map__end (map ) - ip ;
319
- ret = dso__data_read_offset (map__dso (map ), d -> machine , offset , buf , len );
320
- out :
321
318
addr_location__exit (& a );
319
+
322
320
return ret ;
323
321
}
324
322
0 commit comments