即使在逻辑上对两个错误条件进行逻辑运算后,断点处的GDB复杂条件也变为true

rah*_*til 5 gdb

如果有条件的条件断点

  (gdb) b handle.cpp:66 if ( (sn == 6092 && !strcmp(_name.c_str(),"HSI_IDX_DEF")) || (sn == 1251 && !strcmp(_name.c_str(),"SP_IDX_DEF")))
Run Code Online (Sandbox Code Playgroud)

它每次都会命中,因为即使对两个错误的子条件进行运算后,复杂的条件也会每次都变为真。

(gdb) p  ( (sn == 6092 && !strcmp(_name.c_str(),"HSI_IDX_DEF")) || (sn == 1251 && !strcmp(_name.c_str(),"SP_IDX_DEF")))
    $10 = true
    (gdb) p (sn == 6092 && !strcmp(_name.c_str(),"HSI_IDX_DEF"))
    $11 = false
    (gdb) p  (sn == 1251 && !strcmp(_name.c_str(),"SP_IDX_DEF"))
    $12 = false
Run Code Online (Sandbox Code Playgroud)

我的发行

Linux lab-exchangeIn 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

gdb版本

 GNU gdb (GDB) Red Hat Enterprise Linux (7.2-56.el6)
    Copyright (C) 2010 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-redhat-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>
Run Code Online (Sandbox Code Playgroud)

gcc版本:

Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
Run Code Online (Sandbox Code Playgroud)