This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Add $_as_string convenience function
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 4 Mar 2016 18:07:22 -0500
- Subject: Re: [PATCH] Add $_as_string convenience function
- Authentication-results: sourceware.org; auth=none
- References: <1457124218-22342-1-git-send-email-simon dot marchi at polymtl dot ca>
> 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.
Neat. I think this deserves a NEWS entry!