cutter icon indicating copy to clipboard operation
cutter copied to clipboard

Set environment variables for debugging

Open diddierh opened this issue 5 years ago • 8 comments

Is your feature request related to a problem? Please describe. Yes, it is not possible to set environment variables for a binary to debug.

Describe the solution you'd like Add an option in the debug section of preferences to set env variables something like this (taken from codeblocks).

image

diddierh avatar Apr 14 '20 11:04 diddierh

This should probably done using rarun2/e dbg.profile files. In that case it should be an interface for managing and editing all(except ones that conflict with rest of UI) dbg.profile properties not just environment variables. It should be also possible to select existing handwritten rarun2 file.

karliss avatar Apr 14 '20 11:04 karliss

Good idea! Thank you <3 I agree with Karliss, this can - and maybe should - be part in a bigger solution of modifying dbg.profile

ITAYC0HEN avatar Apr 14 '20 11:04 ITAYC0HEN

This should probably done using rarun2/e dbg.profile files. In that case it should be an interface for managing and editing all(except ones that conflict with rest of UI) dbg.profile properties not just environment variables. It should be also possible to select existing handwritten rarun2 file.

I would be happy with a small embedded editor for that config file, I only need to switch a specific envvar for testing a binary. Thanks for your soon response.

diddierh avatar Apr 14 '20 17:04 diddierh

In case you need a solution that works right now looks like setting e dbg.profile=/path/to/rarun_profile.rr2 in the console widget works. Didn't test with all the features but at least setting environment variable works.

karliss avatar Apr 14 '20 17:04 karliss

You can unset env vars too with rarun2

On 14 Apr 2020, at 19:59, karliss [email protected] wrote:

 In case you need a solution that works right now looks like setting e dbg.profile=/path/to/rarun_profile.rr2 in the console widget works. Didn't test with all the features but at least setting environment variable works.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

radare avatar Apr 14 '20 20:04 radare

related: in gdb, shims (wrapper scripts) can be debugged by debugging the interpreter with catch exec

/usr/bin/env bash /path/to/wrapper.sh

https://developers.redhat.com/articles/2022/12/27/debugging-binaries-invoked-scripts-gdb

ideally the debugger should also work on such wrappers

#! /usr/bin/env bash
export X=1
exec /path/to/some_binary

such wrapper scripts are common on nixos linux

milahu avatar Feb 17 '23 13:02 milahu

~~related to #2052~~

karliss avatar Jan 30 '25 21:01 karliss

It was supposed to be related to #3199

karliss avatar Apr 03 '25 12:04 karliss