microsoft / microsoft/vscode-cpptools

Breakpoints are off when debugging through vscode, but work correctly when run through gdb correctly

Aperta
#11,929 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

debugger Language Service
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and version: Ubuntu 22.04.3 LTS
  • VS Code: 1.86.0 05047486b6df5eb8d44b2ecd70ea3bdf775fd937 x64
  • C/C++ extension: gcc 11.4.0, c++20
  • GDB / LLDB version: GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Bug Summary and Steps to Reproduce

Bug Summary:

Break point doesn't line up with where I added it.
image

My theory is that it is caused by this from the output logs


Breakpoint 2, cdrc::internal::memory_manager_base<int, cdrc::internal::acquire_retire<int, 7ul, 2ul> >::retire (type=cdrc::internal::RetireType::decrement_weak_count, ptr=0x555555600160, this=0x5555555e8360 <cdrc::internal::acquire_retire<int, 7ul, 2ul>::instance()::ar>) at /tmp/concurrent_deferred_rc/include/cdrc/internal/smr/../memory_manager_base.h:84

For some reason the break point on line 79 is being comunicated as the retire function to gdb through the vscode ui (I think).

Thanks in advance.

Reproduction:

git clone https://github.com/thetazero/concurrent_deferred_rc
cd concurrent_deferred_rc/
git checkout sticky_counter_experiment
mkdir build
cd build
cmake .. -DCDRC_TEST=On -DBUILD_ASANZ_TESTS=On
cmake --build .
code ..

Then placing a break point on 79 of include/cdrc/internal/memory_manager_base.h.
Then launching the TestWeakPtrsMini.bug-nosan test via the testing window in debug mode causes it to break twice on line 84 of memory_manager_base.h, the "retire" function. Rather than the intended "destroy" function.

However, if we do the same with gdb via

cd build/test/
gdb test_weak_ptr_mini-nosan 

Add the breakpoint with break memory_manager_base::destroy
Then run
Via backtrace we can see it correctly break on the right line number, and it only breaks once before the assertion failure (as expected).

Debugger Configurations
`launch.json`

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(ctest) Launch",
            "type": "cppdbg",
            "request": "launch",
            // Resolved by CMake Tools:
            "cwd": "${cmake.testWorkingDirectory}",
            "program": "${cmake.testProgram}",
            "args": [
                "${cmake.testArgs}"
            ],
        }
    ],
    "logging": {
        "engineLogging": true
    }
}

no test.json



### Debugger Logs

