@@ -243,8 +243,6 @@ int vmp_resolve_addr(void * addr, char * name, int name_len, int * lineno, char
243243 return 0 ;
244244}
245245
246- #ifdef RPYTHON_VMPROF
247-
248246#define WORD_SIZE sizeof(long)
249247#define ADDR_SIZE sizeof(void*)
250248#define MAXLEN 1024
@@ -254,10 +252,12 @@ void _dump_native_symbol(int fileno, void * addr, char * sym, int linenumber, ch
254252 off_t pos_before ;
255253 struct str {
256254 void * addr ;
257- // NOTE windows 64, not supported yet
255+ // NOTE windows, not supported yet would be a problem for 64 bit
256+ // hint: alignment
258257 long size ;
259258 char str [1024 ];
260259 } s ;
260+ fsync (fileno );
261261 pos_before = lseek (fileno , 0 , SEEK_CUR );
262262 lseek (fileno , 0 , SEEK_END );
263263
@@ -286,7 +286,7 @@ int _skip_string(int fileno)
286286{
287287 long chars ;
288288 int count = read (fileno , & chars , sizeof (long ));
289- LOG ("reading string of %d chars\n" , chars );
289+ // LOG("reading string of %d chars\n", chars);
290290 if (count <= 0 ) {
291291 return 1 ;
292292 }
@@ -309,14 +309,14 @@ int _skip_header(int fileno, int * version, int * flags)
309309long _read_word (int fileno )
310310{
311311 long w ;
312- read (fileno , & w , WORD_SIZE );
312+ ( void ) read (fileno , & w , WORD_SIZE );
313313 return w ;
314314}
315315
316316void * _read_addr (int fileno )
317317{
318318 void * a ;
319- read (fileno , & a , ADDR_SIZE );
319+ ( void ) read (fileno , & a , ADDR_SIZE );
320320 return a ;
321321}
322322
@@ -341,21 +341,19 @@ int _skip_time_and_zone(int fileno)
341341
342342void dump_native_symbols (int fileno )
343343{
344- // only call this function
345344 off_t orig_pos , cur_pos ;
346345 char marker ;
347346 ssize_t count ;
348347 int version ;
349348 int flags ;
350349 int memory = 0 , lines = 0 , native = 0 ;
350+ fsync (fileno );
351351 orig_pos = lseek (fileno , 0 , SEEK_CUR );
352352
353353 lseek (fileno , 5 * WORD_SIZE , SEEK_SET );
354354
355355 while (1 ) {
356- LOG ("pre read\n" );
357356 count = read (fileno , & marker , 1 );
358- LOG ("post read\n" );
359357 if (count <= 0 ) {
360358 break ;
361359 }
@@ -383,7 +381,7 @@ void dump_native_symbols(int fileno)
383381 break ;
384382 } case MARKER_VIRTUAL_IP :
385383 case MARKER_NATIVE_SYMBOLS : {
386- LOG ("virtip 0x%llx\n" , cur_pos );
384+ // LOG("virtip 0x%llx\n", cur_pos);
387385 if (_skip_addr (fileno ) != 0 ) { return ; }
388386 if (_skip_string (fileno ) != 0 ) { return ; }
389387 break ;
@@ -394,10 +392,16 @@ void dump_native_symbols(int fileno)
394392
395393 LOG ("stack 0x%llx %d %d\n" , cur_pos , trace_count , depth );
396394
395+ #ifdef RPYTHON_VMPROF
397396 for (i = depth /2 - 1 ; i >= 0 ; i -- ) {
398397 long kind = (long )_read_addr (fileno );
399398 void * addr = _read_addr (fileno );
400399 if (kind == VMPROF_NATIVE_TAG ) {
400+ #else
401+ for (i = 0 ; i < depth ; i ++ ) {
402+ void * addr = _read_addr (fileno );
403+ if (((intptr_t )addr & 0x1 ) == 1 ) {
404+ #endif
401405 LOG ("found kind %p\n" , addr );
402406 char name [MAXLEN ];
403407 char srcfile [MAXLEN ];
@@ -412,14 +416,17 @@ void dump_native_symbols(int fileno)
412416 }
413417 LOG ("passed memory %d \n" , memory );
414418
415- if (_skip_addr (fileno ) != 0 ) { return ; } // thread id
419+ if (version >= VERSION_THREAD_ID ) {
420+ if (_skip_addr (fileno ) != 0 ) { return ; } // thread id
421+ }
416422 if (memory ) {
417423 if (_skip_addr (fileno ) != 0 ) { return ; } // profile memory
418424 }
419425
420426 break ;
421427 } default : {
422428 fprintf (stderr , "unknown marker 0x%x\n" , marker );
429+ lseek (fileno , 0 , SEEK_END );
423430 return ;
424431 }
425432 }
@@ -432,4 +439,3 @@ void dump_native_symbols(int fileno)
432439
433440 lseek (fileno , 0 , SEEK_END );
434441}
435- #endif
0 commit comments