[libcxx-commits] [PATCH] D109204: [libc++][NFC] Mark values in gdb pretty print comparison functions as live to prevent values being optimized out.

Amy Kwan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 2 16:05:03 PDT 2021


amyk added a comment.

An example of what occurs when we compile and run the test:

  $ clang++ --gcc-toolchain=/usr --target=powerpc64le-unknown-linux-gnu /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp -o /home/amyk/llvm/dev/build/projects/libcxx/test/libcxx/gdb/Output/gdb_pretty_printer_test.sh.cpp.dir/t.tmp.exe -include /home/amyk/llvm/dev/llvm-project/libcxx/test/support/nasty_macros.h -nostdinc++ -I/home/amyk/llvm/dev/build/include/c++/v1 -I/home/amyk/llvm/dev/build/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/home/amyk/llvm/dev/llvm-project/libcxx/test/support -std=c++20 -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined -D_LIBCPP_ABI_VERSION=1  -g -lc++experimental -L/home/amyk/llvm/dev/build/./lib -Wl,-rpath,/home/amyk/llvm/dev/build/./lib -L/home/amyk/llvm/dev/build/./lib -Wl,-rpath,/home/amyk/llvm/dev/build/./lib -nodefaultlibs -lc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc -latomic
  
  $ "/usr/bin/gdb" "-nx" "-batch" "-iex" "set autoload off" "-ex" "source /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/../../../utils/gdb/libcxx/printers.py" "-ex" "python register_libcxx_printer_loader()" "-ex" "source /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py" "/home/amyk/llvm/dev/build/projects/libcxx/test/libcxx/gdb/Output/gdb_pretty_printer_test.sh.cpp.dir/t.tmp.exe"
  No symbol table is loaded.  Use the "file" command.
  Breakpoint 1 at 0x10002968: file llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp, line 67.
  Loading libc++ pretty-printers.
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib64/power9/libthread_db.so.1".
  FAIL: Something is wrong in the test framework.
  value has been optimized out
  FAIL: Something is wrong in the test framework.
  value has been optimized out
  PASS: llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:170
  PASS: llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:174
  PASS: llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:179
  PASS: llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:184
  
  . . . 
  
  PASS: llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:648
  [Inferior 1 (process 708433) exited normally]
  FAILED 82 cases

After adding the `MarkAsLive()` calls:

  $ /usr/bin/gdb -nx -batch -iex "set autoload off" -ex "source /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/../../../utils/gdb/libcxx/printers.py" -ex "python register_libcxx_printer_loader()" -ex "source /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py" /home/amyk/llvm/dev/build/projects/libcxx/test/libcxx/gdb/Output/gdb_pretty_printer_test.sh.cpp.dir/t.tmp.exe
  No symbol table is loaded.  Use the "file" command.
  Breakpoint 1 at 0x10002968: file /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp, line 67.
  Loading libc++ pretty-printers.
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib64/power9/libthread_db.so.1".
  PASS: /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:154
  PASS: /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:158
  
  . . . 
  
  PASS: /home/amyk/llvm/dev/llvm-project/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp:652
  [Inferior 1 (process 2898308) exited normally]
  
  $ echo $?
  0




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109204/new/

https://reviews.llvm.org/D109204



More information about the libcxx-commits mailing list