This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Disable check for NUL bytes in /proc/pid/cmdline
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: "Vladimir Nikulichev" <nvs at tbricks dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 11 Apr 2014 13:36:47 -0300
- Subject: Re: [PATCH] Disable check for NUL bytes in /proc/pid/cmdline
- Authentication-results: sourceware.org; auth=none
- References: <web-7508899 at mx2 dot tbricks dot com>
On Friday, April 11 2014, Vladimir Nikulichev wrote:
> When I execute gcore on a process, it prints warning that
> /proc/pid/cmdline
> contains null characters:
>
> $ gcore 18706
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> 0x00007fa23be3c5c3 in __select_nocancel () from /lib64/libc.so.6
> warning: target file /proc/18706/cmdline contained unexpected null
> characters
> Saved corefile core.18706
>
> There's nothing wrong, null characters separate command line arguments
> from
> each other. This fix disables the check when reading cmdline.
Thanks for the patch.
> index 1b48f79..e6f9c3c 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -2895,7 +2895,7 @@ target_fileio_read_alloc (const char *filename,
> gdb_byte **buf_p)
> if the result contains any embedded NUL bytes. */
>
> char *
> -target_fileio_read_stralloc (const char *filename)
> +target_fileio_read_stralloc (const char *filename, int check_null)
> {
Shouldn't this argument be named "check_nul", since we are talking about
the NUL byte?
> diff --git a/gdb/target.h b/gdb/target.h
> index d7c6c3d..2d11a99 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -1890,7 +1890,8 @@ extern LONGEST target_fileio_read_alloc (const
> char *filename,
> or the transfer is unsupported, NULL is returned. Empty objects
> are returned as allocated but empty strings. A warning is issued
> if the result contains any embedded NUL bytes. */
> -extern char *target_fileio_read_stralloc (const char *filename);
> +extern char *target_fileio_read_stralloc (const char *filename,
> + int check_null);
The comment could be expanded to explain what "check_nul" does.
Thanks,
--
Sergio