Closed asimgunes closed 9 months ago
Some additional update notes:
I observe that there is a problem in the Windows integration tests. As far as I see, new tests are working fine but one old test is failing in the report.
I implemented new tests for utility functions, which checks the inject logic and text building formats, however, I couldn't find the proper way to test if the environment
variables is injected/passed in to the spawn function. (Since CdtDebugClient is already creating a new process while running the tests, libraries like sinon could not create stub functions to check the parameters.), I do my tests manually and locally, out of scope of this update. I am open for suggestions on this point.
For windows tests are broken, see #299
For tests I think we can use getenv C function in a new test class to see what environment ends up in the inferior. See https://www.tutorialspoint.com/c_standard_library/c_function_getenv.htm Eg you can call setenv on a few env vars and assign them to c variables, insert a breakpoint after those calls and ensure the C vars have expected values.
The other thing you can do is use cdt-gdb-tests/executeCommand
to send arbitrary gdb commands to check the effect has worked as expected.
I'll do a review of the code itself soon.
I tried adding
${env:PATH}
to my launch.json and it was expanded as I expected with no special handling.
I experimented with case sensitivity and multiple vars in a single expansion and it all worked as I would expect according to https://code.visualstudio.com/docs/editor/variables-reference#_environment-variables
@asimgunes please let me know when you are ready for me to re-review this, with a comment on pressing the "re-request review" button.
Hi @jonahgraham,
I think this pull request is ready to re-check right now.
To summarize, following changes performed:
cdt-gdb-tests/executeCommand
command and inject console output as well as the command result. I need to update this implementation due to executing command and getting results. (The previous implementation was neither getting the result nor getting the console output. I added both of them.)Note: Both commands tried: show environment <VARNAME>
and call (char *) getenv("<VARNAME>")
to get the variables and both of them return the result in console output. Thats the reason for cdt-gdb-tests/executeCommand
command update.
Hi @jonahgraham,
I made some updates about your comments, Could you please re-check the updates when you are available?
Kind regards.
@asimgunes I made some changes to the code in line with my review comments. Please have a review of that and let me know if it looks good to you
I have now fixed the Windows issue, rebasing this on main will pull in the fix for #299
Hi @jonahgraham,
Thanks for the updates, they all seem fine and I like the idea of lineTags. I also rebased the current request and all tests seem to be passed.
From my point of view, update seem fine.
@asimgunes this is now merged - are there other changes incoming, or should I do a publish to npm and version bump?
Will you provide the corresponding change to cdt-gdb-vscode?
Hi @jonahgraham,
Thanks for the merge, there is no upcoming change from my side, and sure I can provide an update about related changes to the cdt-gdb-vscode, once you publish the recent cdt-gdb-adapter to npm.
@asimgunes - I have published new version - https://www.npmjs.com/package/cdt-gdb-adapter/v/0.0.29 - can you consume that update when you make the cdt-gdb-vscode changes?
can you consume that update when you make the cdt-gdb-vscode changes?
I am making the change to cdt-gdb-vscode now to pull in the fix in #306
Hi,
I like to propose a new feature for cdt-gdb-adapter which enables injecting environment variables to gdb and gdbserver processes.
The new variables are located as
environment
andtarget.environment
. The rootenvironment
injects environment variables togdb
process, wheretarget.environment
injects environment variables to gdbserver process.Similar to
cwd
andtarget.cwd
behaviour, gdbserver process also includesenvironment
definition. (Which means gdbserver is injecting both environment and target.environment).In this implementation, we also support construction of new values with using the old values. This is a common scenario for PATH environment variable in most cases. The following configuration will append a new path to the PATH variable:
PATH: '%PATH%;C:\some\new\path'
or
PATH: '$PATH:/some/new/path'
New value construction is not limited to the PATH variable, the logic could be used in any variable and the following formats are supported:
%VAR_NAME% format: TEST_VAR: "%TEST_VAR%;Some other text"
$VAR_NAME format: TEST_VAR: "$TEST_VAR;Some other text"
${env.VAR_NAME} format: TEST_VAR: "${env.TEST_VAR};Some other text"
I believe this could be a useful scenario in some cases where developers need to inject some environment variables seamlessly and improve the user experience.
To sum up, I would be happy if you can review this request, and happy to hear any feedback.
Kind regards. Asim Gunes