This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fixup gdb.python/py-value.exp for bare-metal aarch64-elf

On 10/07/2016 05:23 AM, Yao Qi wrote:
On Thu, Oct 6, 2016 at 5:27 PM, Luis Machado <> wrote:
I noticed that testing aarch64-elf gdb with a physical board
ran into issues with gdb.python/py-value.exp. Further investigation showed
that we were actually trying to dereference a NULL pointer (argv) when trying
to access argv[0].

Being bare-metal, argv is not guaranteed to be there. So we need to make sure
argv is sane before accessing argv[0].

After fixing that, i noticed we were assuming a value of 1 for argc, which is
also not true, as i see 0 in my tests.

If I understand C standard correctly,
"argv" can't be NULL. Program startup
 The value of argc shall be nonnegative.
 argv[argc] shall be a null pointer.

The first one implies that argc can be zero, and the second one implies
argv can't be NULL.  In this case, argc is zero, so argv[0] can be

Ah, that makes sense indeed. Let me check the startup code and i'll get back to this patch (that may not be needed then).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]