]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdbsupport] Reimplement phex and phex_nz as templates
authorTom de Vries <tdevries@suse.de>
Fri, 2 May 2025 20:10:53 +0000 (22:10 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 2 May 2025 20:10:53 +0000 (22:10 +0200)
commit9c1f84c9b46c1442649077d340224fa05ced63e3
tree517b4e2727754d8fa99e6d8bec96df3f6a30a85f
parenta048980c4eb93f8a965b4addc7134e8a527874a2
[gdbsupport] Reimplement phex and phex_nz as templates

Gdbsupport functions phex and phex_nz have a parameter sizeof_l:
...
extern const char *phex (ULONGEST l, int sizeof_l);
extern const char *phex_nz (ULONGEST l, int sizeof_l);
...
and a lot of calls use:
...
  phex (l, sizeof (l))
...

Make this easier by reimplementing the functions as a template, allowing us to
simply write:
...
  phex (l)
...

Simplify existing code using:
...
$ find gdb* -type f \
    | xargs sed -i 's/phex (\([^,]*\), sizeof (\1))/phex (\1)/'
$ find gdb* -type f \
    | xargs sed -i 's/phex_nz (\([^,]*\), sizeof (\1))/phex_nz (\1)/'
...
and manually review:
...
$ find gdb* -type f | xargs grep "phex (.*, sizeof.*)"
$ find gdb* -type f | xargs grep "phex_nz (.*, sizeof.*)"
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
16 files changed:
gdb/aarch64-linux-tdep.c
gdb/aarch64-tdep.c
gdb/breakpoint.c
gdb/bsd-uthread.c
gdb/dwarf2/read.c
gdb/ravenscar-thread.c
gdb/remote.c
gdb/solib-svr4.c
gdb/tracefile-tfile.c
gdb/tracepoint.c
gdbserver/server.cc
gdbserver/target.cc
gdbserver/tracepoint.cc
gdbserver/utils.cc
gdbsupport/print-utils.cc
gdbsupport/print-utils.h