Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit ae4b79f

Browse files
author
Pawel Karczewski
committed
Add gdbserver support to ctest
1 parent 2083ad3 commit ae4b79f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [Submitting Pull Requests](#submitting-pull-requests)
66
- [Implementing persistent containers](#implementing-persistent-containers)
77
- [Configuring GitHub fork](#configuring-github-fork)
8+
- [Debugging](#Debugging)
89

910
# Opening New Issues
1011

@@ -148,3 +149,17 @@ To enable automatic images pushing to GitHub Container Registry, following varia
148149
(with only read & write packages permissions), to be generated as described
149150
[here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token#creating-a-token)
150151
for selected account (user defined in above variable).
152+
153+
# Debugging
154+
155+
Test framework supports debugging under gdb.
156+
157+
* For remote debugging set `GDBSERVER` environment variable. Its content will be passed to gdbserver
158+
application as first positional argument, so it should define how gdbserver will communicate with gdb.
159+
Example usage with a single test:
160+
161+
```sh
162+
GDBSERVER=localhost:4444 ctest -R vector_comp_operators_0_none --output-on-failure
163+
```
164+
165+
* For local debugging in graphical environment using cgdb, set `CGDB` environment variable to `gnome-terminal` or `konsole` accordingly to your setup.

tests/helpers.cmake

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ function(execute_common expect_success output_file name)
133133

134134
set(cmd ${TRACE} ${name} ${ARGN})
135135

136-
if($ENV{CGDB})
136+
if(DEFINED ENV{CGDB} AND DEFINED ENV{GDBSERVER})
137+
message(FATAL_ERROR "CGDB and GDBSERVER shouldn't be used at the same time."
138+
"You should choose one way of debugging and probably refill your coffee.")
139+
endif()
140+
141+
if(DEFINED ENV{CGDB})
137142
find_program(KONSOLE NAMES konsole)
138143
find_program(GNOME_TERMINAL NAMES gnome-terminal)
139144
find_program(CGDB NAMES cgdb)
@@ -153,6 +158,18 @@ function(execute_common expect_success output_file name)
153158
endif()
154159
endif()
155160

161+
if(DEFINED ENV{GDBSERVER})
162+
find_program(GDBSERVER NAMES gdbserver)
163+
set(GDBSERVER_SETTINGS $ENV{GDBSERVER})
164+
if (NOT GDBSERVER)
165+
message(FATAL_ERROR "gdbserver not found.")
166+
endif()
167+
if(NOT (${TRACER} STREQUAL none))
168+
message(FATAL_ERROR "Cannot use gdbserver with ${TRACER}")
169+
endif()
170+
set(cmd ${GDBSERVER} ${GDBSERVER_SETTINGS} ${cmd})
171+
endif()
172+
156173
if(${output_file} STREQUAL none)
157174
execute_process(COMMAND ${cmd}
158175
OUTPUT_QUIET

0 commit comments

Comments
 (0)