This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to use -list-target-features MI command


On 04/23/2018 02:28 AM, Simon Marchi wrote:
> On 2018-04-09 10:22, Jan Vrany wrote:
>> I need to know (in advance) whether the target supports async
>> mode or not.
>> I know that -list-target-features can be used for that, but
>> not sure when and how to use -list-target-features.
>>
>> The documentation says:
>>
>> "Whenever a target can change, due to commands such as -target-select,
>> -target-attach or -exec-run, the list of target features may change,
>> and the frontend should obtain it again."
>>
>> However, once I issue `-exec-run` using a target with no async mode
>> support, I will not get the result of -list-target-feature before
>> debugee stops.
> 
> I think that's kind of expected.  If the run target does not support mi-async, GDB can't parse and reply to MI commands while the target is executing.  GDB reads and replies to your -list-target-features only when the target stops.
> 
> One way to hack around it would be to use for example the new "starti" command, which breaks at (before?) the first instruction of the program, issue -list-target-features, and then continue.  There might be some better/cleaner solution, but that's what comes to mind right now.

IMO the clean solution is to connect to the native target
explicitly, with "-target-select native", before -exec-run,
instead of letting -exec-run automatically connect to
the native target if not connected to any other target yet.

 -gdb-set mi-async on
 ^done
 (gdb) 
 -target-select native
 ^connected
 (gdb) 
 -list-target-features
 ^done,features=["async"]
 (gdb) 
 -exec-run ...

I'd also suggest that frontends consider using 
  "set auto-connect-native-target off"
https://sourceware.org/gdb/onlinedocs/gdb/Starting.html

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]