-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add support for loading Core files #152
Comments
and exporting them into elf/pe/whatever. |
See |
Could be helpful http://backtrace.io/blog/blog/2015/10/03/whats-a-coredump/ |
See also this issue @z03 you may be interested |
Hi! Is there anyone taking a look at this? If not, I'd like to take a look into it! |
afaik there is no one working on this. So go ahead @leberus :) |
Ok, then I'll take it ;) |
👍
|
This is already supported for OSX and iOS |
It's working on Linux x86_64. Unfortunately is still missing thread support (didn't have so much time). Much more work is still to be done, but i'd say that something is showing up. I'll add the support for threads in the next days and fix the errors as well. |
Can you do a Pull request ? |
i added some comments in your commit, please, fix them and send a PR for further review
|
Thanks for the comments! I'll write down it and I'll fix all in the next days ;) |
👍
|
ping |
it is merged now. still needs more work, but at least it generates a dump. the implementation is not yet complete, and r2 is not able to load properly those dumps yet. so the task is not complete |
I know, it's missing PC state which is being saved in X86STATE. I will work
|
👍 would be great if that would be ready before the release (aka monday) I'll do more reviews to your code since then and remove many debug printfs which should not appear.
|
I'll try my best! ;)
|
Hi @radare, could you tell me how are you loading the coredump on r2? |
ping |
Hi, I was checking, and I saw something spooky: With the last changes, I saw that some maps which should be dumped are not dumped anymore. This is a test with the same exec, with my code:
And this is the corefile which is generated with the same exec, but with your changes:
Something is wrong. This is easy to test if you try the code from radare2, and the code you can get from https://github.com/leberus/radare2.git in the coresupport branch. PD: Don't take this as a blame please, it justs that I think it should not work in that way. |
r2 corefile
|
Please see the comment above |
There were some really strange conditionals which looked wrong so maybe i missunferstood them. Gcc was complaining about dead code and such. The way to load a core file is just r2 corefile. This will set the register state and the stack must be visible and disassembling in the program counter address should show real code to work. This is how it works with apple cores at least. Never tried with windows minidumps, but the process should be similar. We will have time to think and discuss about better ways to load corefiles when all this stuff works
|
mmm, maybe would be a nice ide to set it up as it was before? at least for dumping the good maps, because now most of the maps are missing and this lead to a wrong behaviour. |
Fix the maps thing i bet this is the oneliner conditional thats on top of the loop. I dont know which is the expected condition to be in there I also moved all the isValidSection checks into separate functions for readabiliy and reusability. So the fix should be easy if you know what must be cloned and what not. See the comments i added. Btw release is today, so it will be great if you could fix this "if" at least. I have a mail from coverity with a lot of errors on this code, i will address them this morning but this shouldnt conflict with your patch, so go ahead
|
I did a quick test. The process can you see it under http://pastebin.com/rcJEVJ0W |
The regs must be loaded and your code doesnt do that yet. The arw command is the one that sets the reg arena
|
I fixed it in https://github.com/radare/radare2/compare/master...leberus:mapping?expand=1, was just a small typo error. In the other hand, just put all errors which coverity is pointing out, and I'll fix them. I'd like to do it so I learn from mistakes. A another thing:as I said, I was not writing this with the though that r2 could load the corefile, my intention was just that r2 was able to dump a corefile from memory and registers, but not load anything. I'd like to do it of course, but this was not my first though. I think this was a misunderstanding from my part with the Task. I mixed this task with the task of #4124 so I apologize for it. |
Also, core support should be implemented for 32 bits, as well as arm and mips. Yesterday i removed the use of a syscall that its only available from kernel 3.2 to just use the io api, doesnt seems to break anything. Also i disabled it for android and non x86-64 linux targets
|
I'm working on enabling thread support and dump the extended state register as well. Once this is working in a proper way, I'll add support for 32 bits because just minor checks must be put in place. PD: Would be also nice for me if you find something more, to tell me, i'd like to fix it. |
awesome! feel free to remove the debug messages as soon as they are not needed thanks!
|
Hey @leberus! Glad to see that you are working on enable coredump support for linux x86. How is it going? I'm currently needing it and wanted to avoid using GDB (r2 is way cooler :P). Thanks for your efforts! |
Hi @zlowram! I'm almost done with thread support and x86 support as well. Just minor things are left(like cleanup a little bit and do the final tests). |
Whoa, sounds great! Looking forward to it :P |
hi @radare, I have a couple of questions: 1- While cleaning my code, I decided to use dbg->maps to get all maps, instead of parsing /proc/pid/maps myself, so I'm not reinventing the weel. But unfortunately I found that r2 does not include the offset field within RDebugMap structure (which a important field for at least coredump). I though about create a new field within RDebugMap to include "offset" value, and then do something like this in r_debug_native_map_get function:
This might be a little bit messy because this function is being called by: debug/p/native/xnu/xnu_debug.c So maybe that's too much, and if that is the case I could parse the /proc/pid/maps myself as I did. 2- That's one thing I spotted during the final tests about thread support:
This is not enough for a process which has a large number of maps (f.i my iceweasel), and buff is being truncated by the size of 65536 by this check that r_file_slurp performs.
So I'm wondering how I should solve this without bypassing the sandbox file utils. (maybe there is a function which gets a char one by one? I didn't see it) Thanks in advance |
Hi
Good. This is how I was expecting to do it. For offset you mean the paddr? Personally i would like to use vaddr/paddr than the confusing offset/addr names. What do you think? But.. I didnt knew you could get the paddr when listig the maps
Well main issue here is that overflows may halpen pretty easily if the user controls the contents in /proc, or the kernel changes the field lengths. Both are rare cases but is better not to assume things that are not under our control
Yes this looks wrong to me too, and this was probably done because slurping a harddisk results in zerosize file but with pretty huge contents. So this way at least it avoids exploding.
Maybe we should check if file is regular (no device, socket, etc) and later go read until eof. Another option would be to increase that size to 512KB or so but that limit will be still a hack
|
Hi @radare , Regarding the problem with the true size of a proc file: Regarding the problem with offset field: I could solve both problems by parsing maps file myself, but in the future I'll fix it because we could save some lines of code and have a more consistent RDebugMap structure as well.
is much less than before since I'm using RDebugMap structure. Thanks |
Sounds good
|
it just works out of the box, r2 corefile git log | grep core may help
|
I got the commit 2702c3f 2016-07-04 15:29 GMT+02:00 radare [email protected]:
|
i think its all fixed now. closing for now |
The text was updated successfully, but these errors were encountered: