mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Debugging: Add PIOS_DEBUG_Panic() call wen an UAVObject handle is requested but object is uninitialized, make PiOS.posix bail in case of a Panic with an error message
This commit is contained in:
parent
01a844e0da
commit
78e42470d4
@ -79,8 +79,15 @@ void PIOS_DEBUG_Panic(const char *msg)
|
|||||||
PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, "\r%s @0x%x\r", msg, lr);
|
PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, "\r%s @0x%x\r", msg, lr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Stay put
|
// tell the user whats going on on commandline too
|
||||||
while (1) ;
|
fprintf(stderr,"CRITICAL ERROR: %s\n",msg);
|
||||||
|
|
||||||
|
// this helps debugging: causing a div by zero allows a backtrace
|
||||||
|
// and/or ends execution
|
||||||
|
int b = 0;
|
||||||
|
int a = (2/b);
|
||||||
|
b=a;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "$(NAMELC).h"
|
#include "$(NAMELC).h"
|
||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
static UAVObjHandle handle;
|
static UAVObjHandle handle = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize object.
|
* Initialize object.
|
||||||
@ -103,6 +103,7 @@ $(INITFIELDS)
|
|||||||
*/
|
*/
|
||||||
UAVObjHandle $(NAME)Handle()
|
UAVObjHandle $(NAME)Handle()
|
||||||
{
|
{
|
||||||
|
if (!handle) PIOS_DEBUG_Panic("$(NAME) used uninitialized");
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user