-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Mach0 coredump generation (WIP) - Revised #4407
Conversation
@@ -3130,6 +3130,9 @@ static int cmd_debug(void *data, const char *input) { | |||
case 'e': | |||
r_core_debug_esil (core, input + 1); | |||
break; | |||
case 'g': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add comments here // "dg"
so that grepping for the command is easier?
wrong window :X sorry |
can you squash, rebase and update the PR to fix the merge conflict and allow proper review? thanks! |
|
||
#include <mach-o/loader.h> | ||
|
||
// TODO: Put this code in an if that checks if the target is a mach kernel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is mach0 specific, must be implemented in a plugin, or at least in a separate file debug/mach0 or so
I have removed core.c and moved all the implementation to the native debug plugin. |
i sent him through telegram some feedback. Looking forward for the PR update in order to see it again and study thoroughly the logic behind core file generation ;) |
660b3f0
to
ae14338
Compare
vm_size_t size = 0; | ||
int n = 1; | ||
|
||
for(;;) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space before (
Hardcoded path must be |
Use eprintf instead of printf for debuggging messages |
The final core generated:
|
The file generation part must be done in RCore, and using the |
ping |
I will continue tomorrow |
Starting to look good! |
There are some bugs here and there. It's not finished. |
return -1; | ||
} | ||
|
||
if (fchown (fd, info->uid, info->gid) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to fail if ownership change fails. it's ok to save the file as r2 the user running r2. in fact, changing it can be problematic for the user in some environments
👍 |
ACK the feedback. I hope to finish it tomorrow |
oops. can you squash and drop that merge? |
I will describe here the bug with realloc: during r_buf_append_buf, the dest buf [b] is a pointer to the file by mmap, realloc says that the pointer is not allocated (maybe because is alloacted by mmap and not malloc, so some internal state is missing?) |
mmapped memory cannot be reallocated. so looks like a bug in r_buf_append_buf, because it should be checking if its malloc or mmaped buf. |
What function should I use for reallocating the buffer in case is a mmap one? mremap is not standard and is not in Darwin. (Also looks like is not very secure) |
@@ -1259,6 +1259,52 @@ static int r_debug_desc_native_open (const char *path) { | |||
return 0; | |||
} | |||
|
|||
static int r_debug_setup_ownership (int fd, RDebug *dbg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer RDebug don't touch the filesystem at all. and, as long as r_debug_info
can be called from RCore you can just fchown in there.
i have commited the new RBuffer API |
Great! :D it works,it can be better (like everything) but it's by far, ready to be merged. Good work and thanks for the contrib! |
Also, cleaned up the code and removed core.c.