Skip to content

Commit ed3c22c

Browse files
committed
update vscode config
1 parent 0c29ce8 commit ed3c22c

File tree

5 files changed

+150
-189
lines changed

5 files changed

+150
-189
lines changed

.vscode/launch.json

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,20 @@
55
"name": "Make: compile and debug",
66
"type": "cppdbg",
77
"request": "launch",
8-
"program": "${workspaceFolder}/${config:c_project.dir}/${config:c_project.program}",
8+
"program": "/bin/bash",
99
"args": [
10-
"${config:c_project.arg1}",
11-
"${config:c_project.arg2}",
12-
"${config:c_project.arg3}",
13-
"${config:c_project.arg4}",
14-
"${config:c_project.arg5}",
15-
"${config:c_project.arg6}",
16-
"${config:c_project.arg7}",
17-
"${config:c_project.arg8}"
10+
"-c",
11+
"${workspaceFolder}/.vscode/run.sh",
1812
],
19-
"stopAtEntry": true,
13+
"stopAtEntry": false,
2014
"cwd": "${workspaceFolder}/${config:c_project.dir}",
2115
"externalConsole": false,
2216
"linux": {
2317
"MIMode": "gdb",
2418
"internalConsoleOptions": "neverOpen", // don't show the debugger console
2519
"environment": [
2620
{"name":"LD_PRELOAD", "value":"${workspaceFolder}/.vscode/visualize-c-memory.so"},
21+
{"name":"CODE_DEBUG", "value":"./${config:c_project.program} ${config:c_project.args}"},
2722
],
2823
"setupCommands": [
2924
{
@@ -39,26 +34,30 @@
3934
},
4035
"osx": {
4136
"MIMode": "lldb", // on macOS gdb is hard to setup
42-
"internalConsoleOptions": "openOnSessionStart" // open the debugger console, lldb sends output only there
37+
"internalConsoleOptions": "openOnSessionStart", // open the debugger console, lldb sends output only there
38+
"environment": [
39+
{"name":"CODE_DEBUG", "value":"./${config:c_project.program} ${config:c_project.args}"},
40+
],
41+
"setupCommands": [
42+
{
43+
"description": "Don't stop on exec", // lldb stops execution on "exec", we need to continue since we run via bash
44+
"text": "settings set target.process.stop-on-exec false",
45+
"ignoreFailures": false
46+
}
47+
],
4348
},
4449
"preLaunchTask": "Make: compile",
4550
},
4651
{
4752
"name": "Single file: compile and debug",
4853
"type": "cppdbg",
4954
"request": "launch",
50-
"program": "${fileDirname}/${fileBasenameNoExtension}",
55+
"program": "/bin/bash",
5156
"args": [
52-
"${config:c_project.arg1}",
53-
"${config:c_project.arg2}",
54-
"${config:c_project.arg3}",
55-
"${config:c_project.arg4}",
56-
"${config:c_project.arg5}",
57-
"${config:c_project.arg6}",
58-
"${config:c_project.arg7}",
59-
"${config:c_project.arg8}"
57+
"-c",
58+
"${workspaceFolder}/.vscode/run.sh",
6059
],
61-
"stopAtEntry": true,
60+
"stopAtEntry": false,
6261
"cwd": "${fileDirname}",
6362
"environment": [],
6463
"externalConsole": false,
@@ -67,6 +66,7 @@
6766
"internalConsoleOptions": "neverOpen", // don't show the debugger console
6867
"environment": [
6968
{"name":"LD_PRELOAD", "value":"${workspaceFolder}/.vscode/visualize-c-memory.so"},
69+
{"name":"CODE_DEBUG", "value":"./${fileBasenameNoExtension} ${config:c_project.args}"},
7070
],
7171
"setupCommands": [
7272
{
@@ -82,26 +82,30 @@
8282
},
8383
"osx": {
8484
"MIMode": "lldb", // on macOS gdb is hard to setup
85-
"internalConsoleOptions": "openOnSessionStart" // open the debugger console, lldb sends output only there
85+
"internalConsoleOptions": "openOnSessionStart", // open the debugger console, lldb sends output only there
86+
"environment": [
87+
{"name":"CODE_DEBUG", "value":"./${fileBasenameNoExtension} ${config:c_project.args}"},
88+
],
89+
"setupCommands": [
90+
{
91+
"description": "Don't stop on exec", // lldb stops execution on "exec", we need to continue since we run via bash
92+
"text": "settings set target.process.stop-on-exec false",
93+
"ignoreFailures": false
94+
}
95+
],
8696
},
8797
"preLaunchTask": "Single file: compile",
8898
},
8999
{
90100
"name": "All files in directory: compile and debug",
91101
"type": "cppdbg",
92102
"request": "launch",
93-
"program": "${fileDirname}/${config:c_project.program}",
103+
"program": "/bin/bash",
94104
"args": [
95-
"${config:c_project.arg1}",
96-
"${config:c_project.arg2}",
97-
"${config:c_project.arg3}",
98-
"${config:c_project.arg4}",
99-
"${config:c_project.arg5}",
100-
"${config:c_project.arg6}",
101-
"${config:c_project.arg7}",
102-
"${config:c_project.arg8}"
105+
"-c",
106+
"${workspaceFolder}/.vscode/run.sh",
103107
],
104-
"stopAtEntry": true,
108+
"stopAtEntry": false,
105109
"cwd": "${fileDirname}",
106110
"environment": [],
107111
"externalConsole": false,
@@ -110,6 +114,7 @@
110114
"internalConsoleOptions": "neverOpen", // don't show the debugger console
111115
"environment": [
112116
{"name":"LD_PRELOAD", "value":"${workspaceFolder}/.vscode/visualize-c-memory.so"},
117+
{"name":"CODE_DEBUG", "value":"./${config:c_project.program} ${config:c_project.args}"},
113118
],
114119
"setupCommands": [
115120
{
@@ -125,15 +130,18 @@
125130
},
126131
"osx": {
127132
"MIMode": "lldb", // on macOS gdb is hard to setup
128-
"internalConsoleOptions": "openOnSessionStart" // open the debugger console, lldb sends output only there
133+
"internalConsoleOptions": "openOnSessionStart", // open the debugger console, lldb sends output only there
134+
"environment": [
135+
{"name":"CODE_DEBUG", "value":"./${config:c_project.program} ${config:c_project.args}"},
136+
],
137+
"setupCommands": [
138+
{
139+
"description": "Don't stop on exec", // lldb stops execution on "exec", we need to continue since we run via bash
140+
"text": "settings set target.process.stop-on-exec false",
141+
"ignoreFailures": false
142+
}
143+
],
129144
},
130-
"setupCommands": [
131-
{
132-
"description": "Enable pretty-printing for gdb",
133-
"text": "-enable-pretty-printing",
134-
"ignoreFailures": true
135-
}
136-
],
137145
"preLaunchTask": "All files in directory: compile",
138146
},
139147
]

.vscode/run.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Helper script for executing programs in tasks/debugger with flexibility for
4+
# passing arguments, input/output redirection, etc.
5+
6+
if [ -z "$CODE_DEBUG" ]
7+
then
8+
echo " * Executing: $CODE_RUN"
9+
echo
10+
11+
# we use "eval" to allow for input/output redirections
12+
cd "$CODE_DIR"
13+
eval $CODE_RUN
14+
else
15+
echo " * Executing: $CODE_DEBUG"
16+
echo
17+
18+
# When debugging we exec in the same process being debugged
19+
eval "exec $CODE_DEBUG"
20+
fi
21+

.vscode/set_program_args.pl

Lines changed: 0 additions & 27 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,9 @@
66
// Directory στο οποίο βρίσκεται το πρόγραμμα (μόνο για μεταγλώτισση με make)
77
"dir": "programs/cat",
88

9-
// Οι τιμές που δηλώνονται στα arg1 - arg8 παρακάτω δίνονται αυτόματα σαν ορίσματα
10-
// σε οποιοδήποτε πρόγραμμα τρέχουμε (είτε με Ctrl-Shift-B είτε στον debugger).
9+
// Ορίσματα του προγράμματος.
10+
// Υποστηρίζονται ανακατευθύνσεις εισόδου (< input-file) και εξόδου (> output-file).
1111
//
12-
// Ο ευκολότερος τρόπος να τις αλλάξουμε: Terminal / Run task / Set program arguments
13-
//
14-
// - Για ανακατεύθυνση εισόδου βάζουμε ορίσματα: "<", "input-file"
15-
// - Για ανακατεύθυνση εξόδου βάζουμε ορίσματα: ">", "output-file"
16-
//
17-
// Τερματίζουμε τη λίστα με "#", το όρισμα αυτό και τα επόμενά του αγνοούνται.
18-
//
19-
// ΠΡΟΣΟΧΗ: Ολα τα arg1 - arg8 πρέπει να δηλώνονται, αν τα βάλουμε σε σχόλια θα
20-
// πάρουμε μήνυμα λάθους. Αν θέλουμε λιγότερα απλά τερματίζουμε με "#".
21-
//
22-
"arg1": "input-file",
23-
"arg2": "#",
24-
"arg3": "#",
25-
"arg4": "#",
26-
"arg5": "#",
27-
"arg6": "#",
28-
"arg7": "#",
29-
"arg8": "#",
12+
"args": "input-file",
3013
},
3114
}

0 commit comments

Comments
 (0)