This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add $_as_string convenience function


On 03/04/2016 08:43 PM, Simon Marchi wrote:
This patch is a follow-up to "Add printf format specifier for printing
enumerator":

   https://sourceware.org/ml/gdb-patches/2016-02/msg00144.html

Instead of having a solution specific to the printf command, Pedro
suggested adding a general purpose function $_as_string() that would
cover this use case and more.

So, in order to print the textual label of an enum, one can use:

   (gdb) printf "Visiting node of type %s\n", $_as_string(node)
   Visiting node of type NODE_INTEGER

gdb/ChangeLog:

	* data-directory/Makefile.in (PYTHON_FILE_LIST): Install
	gdb/function/as_string.py.
	* python/lib/gdb/function/as_string.py: New file.

gdb/testsuite/ChangeLog:

	* gdb.python/py-as-string.exp: New file.
	* gdb.python/py-as-string.c: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Convenience Functions): Document $_as_string.

LGTM, thanks for doing this.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]