[PATCH v5] Implement the ability to set/unset environment variables to GDBserver when starting the inferior

Sergio Durigan Junior sergiodj@redhat.com
Thu Aug 31 21:26:00 GMT 2017


On Thursday, August 31 2017, Simon Marchi wrote:

> On 2017-08-31 22:49, Sergio Durigan Junior wrote:
>> Changes from v4:
>>
>> - Applied Simon's patch to refactor the unittest.  Thanks, Simon!
>>
>>
>> This patch implements the ability to set/unset environment variables
>> on the remote target, mimicking what GDB already offers to the user.
>> There are two features present here: user-set and user-unset
>> environment variables.
>>
>> User-set environment variables are only the variables that are
>> explicitly set by the user, using the 'set environment' command.  This
>> means that variables that were already present in the environment when
>> starting GDB/GDBserver are not transmitted/considered by this feature.
>>
>> User-unset environment variables are variables that are explicitly
>> unset by the user, using the 'unset environment' command.
>>
>> The idea behind this patch is to store user-set and user-unset
>> environment variables in two separate sets, both part of gdb_environ.
>> Then, when extended_remote_create_inferior is preparing to start the
>> inferior, it will iterate over the two sets and set/unset variables
>> accordingly.  Three new packets are introduced:
>>
>> - QEnvironmentHexEncoded, which is used to set environment variables,
>>   and contains an hex-encoded string in the format "VAR=VALUE" (VALUE
>>   can be empty if the user set a variable with a null value, by doing
>>   'set environment VAR=').
>>
>> - QEnvironmentUnset, which is used to unset environment variables, and
>>   contains an hex-encoded string in the format "VAR".
>>
>> - QEnvironmentReset, which is always the first packet to be
>>   transmitted, and is used to reset the environment, i.e., discard any
>>   changes made by the user on previous runs.
>>
>> The QEnvironmentHexEncoded packet is inspired on LLDB's extensions to
>> the RSP.  Details about it can be seen here:
>>
>>
>> <https://raw.githubusercontent.com/llvm-mirror/lldb/master/docs/lldb-gdb-remote.txt>
>>
>> I decided not to implement the QEnvironment packet because it is
>> considered deprecated by LLDB.  This packet, on LLDB, serves the same
>> purpose of QEnvironmentHexEncoded, but sends the information using a
>> plain text, non-hex-encoded string.
>>
>> The other two packets are new.
>>
>> This patch also includes updates to the documentation, testsuite, and
>> unit tests, without introducing regressions.
>
> That version LGTM.

Thanks for all the reviews.

Pushed:
  0a2dde4a321d2f7bd2ded9a558b9ae92892de0e2

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/



More information about the Gdb-patches mailing list