Compare commits

...

2 commits

Author SHA1 Message Date
Denis
2ca8e9ada3
let me try a little something... 2023-12-13 14:40:11 +01:00
Denis
70023cb48f
Debugging instructions 2023-12-13 14:34:17 +01:00
4 changed files with 49 additions and 4 deletions

2
ipc.h
View file

@ -40,4 +40,4 @@ typedef struct ipc {
} ipc_t;
#define SERVER_PATH "/tmp/rogue-enemy.sock"
#define SERVER_PATH "/home/rogue-enemy.sock"

31
notes/launch.json Normal file
View file

@ -0,0 +1,31 @@
{
// 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/allynone",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"miDebuggerPath": "/home/gamer/gdb",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

13
notes/vscode_debug.md Normal file
View file

@ -0,0 +1,13 @@
# Debug sudo application with vscode
1. create /home/gamer/gdb with following content:
```
sudo /usr/bin/gdb "$@"
```
2. add this line to /etc/sudoers
```
gamer ALL=(ALL) NOPASSWD:/usr/bin/gdb
```
then copy the launch.json in this folder into .vscode folder

View file

@ -110,15 +110,16 @@ int main(int argc, char ** argv) {
// here the client_fd is good
if (pthread_mutex_lock(&dev_out_thread_data.communication.endpoint.ssocket.mutex) == 0) {
int i;
for (i = 0; i < MAX_CONNECTED_CLIENTS; ++i) {
bool found = false;
for (size_t i = 0; i < MAX_CONNECTED_CLIENTS; ++i) {
if (dev_out_thread_data.communication.endpoint.ssocket.clients[i] < 0) {
dev_out_thread_data.communication.endpoint.ssocket.clients[i] = client_fd;
found = true;
break;
}
}
if (i == MAX_CONNECTED_CLIENTS) {
if (!found) {
fprintf(stderr, "Could not find a free spot fot the incoming client -- client will be rejected\n");
close(client_fd);
}