Autodetect GDB data directory
As a courtesy to the us who use GDB from build tree, try to detect
and automatically add --data-directory if no arguments are specified
in GDB command (`GDBProcess gdbCommand`).
--- a/GDBLocalProcess.st Wed Jun 19 12:02:49 2019 +0100
+++ b/GDBLocalProcess.st Thu Jun 20 11:24:54 2019 +0100
@@ -157,7 +157,7 @@
On error, thrown GDBError.
"
- | cmd |
+ | cmd argv |
commandOrNil isNil ifTrue:[
@@ -169,10 +169,39 @@
] ifFalse:[
cmd := commandOrNil.
].
- ^ self class gdbCommandParseAndValidate:cmd.
+ argv := self class gdbCommandParseAndValidate:cmd.
+
+ "/ As a courtesy to the us who use GDB from build tree, try to detect
+ "/ and automatically add --data-directory if no arguments are specified.
+ "/ For example:
+ "/
+ "/ GDBLocalProcess basicNew command2argv: '/some/path/to/my/gdb/gdb'
+ "/
+ "/ returns
+ "/
+ "/ #('/some/path/to/my/gdb/gdb' '--data-directory' '/some/path/to/my/gdb/data-directory')
+ "/
+
+ argv size == 1 ifTrue:[
+ | dir |
+
+ dir := argv first asFilename directory.
+ (dir baseName = 'gdb' and:[ (dir / 'data-directory') isDirectory ]) ifTrue:[
+ argv := argv , (Array with: '--data-directory' with: (dir / 'data-directory') pathName)
+ ].
+ ].
+ ^ argv
+
+ "
+ GDBLocalProcess basicNew command2argv: '/home/jv/Projects/gdb/users_jv_patches/gdb/gdb'
+ GDBLocalProcess basicNew command2argv: '/home/jv/Projects/gdb/users_jv_patches/gdb/gdb -nx'
+ GDBLocalProcess basicNew command2argv: '/usr/bin/gdb'
+ GDBLocalProcess basicNew command2argv: 'gdb'
+ GDBLocalProcess basicNew command2argv: nil
+ "
"Created: / 17-12-2018 / 10:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 18-06-2019 / 10:39:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 20-06-2019 / 11:17:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
exited: status
--- a/GDBProcess.st Wed Jun 19 12:02:49 2019 +0100
+++ b/GDBProcess.st Thu Jun 20 11:24:54 2019 +0100
@@ -234,10 +234,12 @@
"
GDBProcess gdbCommand
- GDBProcess gdbCommandValidate: 'gdb'
- GDBProcess gdbCommandValidate: 'gdb -q'
+ GDBProcess gdbCommandParseAndValidate: 'gdb'
+ GDBProcess gdbCommandParseAndValidate: 'gdb -q'
"
+
"Created: / 18-06-2019 / 10:26:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 20-06-2019 / 11:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
gdbExecutable