This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] better assembly level debugging
- From: Tom Tromey <tromey at redhat dot com>
- To: Francois <rigault dot francois at gmail dot com>
- Cc: pmuldoon at redhat dot com, gdb-patches at sourceware dot org
- Date: Fri, 27 May 2011 15:02:37 -0600
- Subject: Re: [PATCH] better assembly level debugging
- References: <BANLkTi=NhwR2_F584nsxVhvDtTuxPMB0Ag@mail.gmail.com> <m3tydd9j3u.fsf@redhat.com> <BANLkTimz5pTfcf6O-JNrpxi9d3LotoewMw@mail.gmail.com>
>>>>> "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