This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: Simple but crucial bug fix to gdb


> Daniel Berlin <dan@cgsoftware.com> writes:
> 
> : [...]
> : However, we should *never* see a case where pst is NULL, and
> : textlow_not_set is 1, at the point we see a function.
> : [...]
> 
> Would a gdb_assert() to this effect satisfy all sides?
> 
> - FChE


Yes.

gdb_assert() and internal_error() are for reporting problems internal to 
gdb.  EG: a check for a NULL reference caused by GDB failing to 
detect/handle bad input.  Both of these functions force GDB to abandon 
the current command.

warning() and error() should only be used when the problem is caused by 
an external interface/input _and_ GDB correctly recovered.  EG: a 
warning() to notify the user that a file is corrupt but GDB has managed 
to recover from the problem.  You migt even end up with:

	if (recovery case 1)
	  warning (...); recover;
	else if (recovery case 2)
	  warning (...); recover;
	else
	  internal_error (oops, stuffed);

The difference is subtle but important.  I'd only think about replacing 
gdb_assert() / internal_error() with warning() / error() when it is 
clear that the problem isn't internal to GDB and that GDB is correctly 
recovering from it.

	Andrew



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