gdb 通过指针查看/修改结构体信息

 

#include

struct dayint{
 int a;
 int b;
};

struct day{
 struct dayint day1;
 int day2;
 int day3;
};

struct day gudday;
int bb =2;
int main()
{
  gudday.day2=2;
  while(1){
// printf("qwqww\n");
  };
  bb =3;
}

 

 

(gdb) print &gudday

$8 = (struct day *) 0x601040 

(gdb) print gudday

$9 = {

  day1 = {

    a = 0,

    b = 0

  },

  day2 = 2,

  day3 = 0

}

(gdb) print *(struct day *) 0x601040

$10 = {

  day1 = {

    a = 0,

    b = 0

  },

  day2 = 2,

  day3 = 0

}

(gdb) print *(struct dayint *) 0x601040

$11 = {

  a = 0,

  b = 0

}



(gdb) print ((struct dayint *) 0x601040)->a=23

$12 = 23

(gdb) print *(struct dayint *) 0x601040

$13 = {

  a = 23,

  b = 0

}

 

你可能感兴趣的:(笔记,gdb)