|
From: David F. <fa...@kd...> - 2018-11-19 15:52:53
|
When using vgdb (e.g. `valgrind --vgdb-error=0 myprog`)
and there's a valgrind warning for an uninitialized read, on a line like
if (a || b)
The question that happens then is, of course, was it a or b that was
uninitialized. If one uses vgdb to print the values of a and b, it won't
necessarily be obvious (e.g. two bools, both happen to show as "false", with
only one actually uninitialized). This makes me wonder, wouldn't it be
possible for vgdb to output a warning when doing "print a" or "print b" from
gdb and the value is marked as uninitialized?
If I understand the architecture correctly, this should be possible to
implement, right?
--
David Faure | dav...@kd... | Managing Director KDAB France
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts
|
|
From: Ivo R. <iv...@iv...> - 2018-11-20 09:36:14
|
Il giorno lun 19 nov 2018 alle ore 16:53 David Faure <fa...@kd...> ha scritto: > > When using vgdb (e.g. `valgrind --vgdb-error=0 myprog`) > and there's a valgrind warning for an uninitialized read, on a line like > if (a || b) > > The question that happens then is, of course, was it a or b that was > uninitialized. If one uses vgdb to print the values of a and b, it won't > necessarily be obvious (e.g. two bools, both happen to show as "false", with > only one actually uninitialized). This makes me wonder, wouldn't it be > possible for vgdb to output a warning when doing "print a" or "print b" from > gdb and the value is marked as uninitialized? > > If I understand the architecture correctly, this should be possible to > implement, right? I do not want to estimate how feasible would be to implement this feature. Patches are welcome, of course. But you can use an existing feature: http://valgrind.org/docs/manual/mc-manual.html#mc-manual.machine http://valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands This will give you what (I think) you want. I. |
|
From: Philippe W. <phi...@sk...> - 2018-11-20 20:34:46
|
On Tue, 2018-11-20 at 10:35 +0100, Ivo Raisr wrote: > Il giorno lun 19 nov 2018 alle ore 16:53 David Faure <fa...@kd...> ha scritto: > > > > When using vgdb (e.g. `valgrind --vgdb-error=0 myprog`) > > and there's a valgrind warning for an uninitialized read, on a line like > > if (a || b) > > > > The question that happens then is, of course, was it a or b that was > > uninitialized. If one uses vgdb to print the values of a and b, it won't > > necessarily be obvious (e.g. two bools, both happen to show as "false", with > > only one actually uninitialized). This makes me wonder, wouldn't it be > > possible for vgdb to output a warning when doing "print a" or "print b" from > > gdb and the value is marked as uninitialized? > > > > If I understand the architecture correctly, this should be possible to > > implement, right? > > I do not want to estimate how feasible would be to implement this feature. > Patches are welcome, of course. > > But you can use an existing feature: > http://valgrind.org/docs/manual/mc-manual.html#mc-manual.machine > http://valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands > > This will give you what (I think) you want. Yes, using e.g. the monitor command xb allows to look at the V bits: you need to know the address (and len) of the value you want to look at. If a value is in a register, then you have to print the shadow register. For what concerns automatically printing warnings when GDB prints a 'non initialised' value: I think this is not very easy, and will likely give many false positives : the valgrind gdbserver has no idea why GDB asks to read some memory and/or asks to read the registers. In particular, GDB will very likely often read all the registers (including the one having uninitialised values). The GDB protocol also does not allow to read individual bits, and so, when a part of a byte is not initialised (but correctly so, i.e. not used by the program), printing the variable will give a warning. So, in summary, would be a nice thing to do, but I see no way to do it properly. Philippe |