# HG changeset patch # User Jan Vrany # Date 1528362667 -3600 # Node ID 74c24ce4025136e9c5a859654fae426a74b1e2b3 # Parent 1e2c548b0cde54c5a38e4f7373e9296a693d9555 Fixed `GDBThreadGroup >> #executable` for case where executable ir not known (reported) such as when debugging bare-metal code or the target does not report it (may happen, for example wine's winedbg GDB proxy does not report executable names. diff -r 1e2c548b0cde -r 74c24ce40251 GDBThreadGroup.st --- a/GDBThreadGroup.st Mon Jun 04 15:12:54 2018 +0100 +++ b/GDBThreadGroup.st Thu Jun 07 10:11:07 2018 +0100 @@ -24,7 +24,7 @@ GDBDebuggerObject subclass:#GDBThreadGroup instanceVariableNames:'id type executable running pid exit_code threads' - classVariableNames:'' + classVariableNames:'ExecutableSentinel' poolDictionaries:'GDBCommandStatus' category:'GDB-Core' ! @@ -52,6 +52,16 @@ " ! ! +!GDBThreadGroup class methodsFor:'initialization'! + +initialize + "Invoked at system start or when the class is dynamically loaded." + + ExecutableSentinel := Object new. + + "Modified: / 07-06-2018 / 10:05:35 / Jan Vrany " +! ! + !GDBThreadGroup class methodsFor:'instance creation'! new @@ -99,6 +109,8 @@ !GDBThreadGroup methodsFor:'accessing'! executable + "Return name path of the executable (if known) or nil (if unknown)" + (executable isNil and:[ pid notNil and:[self isStopped or:[debugger hasFeature:'async']]]) ifTrue:[ | result tg | @@ -107,12 +119,27 @@ self error: 'Failed to send command.' ]. tg := (result propertyAt: 'groups') detect: [: each | each id = id ]. - executable := tg executable. + "/ In some cases the executable is not known - it may not exist (such as + "/ when debugging bare-metal code) or the target does not report it + "/ (may happen, for example wine's winedbg GDB proxy does not report + "/ executable names). + "/ + "/ In this case, we store a sentinel object in `executable` instvar + "/ to prevent repeated queries which are bound to fail (see the nil-check + "/ above. + executable := tg executableOrNil ? ExecutableSentinel. ]. - ^ executable + ^ executable == ExecutableSentinel ifTrue:[ nil ] ifFalse:[ executable ] "Created: / 06-06-2017 / 00:04:43 / Jan Vrany " "Modified: / 26-03-2018 / 21:44:53 / jv" + "Modified (comment): / 07-06-2018 / 10:09:40 / Jan Vrany " +! + +executableOrNil + ^ executable + + "Created: / 06-06-2018 / 15:43:12 / Jan Vrany " ! exitCode @@ -316,3 +343,5 @@ ^ '$Changeset: $' ! ! + +GDBThreadGroup initialize!