Add $_as_string convenience function
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 10 Mar 2016 22:12:30 +0000 (17:12 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 10 Mar 2016 22:12:30 +0000 (17:12 -0500)
commitf2f3ccb9f81255fd1b4f877600f39979c2d7ece5
treeb716861822a8b7ecd3d643061903298d57b969b8
parenta9f02af88d230aabf6771f94a6c401727a865188
Add $_as_string convenience function

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.
* NEWS: Mention the new $_as_string function.

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.
gdb/ChangeLog
gdb/NEWS
gdb/data-directory/Makefile.in
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/python/lib/gdb/function/as_string.py [new file with mode: 0644]
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-as-string.c [new file with mode: 0644]
gdb/testsuite/gdb.python/py-as-string.exp [new file with mode: 0644]
This page took 0.025293 seconds and 4 git commands to generate.