[PATCH] Add debug_function_to_file

Tom de Vries Tom_deVries@mentor.com
Fri Feb 19 12:40:00 GMT 2016


On 19/02/16 10:44, Richard Biener wrote:
> On Fri, Feb 19, 2016 at 1:37 AM, Tom de Vries <Tom_deVries@mentor.com> wrote:
>> On 18/02/16 16:27, Richard Biener wrote:
>>>
>>> Attached is what I have for now, it works if you call it like
>>>
>>> (gdb) dot-fn cfun
>>> (gdb) dot-fn cfun, 1<<6
>>>
>>> w/o that arg parsing;)
>>>
>>> I'll play with it some more tomorrow.
>>
>>
>> This version:
>> - uses arg parsing
>> - adds error handling
>> - uses a temp file instead of a pipe
>> - uses python os.system to call dot
>
> I used popen

It was suggested in the other thread ( 
https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01172.html ) that there 
were portability issues with popen, so I tried to avoid it.

Anyway, I guess it's probably best to try to minimize interaction with 
the inferior, if we can handle it in python instead.

> specifically to allow you continue debugging while keeping the dot
> process open and functional.

Ah, I see.

> That would be restored with adding a '&' after
> the command but then we race with the file removal ...
>
> The following works for me though:
>
>          # Show graph in temp file
>          os.system("( dot -Tx11 %s; rm %s ) &" % (filename, filename) )
>
> dot_fn()
>

Yep, that works for me too.

[ Btw, I prefer generating dot graps in pdf format. In the pdf viewer, 
you can search for variable names, bb numbers, etc.

It's easy enough to generate the pdf file, but I'm not sure how in 
python we can open the pdf viewer, and wait for it to finish in a 
portable way. xdg-open is linux-only and doesn't seem to wait-on 
-finish. And pythons webbrowser.open_new does wait-on-finish in some 
cases, but not in others, and I don't understand the documentation well 
enough to know if that's going to affect this use-case. ]

> ok for trunk with that change and thanks for the help!
>

You're welcome :) . [ I used to use python regularly (though at a basic 
level) about 6 years ago, but haven't used it since, so it was good to 
revive that skill a bit. ]

I'll commit as attached, unless David has further review comments on 
dot-fn (or comments on dump-fn which would also apply for dot-fn).

Thanks,
- Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-dot-fn-to-gdbhooks.py.patch
Type: text/x-patch
Size: 4729 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160219/c710ff46/attachment.bin>


More information about the Gcc-patches mailing list