[PATCH v4] Improve gdb_tilde_expand logic

Simon Marchi simon.marchi@polymtl.ca
Mon Jan 11 23:36:32 GMT 2021


On 2021-01-11 5:40 p.m., Lancelot SIX via Gdb-patches wrote:
> Before this patch, gdb_tilde_expand would use glob(3) in order to expand
> tilde at the begining of a path. This implementation has limitation when
> expanding a tilde leading path to a non existing file since glob fails to
> expand.
> 
> This patch proposes to use glob only to expand the tilde component of the
> path and leaves the rest of the path unchanged.
> 
> This patch is a followup to the following discution:
> https://sourceware.org/pipermail/gdb-patches/2021-January/174776.html
> 
> Before the patch:
> 
> 	gdb_tilde_expand("~") -> "/home/lsix"
> 	gdb_tilde_expand("~/a/c/b") -> error() is called
> 
> After the patch:
> 
> 	gdb_tilde_expand("~") -> "/home/lsix"
> 	gdb_tilde_expand("~/a/c/b") -> "/home/lsix/a/c/b"
> 
> Tested on x84_64 linux.
> 
> Since V1:
> 	* Unittests added thanks to inputs and skeleton provided by
> 	Simon Marchi.
> 	* My copyright assignment has been signed!
> 
> Since V2:
> 	* Fix coding style issuess and typos.
> 	* Use $HOME and $USER env variables to test the behavior of
> 	gdb_tilde_expand instead of testing the function against itself.
> 
> Since V3:
> 	* Add tests for erroneous cases.
> 	* Fix coding style of lambda function.
> 
> gdb/ChangeLog:
> 
> 	* Makefile.in (SELFTESTS_SRCS): Add
> 	unittests/gdb_tilde_expand-selftests.c.
> 	* unittests/gdb_tilde_expand-selftests.c: New file.
> 
> gdbsupport/ChangeLog:
> 
> 	* gdb_tilde_expand.cc (gdb_tilde_expand): Improve
> 	implementation.
> 	(gdb_tilde_expand_up): Delegate logic to gdb_tilde_expand.
> 	* gdb_tilde_expand.h (gdb_tilde_expand): Update description.

This is ok.  Did you get your sourceware account?  Once you do, you can push
a commit to add yourself to gdb/MAINTAINERS (just look up previous commit that
touch this file for examples).

Simon


More information about the Gdb-patches mailing list