@@ -363,14 +363,14 @@ std::vector<ulong> PaserPlugin::for_each_vma(ulong& task_addr){
363
363
return vma_list;
364
364
}
365
365
366
- ulonglong PaserPlugin::read_structure_field (ulong kvaddr ,const std::string& type,const std::string& field){
366
+ ulonglong PaserPlugin::read_structure_field (ulong addr ,const std::string& type,const std::string& field, bool virt ){
367
367
int offset = type_offset (type,field);
368
368
int size = type_size (type,field);
369
369
std::string note = type + " _" + field;
370
- ulong addr = kvaddr + offset;
370
+ addr += offset;
371
371
ulonglong result = 0 ;
372
372
void *buf = (void *)GETBUF (size);
373
- if (!readmem (addr, KVADDR, buf, size, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
373
+ if (!readmem (addr, (virt ? KVADDR : PHYSADDR) , buf, size, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
374
374
fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), addr);
375
375
FREEBUF (buf);
376
376
return 0 ;
@@ -395,17 +395,17 @@ ulonglong PaserPlugin::read_structure_field(ulong kvaddr,const std::string& type
395
395
return result;
396
396
}
397
397
398
- std::string PaserPlugin::read_cstring (ulong kvaddr ,int len, const std::string& note){
398
+ std::string PaserPlugin::read_cstring (ulong addr ,int len, const std::string& note, bool virt ){
399
399
char res[len];
400
- if (!readmem (kvaddr, KVADDR, res, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
401
- fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), kvaddr );
400
+ if (!readmem (addr, (virt ? KVADDR : PHYSADDR) , res, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
401
+ fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), addr );
402
402
return nullptr ;
403
403
}
404
404
return std::string (res);
405
405
}
406
406
407
- bool PaserPlugin::read_bool (ulong kvaddr ,const std::string& note){
408
- void *buf = read_memory (kvaddr ,sizeof (bool ),note);
407
+ bool PaserPlugin::read_bool (ulong addr ,const std::string& note, bool virt ){
408
+ void *buf = read_memory (addr ,sizeof (bool ),note,virt );
409
409
if (buf == nullptr ){
410
410
return false ;
411
411
}
@@ -414,8 +414,8 @@ bool PaserPlugin::read_bool(ulong kvaddr,const std::string& note){
414
414
return res;
415
415
}
416
416
417
- int PaserPlugin::read_int (ulong kvaddr ,const std::string& note){
418
- void *buf = read_memory (kvaddr ,sizeof (int ),note);
417
+ int PaserPlugin::read_int (ulong addr ,const std::string& note, bool virt ){
418
+ void *buf = read_memory (addr ,sizeof (int ),note,virt );
419
419
if (buf == nullptr ){
420
420
return 0 ;
421
421
}
@@ -424,8 +424,8 @@ int PaserPlugin::read_int(ulong kvaddr,const std::string& note){
424
424
return res;
425
425
}
426
426
427
- uint PaserPlugin::read_uint (ulong kvaddr ,const std::string& note){
428
- void *buf = read_memory (kvaddr ,sizeof (uint ),note);
427
+ uint PaserPlugin::read_uint (ulong addr ,const std::string& note, bool virt ){
428
+ void *buf = read_memory (addr ,sizeof (uint ),note,virt );
429
429
if (buf == nullptr ){
430
430
return 0 ;
431
431
}
@@ -434,8 +434,8 @@ uint PaserPlugin::read_uint(ulong kvaddr,const std::string& note){
434
434
return res;
435
435
}
436
436
437
- long PaserPlugin::read_long (ulong kvaddr ,const std::string& note){
438
- void *buf = read_memory (kvaddr ,sizeof (long ),note);
437
+ long PaserPlugin::read_long (ulong addr ,const std::string& note, bool virt ){
438
+ void *buf = read_memory (addr ,sizeof (long ),note,virt );
439
439
if (buf == nullptr ){
440
440
return 0 ;
441
441
}
@@ -444,8 +444,8 @@ long PaserPlugin::read_long(ulong kvaddr,const std::string& note){
444
444
return res;
445
445
}
446
446
447
- ulong PaserPlugin::read_ulong (ulong kvaddr ,const std::string& note){
448
- void *buf = read_memory (kvaddr ,sizeof (ulong),note);
447
+ ulong PaserPlugin::read_ulong (ulong addr ,const std::string& note, bool virt ){
448
+ void *buf = read_memory (addr ,sizeof (ulong),note,virt );
449
449
if (buf == nullptr ){
450
450
return 0 ;
451
451
}
@@ -454,8 +454,8 @@ ulong PaserPlugin::read_ulong(ulong kvaddr,const std::string& note){
454
454
return res;
455
455
}
456
456
457
- ulonglong PaserPlugin::read_ulonglong (ulong kvaddr ,const std::string& note){
458
- void *buf = read_memory (kvaddr ,sizeof (ulonglong),note);
457
+ ulonglong PaserPlugin::read_ulonglong (ulong addr ,const std::string& note, bool virt ){
458
+ void *buf = read_memory (addr ,sizeof (ulonglong),note,virt );
459
459
if (buf == nullptr ){
460
460
return 0 ;
461
461
}
@@ -464,8 +464,8 @@ ulonglong PaserPlugin::read_ulonglong(ulong kvaddr,const std::string& note){
464
464
return res;
465
465
}
466
466
467
- ushort PaserPlugin::read_ushort (ulong kvaddr ,const std::string& note){
468
- void *buf = read_memory (kvaddr ,sizeof (ushort ),note);
467
+ ushort PaserPlugin::read_ushort (ulong addr ,const std::string& note, bool virt ){
468
+ void *buf = read_memory (addr ,sizeof (ushort ),note,virt );
469
469
if (buf == nullptr ){
470
470
return 0 ;
471
471
}
@@ -474,8 +474,8 @@ ushort PaserPlugin::read_ushort(ulong kvaddr,const std::string& note){
474
474
return res;
475
475
}
476
476
477
- short PaserPlugin::read_short (ulong kvaddr ,const std::string& note){
478
- void *buf = read_memory (kvaddr ,sizeof (short ),note);
477
+ short PaserPlugin::read_short (ulong addr ,const std::string& note, bool virt ){
478
+ void *buf = read_memory (addr ,sizeof (short ),note,virt );
479
479
if (buf == nullptr ){
480
480
return 0 ;
481
481
}
@@ -484,47 +484,37 @@ short PaserPlugin::read_short(ulong kvaddr,const std::string& note){
484
484
return res;
485
485
}
486
486
487
- void * PaserPlugin::read_memory (ulong kvaddr,int len, const std::string& note){
488
- void * buf = (void *)GETBUF (len);
489
- if (!readmem (kvaddr, KVADDR, buf, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
490
- fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), kvaddr);
491
- FREEBUF (buf);
492
- return nullptr ;
493
- }
494
- return buf;
495
- }
496
-
497
- void * PaserPlugin::read_phys_memory (ulong paddr, int len, const std::string& note){
487
+ void * PaserPlugin::read_memory (ulong addr,int len, const std::string& note, bool virt){
498
488
void * buf = (void *)GETBUF (len);
499
- if (!readmem (paddr, PHYSADDR, buf, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR)) {
500
- fprintf (fp, " Can't read %s at %lx\n " , TO_CONST_STRING (note.c_str ()), paddr );
489
+ if (!readmem (addr, (virt ? KVADDR : PHYSADDR) , buf, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
490
+ fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), addr );
501
491
FREEBUF (buf);
502
492
return nullptr ;
503
493
}
504
494
return buf;
505
495
}
506
496
507
- void * PaserPlugin::read_struct (ulong kvaddr ,const std::string& type){
497
+ void * PaserPlugin::read_struct (ulong addr ,const std::string& type, bool virt ){
508
498
int size = type_size (type);
509
499
void * buf = (void *)GETBUF (size);
510
- if (!readmem (kvaddr, KVADDR, buf, size, TO_CONST_STRING (type.c_str ()), RETURN_ON_ERROR|QUIET)) {
511
- fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (type.c_str ()),kvaddr );
500
+ if (!readmem (addr, (virt ? KVADDR : PHYSADDR) , buf, size, TO_CONST_STRING (type.c_str ()), RETURN_ON_ERROR|QUIET)) {
501
+ fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (type.c_str ()),addr );
512
502
FREEBUF (buf);
513
503
return nullptr ;
514
504
}
515
505
return buf;
516
506
}
517
507
518
- bool PaserPlugin::read_struct (ulong kvaddr ,void * buf, int len, const std::string& note){
519
- if (!readmem (kvaddr, KVADDR, buf, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
520
- fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()),kvaddr );
508
+ bool PaserPlugin::read_struct (ulong addr ,void * buf, int len, const std::string& note, bool virt ){
509
+ if (!readmem (addr, (virt ? KVADDR : PHYSADDR) , buf, len, TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
510
+ fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()),addr );
521
511
return false ;
522
512
}
523
513
return true ;
524
514
}
525
515
526
- ulong PaserPlugin::read_pointer (ulong kvaddr , const std::string& note){
527
- void *buf = read_memory (kvaddr ,sizeof (void *),note);
516
+ ulong PaserPlugin::read_pointer (ulong addr , const std::string& note, bool virt ){
517
+ void *buf = read_memory (addr ,sizeof (void *),note,virt );
528
518
if (buf == nullptr ){
529
519
return 0 ;
530
520
}
@@ -533,10 +523,10 @@ ulong PaserPlugin::read_pointer(ulong kvaddr, const std::string& note){
533
523
return res;
534
524
}
535
525
536
- unsigned char PaserPlugin::read_byte (ulong kvaddr , const std::string& note){
526
+ unsigned char PaserPlugin::read_byte (ulong addr , const std::string& note, bool virt ){
537
527
unsigned char val;
538
- if (!readmem (kvaddr, KVADDR, &val, 1 , TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
539
- fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), kvaddr );
528
+ if (!readmem (addr, (virt ? KVADDR : PHYSADDR) , &val, 1 , TO_CONST_STRING (note.c_str ()), RETURN_ON_ERROR|QUIET)) {
529
+ fprintf (fp, " Can't read %s at %lx\n " ,TO_CONST_STRING (note.c_str ()), addr );
540
530
return -1 ;
541
531
}
542
532
return val;
0 commit comments