```shell
DEBUG_CONSOLE logs

=thread-group-added,id="i1"
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 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-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"

Stopped due to shared library event (no libraries added or removed)
Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".


Breakpoint 1, main (argc=3, argv=0x7fffffffdd58) at /tmp/concurrent_deferred_rc/build/_deps/googletest-src/googletest/src/gtest_main.cc:62
62	  printf("Running main() from %s\n", __FILE__);
Loaded '/lib/x86_64-linux-gnu/libstdc++.so.6'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libm.so.6'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libgcc_s.so.1'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libc.so.6'. Symbols loaded.

Breakpoint 2, cdrc::internal::memory_manager_base<int, cdrc::internal::acquire_retire<int, 7ul, 2ul> >::retire (type=cdrc::internal::RetireType::decrement_weak_count, ptr=0x555555600160, this=0x5555555e8360 <cdrc::internal::acquire_retire<int, 7ul, 2ul>::instance()::ar>) at /tmp/concurrent_deferred_rc/include/cdrc/internal/smr/../memory_manager_base.h:84
84	  void retire(counted_ptr_t ptr, RetireType type) {
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)

OUTPUT logs

[proc] Executing command: cmake --version
[proc] Executing command: cmake -E capabilities
[variant] Loaded new set of variants
[kit] Successfully loaded 1 kits from /home/thetazero/.local/share/CMakeTools/cmake-tools-kits.json
[proc] Executing command: /usr/bin/cmake --version
[proc] Executing command: /usr/bin/cmake -E capabilities
[proc] Executing command: /usr/bin/gcc -v
[proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT
[proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT
[main] Configuring project: concurrent_deferred_rc 
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -Dgtest_build_samples:STRING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/tmp/concurrent_deferred_rc -B/tmp/concurrent_deferred_rc/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- CDRC VERSION 0.2.0
[cmake] -- ---------------------------- General configuration -----------------------------
[cmake] -- CMake Generator:                Unix Makefiles
[cmake] -- Compiler:                       GNU 11.4.0
[cmake] -- Build type:                     Debug
[cmake] -- CMAKE_CXX_FLAGS:                
[cmake] -- CMAKE_CXX_FLAGS_DEBUG:          -g
[cmake] -- CMAKE_CXX_FLAGS_RELEASE:        -O3 -DNDEBUG
[cmake] -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O2 -g -DNDEBUG -fno-omit-frame-pointer
[cmake] -- CMAKE_EXE_LINKER_FLAGS          
[cmake] -- CMAKE_INSTALL_PREFIX:           /usr/local
[cmake] -- ---------------------------------- Unit Tests ----------------------------------
[cmake] -- testing: Configuring GoogleTest
[cmake] -- testing: Enabled
[cmake] -- Warning: Sanitizer blacklists are not supported by the compiler. False positives may be encountered.
[cmake] -- AddressSanitizer:             Enabled
[cmake] -- UndefinedBehaviourSanitizer:  Disabled (Enable with -DBUILD_UBSAN_TESTS=On)
[cmake] -- ThreadSanitizer:              Disabled (Enable with -DBUILD_TSAN_TESTS=On)
[cmake] -- MemorySanitizer:              Disabled (Enable with -DBUILD_MSAN_TESTS=On)
[cmake] -- memcheck:                     Disabled (Enable with -DENABLE_MEMCHECK_TESTS)
[cmake] -- ---------------------------------- Benchmarks ----------------------------------
[cmake] -- benchmarks: Disabled (enable with -DCDRC_BENCHMARK=On)
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /tmp/concurrent_deferred_rc/build
[main] Building folder: concurrent_deferred_rc 
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /tmp/concurrent_deferred_rc/build --config Debug --target all -j 22 --
[build] Consolidate compiler generated dependencies of target gtest
[build] [  5%] Built target gtest
[build] Consolidate compiler generated dependencies of target gtest_main
[build] [ 11%] Built target gtest_main
[build] Consolidate compiler generated dependencies of target test_weak_ptrs-nosan
[build] Consolidate compiler generated dependencies of target test_example_linked_list-asan
[build] Consolidate compiler generated dependencies of target test_benchmark_queue-asan
[build] Consolidate compiler generated dependencies of target test_benchmark_queue-nosan
[build] Consolidate compiler generated dependencies of target test_benchmark_stack-asan
[build] Consolidate compiler generated dependencies of target test_example_linked_list-nosan
[build] Consolidate compiler generated dependencies of target test_benchmark_stack-nosan
[build] Consolidate compiler generated dependencies of target test_example_stack-nosan
[build] Consolidate compiler generated dependencies of target test_weak_ptrs-asan
[build] Consolidate compiler generated dependencies of target test_example_stack-asan
[build] Consolidate compiler generated dependencies of target test_bug-asan
[build] Consolidate compiler generated dependencies of target test_sticky_counter-asan
[build] Consolidate compiler generated dependencies of target test_bug-nosan
[build] Consolidate compiler generated dependencies of target test_sticky_counter-nosan
[build] Consolidate compiler generated dependencies of target test_weak_ptr_mini-asan
[build] Consolidate compiler generated dependencies of target test_weak_ptr_mini-nosan
[build] [ 16%] Built target test_benchmark_stack-nosan
[build] [ 22%] Built target test_benchmark_queue-nosan
[build] [ 27%] Built target test_bug-asan
[build] [ 38%] Built target test_benchmark_stack-asan
[build] [ 38%] Built target test_example_linked_list-asan
[build] [ 44%] Built target test_benchmark_queue-asan
[build] [ 50%] Built target test_example_stack-nosan
[build] [ 55%] Built target test_bug-nosan
[build] [ 61%] Built target test_sticky_counter-asan
[build] [ 66%] Built target test_weak_ptrs-asan
[build] [ 72%] Built target test_example_stack-asan
[build] [ 80%] Built target test_example_linked_list-nosan
[build] [ 83%] Built target test_weak_ptrs-nosan
[build] [ 88%] Built target test_sticky_counter-nosan
[build] [ 94%] Built target test_weak_ptr_mini-asan
[build] [100%] Built target test_weak_ptr_mini-nosan
[driver] Build completed: 00:00:00.178
[build] Build finished with exit code 0
[ctest] debugSessionTerminated

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il comportamento usando i comandi nell’issue, quindi esamina la gestione dei breakpoint per la sessione di debug C++ configurata in launch.json. Usa include/cdrc/internal/memory_manager_base.h e test_weak_ptr_mini-nosan come caso di riferimento; il lavoro è completato quando un breakpoint posizionato alla riga 79 si arresta nella funzione destroy prevista invece che in retire alla riga 84, in linea con il comportamento diretto di GDB.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cmake, cpp, typescript, vscode
Ambito
developer-experience, devtools, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.