39 print(
PSTR(
"Cosa/Debug 1.0 Copyright (C) 2015\nDebug::begin:"));
40 run(file, line, func);
51 run(file, line, func, cond);
64 run(file, line, func, cond);
70 uint16_t marker = 0xA5A5;
71 int HEAPEND = (__brkval == 0 ? (int) &__heap_start : (
int)
__brkval);
72 int STACKSTART = (int) ▮
73 return (STACKSTART > HEAPEND + room);
91 uint16_t marker = 0xA5A5;
97 memset(buf, 0,
sizeof(buf));
101 size_t len = strlen(buf) - 1;
102 if (buf[len] !=
'\n')
continue;
103 if (len == 0)
continue;
108 #if !defined(COSA_DEBUG_NO_BACKTRACE) 116 #if !defined(COSA_DEBUG_NO_PRINT_DATA) 123 #if !defined(COSA_DEBUG_NO_PRINT_HEAP) 130 #if !defined(COSA_DEBUG_NO_HELP) 137 #if !defined(COSA_DEBUG_NO_MEMORY_USAGE) 144 #if !defined(COSA_DEBUG_NO_PRINT_STACK) 151 #if !defined(COSA_DEBUG_NO_PRINT_VARIABLES) 158 #if !defined(COSA_DEBUG_NO_QUIT) 166 #if !defined(COSA_DEBUG_NO_WHERE) 173 #if !defined(COSA_DEBUG_NO_LOOKUP_VARIABLES) 175 const char* name = buf + 1;
185 #if !defined(COSA_DEBUG_NO_BACKTRACE) 190 if (func != vp->m_func) {
198 #if !defined(COSA_DEBUG_NO_HELP) 202 static const char help[] PROGMEM =
203 #if !defined(COSA_DEBUG_NO_LOOKUP_VARIABLES) 204 "?VARIABLE -- print variable(s)\n" 206 #if !defined(COSA_DEBUG_NO_BACKTRACE) 207 "backtrace -- print call stack\n" 209 #if !defined(COSA_DEBUG_NO_PRINT_DATA) 210 "data -- print data\n" 212 "go -- return to sketch\n" 213 #if !defined(COSA_DEBUG_NO_PRINT_HEAP) 214 "heap -- print heap\n" 216 #if !defined(COSA_DEBUG_NO_MEMORY_USAGE) 217 "memory -- print memory usage\n" 219 #if !defined(COSA_DEBUG_NO_QUIT) 220 "quit -- exit sketch\n" 222 #if !defined(COSA_DEBUG_NO_PRINT_STACK) 223 "stack -- print stack\n" 225 #if !defined(COSA_DEBUG_NO_PRINT_REGISTER) 226 "variables -- print variables\n" 228 #if !defined(COSA_DEBUG_NO_WHERE) 229 "where -- location in source code\n" 236 #if !defined(COSA_DEBUG_NO_LOOKUP_VARIABLES) 242 if (
strcmp_P(name, vp->m_name) == 0) {
251 #if !defined(COSA_DEBUG_NO_MEMORY_USAGE) 255 int HEAPEND = (__brkval == 0 ? (int) &__heap_start : (
int)
__brkval);
256 printf(
PSTR(
"data=%d,heap=%d,stack=%d,free=%d\n"),
258 HEAPEND - (
int) &__heap_start,
264 #if !defined(COSA_DEBUG_NO_PRINT_DATA) 272 #if !defined(COSA_DEBUG_NO_PRINT_HEAP) 276 int HEAPSTART = (int) &__heap_start;
277 int HEAPEND = (__brkval == 0 ? (int) &__heap_start : (
int)
__brkval);
278 int size = HEAPEND - HEAPSTART;
279 if (size == 0)
return;
284 #if !defined(COSA_DEBUG_NO_PRINT_STACK) 288 int size = RAMEND - marker + 1;
289 if (size == 0)
return;
294 #if !defined(COSA_DEBUG_NO_PRINT_VARIABLES) 309 else if (m_size == 2) {
int strncmp_P(const char *s1, str_P s2, size_t n)
void print(int value, Base base=dec)
void run(const char *file=NULL, int line=0, const char *func=NULL, str_P expr=NULL)
void do_print_stack(int marker)
bool check_stack(int room=128)
void do_print_variables()
char EXITCHARACTER
Character to emit on exit.
void do_backtrace(const char *func)
void assert(const char *file, int line, const char *func, str_P cond)
void printf(str_P format,...)
bool begin(IOStream::Device *dev, const char *file, int line, const char *func)
Variable * m_var
Last registered variable.
char * readline(char *buf, size_t size, bool echo=true)
const class prog_str * str_P
void do_memory_usage(int marker)
int DATAEND
End of data segment.
void break_at(const char *file, int line, const char *func, str_P cond)
int DATASIZE
Size of data segment.
bool do_lookup_variables(const char *name)
Device * m_dev
Delegated device.
static const size_t BUF_MAX
int strcmp_P(const char *s1, str_P s2)