swap变量交换

swap变量交换

 

 

(lldb) po a

0x00007ffeefbff60c

 

(lldb) po b

0x00007ffeefbff608

 

(lldb) p a

(int *) $2 = 0x00007ffeefbff60c

(lldb) bt

* thread #1, queue = 'com.apple.main-thread', stop reason = step over

  * frame #0: 0x0000000100000f3a 1`swap(a=0x00007ffeefbff60c, b=0x00007ffeefbff608) at main.cpp:8

    frame #1: 0x0000000100000f63 1`main at main.cpp:13

    frame #2: 0x00007fff7018d015 libdyld.dylib`start + 1

(lldb) p b

(int *) $3 = 0x00007ffeefbff608

(lldb) p t

(int) $4 = 3

(lldb) p *a

(int) $5 = 4

(lldb) p *b

(int) $6 = 3

(lldb) up

frame #1: 0x0000000100000f63 1`main at main.cpp:13

   10  {

   11      int a,b;

   12      a = 3, b = 4;

-> 13      [4ms[0mwap(&a,&b);

   14      printf("%d %d\n",a,b);

   15  }

(lldb) p a

(int) $7 = 4

(lldb) p b

(int) $8 = 3

(lldb) p &a

(int *) $9 = 0x00007ffeefbff60c

(lldb) p &b

(int *) $10 = 0x00007ffeefbff608

(lldb) q

Program ended with exit code: 9

上一篇:lldb调试C++总结(3)


下一篇:2021-02-22