[prev in list] [next in list] [prev in thread] [next in thread]
List: gdb-patches
Subject: [PATCH] better assembly level debugging
From: tromey () redhat ! com (Tom Tromey)
Date: 2011-05-27 21:02:00
Message-ID: m3r57juaaa.fsf () fleche ! redhat ! com
[Download RAW message or body]
>>>>> "Francois" == Francois <rigault.francois@gmail.com> writes:
Francois> (continuing http://sourceware.org/ml/gdb/2011-05/msg00009.html)
Francois> I've made a proof of concept patch to pretty print addresses. I
Francois> believe it can already greatly improve the task of reading assembly
Francois> code, although it is not yet ready for delivery, I'd love some
Francois> feedback.
Francois> I'm finally able to display:
Francois> => 0x400680 <main+4>: sub $0x10,%rsp
Francois> 0x400684 <main+8>: mov 0x1003fd(%rip),%rax # 0x500a88 [<wprintf>]
Francois> 0x40068b <main+15>: mov %rax,-0x10(%rbp)
Francois> 0x40068f <main+19>: lea 0x106(%rip),%rax # 0x40079c [L"foo 42"]
Francois> Examining the stack:
Francois> 0x7fffffffdd00 [<wprintf>]: 0x7ffff7371920 <wprintf>
Francois> 0x40079c [L"foo 42"]
Looks nice.
Francois> - a gdb.probe_address Python function is called by the print_insn
Francois> routine to check if operands can be pretty printed. If yes, the # is
Francois> added on the right of the instruction and the print_address_func is
Francois> called
Francois> - a gdb.print_address Python function is called by
Francois> print_address_symbolic if no symbolic address could be created for
Francois> this address by the C code.
I am not a big fan of this approach. It means that different Python
modules that want to install printers will conflict. It should probably
be handled some other way instead.
Francois> - the code is not safe yet and I did the changes only for i386-dis.
Changes to opcodes/ have to go to the binutils list.
This patch needs a ChangeLog entry, documentation, and tests.
It has various formatting issues; I can nit-pick them all if you want,
but maybe after addressing the above would be better.
Francois> + di.probe_address_func = (bfd_vma ( *) (char* , void* )) py_probe_address;
Casting function pointers is bad.
Francois> + probe_func = PyObject_GetAttrString(gdb_module, "probe_address");
Francois> + value = PyString_FromString(bufm);
Francois> + result = PyObject_CallFunctionObjArgs (probe_func, value, NULL);
These things need error checks, and probably a call to gdbpy_print_stack
(or throwing a gdb exception).
This applies elsewhere.
Francois> + bfd_vma probed_address = (*info->probe_address_func) (op_txt[i],
Francois> + info->application_data);
Am I right in thinking that the python function must parse the operand
to decide what to do?
If so, I wonder if something friendlier could be done.
Tom
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic