Skip to content

Commit 4960e09

Browse files
committed
Merge remote-tracking branch 'origin/master' into vs_build
2 parents 4096876 + 727665f commit 4960e09

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

idadbg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
33
IDA trace: PIN tool to communicate with IDA's debugger
4-
Last supported linux version: 3.23-98579
5-
Last supported windows version: 3.23-98579
4+
Last supported linux version: 3.27-98718
5+
Last supported windows version: 3.24-98612
66
77
*/
88

@@ -1302,10 +1302,10 @@ static bool accept_conn()
13021302
return false;
13031303
}
13041304
pin_client_version = req_v1.size;
1305-
if ( pin_client_version == 1 )
1305+
if ( pin_client_version < 9 )
13061306
{
13071307
// version 1 (incompatible) client - send v1 packet answer and exit
1308-
MSG("Incompatible client (version 1) - disconnect\n");
1308+
MSG("Incompatible client version %d (9 or higher is expected) - disconnect\n", pin_client_version);
13091309
req_v1.size = PIN_PROTOCOL_VERSION;
13101310
req_v1.data = sizeof(ADDRINT);
13111311
req_v1.code = PTT_ACK;

idadbg.h

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <vector>
1010
#include <string.h>
1111

12-
using namespace std;
13-
1412
typedef unsigned int uint32;
1513
typedef unsigned char uchar;
1614

@@ -24,7 +22,10 @@ typedef unsigned char uchar;
2422
// 7 - PTT_READ_SYMBOLS packet 2..7
2523
// 8 - renumbered PROCESS_ATTACHED, PROCESS_DETACHED, 2..8
2624
// PROCESS_SUSPENDED, TRACE_FULL
27-
#define PIN_PROTOCOL_VERSION 8
25+
// 9 - modified pin_regid_t so that now it is the same for 9
26+
// both 32-bit and 64-bit pintools. We need this to
27+
// support debugging of 32bit apps by ida64
28+
#define PIN_PROTOCOL_VERSION 9
2829

2930
#ifdef IDA_SDK_VERSION
3031
// IDA specific declarations
@@ -57,6 +58,8 @@ typedef unsigned char uchar;
5758
# define qvector std::vector
5859
# define qstring std::string
5960

61+
using namespace std;
62+
6063
#if defined(_MSC_VER)
6164
typedef unsigned __int64 uint64;
6265
typedef __int64 int64;
@@ -438,7 +441,6 @@ enum pin_regid_t
438441
PINREG_EIP,
439442
PINREG_EFLAGS,
440443
PINREG_LAST_REG32 = PINREG_EFLAGS,
441-
#ifdef PIN_64
442444
PINREG64_R8,
443445
PINREG64_R9,
444446
PINREG64_R10,
@@ -447,13 +449,7 @@ enum pin_regid_t
447449
PINREG64_R13,
448450
PINREG64_R14,
449451
PINREG64_R15,
450-
PINREG_LAST_GPREG = PINREG64_R15,
451-
#else
452-
PINREG_LAST_GPREG = PINREG_LAST_REG32,
453-
#endif
454-
PINREG_LAST_INTREG = PINREG_LAST_GPREG,
455-
// mmx registers
456-
PINREG_LAST_REG64 = PINREG_LAST_INTREG,
452+
457453
// FPU registers
458454
PINREG_FIRST_REG128,
459455
PINREG_FIRST_FPREG = PINREG_FIRST_REG128,
@@ -469,6 +465,7 @@ enum pin_regid_t
469465
PINREG_STAT,
470466
PINREG_TAGS,
471467
PINREG_LAST_FPREG = PINREG_TAGS,
468+
472469
// xmm registers
473470
PINREG_FIRST_XMMREG,
474471
PINREG_MXCSR = PINREG_FIRST_XMMREG,
@@ -480,7 +477,6 @@ enum pin_regid_t
480477
PINREG_XMM5,
481478
PINREG_XMM6,
482479
PINREG_XMM7,
483-
#ifdef PIN_64
484480
PINREG_XMM8,
485481
PINREG_XMM9,
486482
PINREG_XMM10,
@@ -489,11 +485,7 @@ enum pin_regid_t
489485
PINREG_XMM13,
490486
PINREG_XMM14,
491487
PINREG_XMM15,
492-
PINREG_LAST_XMMREG = PINREG_XMM15,
493-
#else
494-
PINREG_LAST_XMMREG = PINREG_XMM7,
495-
#endif
496-
PINREG_LAST_REG128 = PINREG_LAST_XMMREG,
488+
PINREG_LAST_REG128 = PINREG_XMM15,
497489

498490
// MMX registers: used only for write_registers()
499491
PINREG_MMX0,
@@ -516,9 +508,6 @@ enum pin_regid_t
516508
PINREG_YMM5,
517509
PINREG_YMM6,
518510
PINREG_YMM7,
519-
#ifndef PIN_64
520-
PINREG_LAST_YMMREG = PINREG_YMM7,
521-
#else
522511
PINREG_YMM8,
523512
PINREG_YMM9,
524513
PINREG_YMM10,
@@ -527,8 +516,17 @@ enum pin_regid_t
527516
PINREG_YMM13,
528517
PINREG_YMM14,
529518
PINREG_YMM15,
519+
#ifdef PIN_64
520+
PINREG_LAST_GPREG = PINREG64_R15,
521+
PINREG_LAST_XMMREG = PINREG_XMM15,
530522
PINREG_LAST_YMMREG = PINREG_YMM15,
523+
#else
524+
PINREG_LAST_GPREG = PINREG_LAST_REG32,
525+
PINREG_LAST_XMMREG = PINREG_XMM7,
526+
PINREG_LAST_YMMREG = PINREG_YMM7,
531527
#endif
528+
PINREG_LAST_INTREG = PINREG_LAST_GPREG,
529+
PINREG_LAST_REG64 = PINREG_LAST_INTREG,
532530
PINREG_LAST_REG256 = PINREG_LAST_YMMREG,
533531

534532
PINREG_MAX
@@ -671,7 +669,7 @@ inline bool pin_classregs_t::init(pin_register_class_t cls, bool is_32bit)
671669
break;
672670
case PIN_RC_YMM:
673671
firstnum = PINREG_FIRST_YMMREG;
674-
lastnum = PINREG_LAST_YMMREG;
672+
lastnum = is_32bit ? PINREG_YMM7 : PINREG_LAST_YMMREG; //-V547 'is_32bit' is always true
675673
break;
676674
default:
677675
return false; // bad class
@@ -695,31 +693,31 @@ inline bool pin_classregs_t::init(pin_regid_t firstnum, pin_regid_t lastnum)
695693
class pin_regbuf_t
696694
{
697695
public:
698-
pin_regbuf_t(int clsmask, bool is_32bit = false)
699-
: ncls(0), bufsize(0) { init(clsmask, is_32bit); }
700-
size_t get_bufsize() const { return bufsize; }
701-
inline int nclasses() const { return ncls; }
702-
pin_classregs_t *get_class(int i) { return &clregs[i]; }
703-
const pin_classregs_t *get_class(int i) const { return &clregs[i]; }
704-
pin_register_class_t get_classid(int i) const { return classes[i]; }
696+
pin_regbuf_t(int clsmask, bool is_32bit = false);
697+
size_t get_bufsize() const { return bufsize; }
698+
inline int nclasses() const { return ncls; }
699+
pin_classregs_t *get_class(int i) { return &clregs[i]; }
700+
const pin_classregs_t *get_class(int i) const { return &clregs[i]; }
701+
pin_register_class_t get_classid(int i) const { return classes[i]; }
705702
inline void setbuf(char *buf);
706703

707704
private:
708-
int ncls;
709-
size_t bufsize;
705+
int ncls = 0;
706+
size_t bufsize = 0;
710707
pin_register_class_t classes[PIN_RC_NCLASSES];
711708
pin_classregs_t clregs[PIN_RC_NCLASSES];
712709
void init(int clsmask, bool is_32bit = false);
713710
};
714711

715712
//--------------------------------------------------------------------------
716-
inline void pin_regbuf_t::init(int clsmask, bool is_32bit)
713+
inline pin_regbuf_t::pin_regbuf_t(int clsmask, bool is_32bit)
717714
{
718715
#ifndef PIN_64
719716
is_32bit = true;
720717
#endif
721-
static pin_register_class_t all_cls[] =
718+
static const pin_register_class_t all_cls[] =
722719
{ PIN_RC_GENERAL, PIN_RC_SEGMENTS, PIN_RC_FPU, PIN_RC_XMM, PIN_RC_YMM };
720+
memset(classes, 0, sizeof(classes));
723721
for ( size_t i = 0; i < sizeof(all_cls) / sizeof(all_cls[0]); ++i )
724722
{
725723
if ( (clsmask & all_cls[i]) != 0 )
@@ -818,6 +816,12 @@ struct idapin_segbase_packet_t: idapin_packet_t
818816
void set_value(int val) { data = val; }
819817
};
820818

819+
#ifdef _WIN32
820+
#define USE_PIN_STLPORT (PIN_BUILD_NUMBER >= 76991)
821+
#else
822+
#define USE_PIN_STLPORT (PIN_BUILD_NUMBER >= 76991 && PIN_BUILD_NUMBER < 98612)
823+
#endif
824+
821825
//--------------------------------------------------------------------------
822826
// symbol address & name in serialized buffer
823827
struct pin_symdef_t
@@ -829,7 +833,7 @@ struct pin_symdef_t
829833
const unsigned char *name() const { return buf() + sizeof(uint64); }
830834
unsigned char *name() { return buf() + sizeof(uint64); }
831835
// PIN's stlport does not have data()
832-
#if defined(IDA_SDK_VERSION) || (PIN_BUILD_NUMBER >= 76991 && defined(TARGET_WINDOWS))
836+
#if defined(IDA_SDK_VERSION) || USE_PIN_STLPORT
833837
const unsigned char *buf() const { return array.begin(); }
834838
unsigned char *buf() { return array.begin(); }
835839
#else

0 commit comments

Comments
 (0)