版权声明:原创博客转载前请私信或评论,一天之内回复。 https://blog.csdn.net/qq_42381849/article/details/91060418
GlobalObject
exit()
调试代码:
(gdb) l
20 {
21 printf("GlobalObject:~GlobalObject() \n");
22 MutexLockGuard lock(mutex_);
23 printf("GlobalObject:~GlobalObject() cleanning\n");
24 }
25
26 private:
27 MutexLock mutex_;
28 };
29
(gdb) l
30 GlobalObject g_obj;
31
32 int main()
33 {
34 g_obj.doit();
35 }(gdb)
Line number 36 out of range; exit.cpp has 35 lines.
(gdb) b main
Breakpoint 1 at 0x98c: file exit.cpp, line 34.
(gdb) r
Starting program: /root/study/chapter-4/exit
Breakpoint 1, main () at exit.cpp:34
34 g_obj.doit();
(gdb) b 21
Breakpoint 2 at 0x555555554bb3: file exit.cpp, line 21.
(gdb) b 23
Breakpoint 3 at 0x555555554bd2: file exit.cpp, line 23.
(gdb) l
29
30 GlobalObject g_obj;
31
32 int main()
33 {
34 g_obj.doit();
35 }(gdb)
Line number 36 out of range; exit.cpp has 35 lines.
(gdb) s
GlobalObject::doit (this=0x555555756040 <g_obj>) at exit.cpp:13
13 void doit()
(gdb) s
15 MutexLockGuard lock(mutex_);
(gdb) p mutex
No symbol "mutex" in current context.
(gdb) p mutex_
$1 = {<noncopyable> = {<No data fields>}, mutex_ = {__data = {__lock = 0, __count = 0, __owner = 0, __
__size = '\000' <repeats 39 times>, __align = 0}, holder_ = 0}
(gdb) s
MutexLockGuard::MutexLockGuard (this=0x7fffffffe4a0, mutex=...) at mutex.h:41
41 : mutex_(mutex)
(gdb) s
noncopyable::noncopyable (this=0x7fffffffe4a0) at noncopyable.h:6
6 noncopyable() {}
(gdb) s
MutexLockGuard::MutexLockGuard (this=0x7fffffffe4a0, mutex=...) at mutex.h:42
42 { mutex_.lock(); }
(gdb) s
MutexLock::lock (this=0x555555756040 <g_obj>) at mutex.h:22
22 pthread_mutex_lock(&mutex_);
(gdb) s
pthread_mutex_lock (mutex=0x555555756040 <g_obj>) at forward.c:192
192 forward.c: No such file or directory.
(gdb) s
MutexLock::lock (this=0x555555756040 <g_obj>) at mutex.h:24
24 }
(gdb) s
GlobalObject::doit (this=0x555555756040 <g_obj>) at exit.cpp:16
16 someFunctionMayCallExit();
(gdb) s
someFunctionMayCallExit () at exit.cpp:7
7 exit(1);
(gdb) p errno
$2 = 0
(gdb) s
__GI_exit (status=1) at exit.c:139
139 exit.c: No such file or directory.
(gdb) p errno
$3 = 0
(gdb) s
138 in exit.c
(gdb) s
139 in exit.c
(gdb) bt
#0 __GI_exit (status=1) at exit.c:139
#1 0x0000555555554988 in someFunctionMayCallExit () at exit.cpp:7
#2 0x0000555555554b75 in GlobalObject::doit (this=0x555555756040 <g_obj>) at exit.cpp:16
#3 0x0000555555554998 in main () at exit.cpp:34
(gdb) p mutex_
No symbol "mutex_" in current context.
(gdb) s
__run_exit_handlers (status=1, listp=0x7ffff7a46718 <__exit_funcs>, run_list_atexit=run_list_atexit@en
40 in exit.c
(gdb) p errno
$4 = 0
(gdb) p AccountA_mutex
No symbol "AccountA_mutex" in current context.
(gdb) info threads
Id Target Id Frame
* 1 process 1039 "exit" __run_exit_handlers (status=1, listp=0x7ffff7a46718 <__exit_funcs>,
run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:40
(gdb) pstack 1039
Undefined command: "pstack". Try "help".
(gdb) quit