-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terminal,service: add raw examinemem dump #3721
base: master
Are you sure you want to change the base?
Conversation
@stapelberg thoughts on this as an implementation for your feature request? |
Hey, thank you so much for sending this PR! I just tried it out like so:
This seems to work: the byte slice contents match exactly. It would be convenient if examinemem also accepted hexadecimal
Or, even better, if the whole sequence of commands (examine slice header, construct transcript and examinemem commands) could somehow be encapsulated into a “dumpslice” command or similar. Thanks again |
Done
That seems a bit too specific to be a command, and it could be added anyway with a user script. |
Thanks, this works now and is convenient :)
I tried writing a starlark script for it (before filing the feature request) but didn’t get very far. I stumbled over basic hurdles like getting an expression from the command line into my starlark function. Unfortunately I wasn’t able to find examples on the web. Would you mind sketching how such a user script would look like? |
If you are willing to do some post-processing you can just do:
you don't even need this patch, otherwise |
Thanks for the example! I ended up with this version: # Syntax: dumpbytearr <var> <outputfile>
def command_dumpbytearr(args):
var_name, filename = args.split(" ")
s = eval(None, var_name).Variable
dlv_command("transcript -t -x -n %s" % filename)
dlv_command("x -fmt raw -count %d -size 1 %d" % (s.Len, s.Base))
dlv_command("transcript -off") From my perspective, the PR is ready to be merged — it’s helpful and seems to work in all of my tests :) |
Overall the implementation seems fine for the Perhaps it would be better to omit the change to |
Change the examinemem command to have a new format 'raw' that just prints the raw memory bytes. Change the transcript command to add a new flag that disables prompt echo to the output file. Fixes go-delve#3706
If we change the way we convert |
Any update on this PR? I still find myself frequently reaching for this functionality, so it would be great to have it included in Delve properly. Thank you! |
I think this is ok. @stapelberg would this work for you? You'd still have to write a custom command to dump the bytes to a file or something however. |
Just had a chance to try this out. I used the following # Syntax: dumpbytearr <var> <outputfile>
def command_dumpbytearr(args):
var_name, filename = args.split(" ")
s = eval(None, var_name).Variable
mem = examine_memory(s.Base, s.Len).Mem
write_file(filename, mem) And it seems to work fine. So, yes, this works. Thank you! |
Change the examinemem command to have a new format 'raw' that just
prints the raw memory bytes.
Change the transcript command to add a new flag that disables prompt
echo to the output file.
Fixes #3706