[RFC,0/3,gdb/testsuite] Introduce is_x86_64_m64_target

Message ID 20230125200626.29340-1-tdevries@suse.de
Headers
Series Introduce is_x86_64_m64_target |

Message

Tom de Vries Jan. 25, 2023, 8:06 p.m. UTC
  I used a refactoring setup I wrote in python for another refactoring to
rewrite:
...
if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
    verbose "Skipping ${testfile}."
    return
}
...
into:
...
require is_x86_64_m64_target
...

It also handles the elseif case.

Due to a recent commit, only the elseif cases are transformed, the others
have been handled already.

Also, I see now that "require {istarget x86_64-*-*} is_lp64_target" can be used,
and that is_x86_64_m64_target not stricly necessary.

I've included the two patches with the refactoring scripts.

Tom de Vries (3):
  [gdb/contrib] Add refactor.py
  [gdb/contrib] Add refactor_require.py
  [gdb/testsuite] Add and use is_x86_64_m64_target

 gdb/contrib/refactor.py                       | 73 +++++++++++++++++++
 gdb/contrib/refactor_require.py               | 53 ++++++++++++++
 .../gdb.arch/amd64-entry-value-param.exp      |  5 +-
 gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp |  5 +-
 .../gdb.mi/mi2-amd64-entry-value.exp          |  5 +-
 .../gdb.python/py-framefilter-invalidarg.exp  |  5 +-
 gdb/testsuite/gdb.python/py-linetable.exp     |  5 +-
 .../gdb.reverse/amd64-tailcall-reverse.exp    |  5 +-
 .../gdb.reverse/singlejmp-reverse.exp         |  5 +-
 gdb/testsuite/lib/gdb.exp                     |  4 +
 10 files changed, 143 insertions(+), 22 deletions(-)
 create mode 100755 gdb/contrib/refactor.py
 create mode 100644 gdb/contrib/refactor_require.py


base-commit: 6121eeb72978cc5749c4c9f119b4dbaf637517c9
  

Comments

Tom Tromey Jan. 25, 2023, 9:26 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> I used a refactoring setup I wrote in python for another refactoring to
Tom> rewrite:
Tom> ...
Tom> if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
Tom>     verbose "Skipping ${testfile}."
Tom>     return
Tom> }
Tom> ...
Tom> into:
Tom> ...
Tom> require is_x86_64_m64_target
Tom> ...

Tom> It also handles the elseif case.

Tom> Due to a recent commit, only the elseif cases are transformed, the others
Tom> have been handled already.

If you want the existing requires could be converted to use the new
proc.  Seems a little simpler.

I sent a comment to one patch but otherwise this looks good to me.
Thanks for doing it.

FWIW I also have some refactoring scripts, but mine are
idiosyncratically written in emacs lisp, which is convenient in some
ways (easier to do multi-line edits, and back in the day I could have
them make ChangeLog entries) but worse in others (slow).

Tom
  
Tom de Vries Jan. 26, 2023, 9:30 a.m. UTC | #2
On 1/25/23 22:26, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> I used a refactoring setup I wrote in python for another refactoring to
> Tom> rewrite:
> Tom> ...
> Tom> if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
> Tom>     verbose "Skipping ${testfile}."
> Tom>     return
> Tom> }
> Tom> ...
> Tom> into:
> Tom> ...
> Tom> require is_x86_64_m64_target
> Tom> ...
> 
> Tom> It also handles the elseif case.
> 
> Tom> Due to a recent commit, only the elseif cases are transformed, the others
> Tom> have been handled already.
> 
> If you want the existing requires could be converted to use the new
> proc.  Seems a little simpler.
> 

Done.

> I sent a comment to one patch but otherwise this looks good to me.
> Thanks for doing it.
> 
> FWIW I also have some refactoring scripts, but mine are
> idiosyncratically written in emacs lisp, which is convenient in some
> ways (easier to do multi-line edits, and back in the day I could have
> them make ChangeLog entries) but worse in others (slow).

I see.  I love to use emacs, but I'm not familiar with lisp, so that's 
not an option for me :)

Anyway, I don't think that the refactoring scripts I've posted here are 
ready for contribution, but ideally I'd love to have some refactoring 
tool commonly used, with the idea that it would enable not only posting 
the result of the transformation, put also the transformation itself, 
and you could get feedback on the transformation, people could try it 
out themselves, find cases they think could be handled in addition, post 
improved versions.  And something in python seems not a bad choice, 
considering the popularity of it.

FWIW, I've started out with the idea of using cocinelle for some gdb 
source transformation, but pretty soon found out that c++ support is 
missing/poor, so I abandoned that idea.

Thanks,
- Tom