CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
dbg_dump.c-Dateireferenz
#include "camera_info.h"
#include "conf.h"
#include "script.h"
#include "meminfo.h"
#include "cache.h"
#include "module_load.h"
#include "clock.h"
#include "cachebit.h"
#include "time.h"
+ Include-Abhängigkeitsdiagramm für dbg_dump.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  dumpheader
 
struct  mod_info
 
union  dumpinfo
 

Makrodefinitionen

#define DBG_DUMP_FL_NOMEMINFO   0x1
 
#define DBG_DUMP_FL_NOEXMEMINFO   0x2
 
#define DBG_DUMP_VERSION   2
 
#define STACK_DUMP_COUNT   512
 

Funktionen

void dbg_dump_write (const char *dumpname, unsigned flags, int user_data_len, char *user_data)
 
void dbg_dump_assert (const char *dumpfile, const char *expr, const char *file, int line)
 

Makro-Dokumentation

#define DBG_DUMP_FL_NOEXMEMINFO   0x2

Definiert in Zeile 14 der Datei dbg_dump.c.

#define DBG_DUMP_FL_NOMEMINFO   0x1

Definiert in Zeile 13 der Datei dbg_dump.c.

#define DBG_DUMP_VERSION   2

Definiert in Zeile 16 der Datei dbg_dump.c.

#define STACK_DUMP_COUNT   512

Definiert in Zeile 64 der Datei dbg_dump.c.

Dokumentation der Funktionen

void dbg_dump_assert ( const char *  dumpfile,
const char *  expr,
const char *  file,
int  line 
)

Definiert in Zeile 161 der Datei dbg_dump.c.

161  {
162  static char buf[128]; // could overflow if expr is long
163  sprintf(buf,"ASSERT %s:%d %s",file,line,expr);
164  script_console_add_error( (long)buf );
165  dbg_dump_write(dumpfile,0,sizeof(buf),buf);
166 }
void dbg_dump_write ( const char *  dumpname,
unsigned  flags,
int  user_data_len,
char *  user_data 
)

Definiert in Zeile 67 der Datei dbg_dump.c.

67  {
68  static dumpinfo buf;
69  // convenient access to uncached version
70  dumpinfo *pb = ADR_TO_UNCACHED(&buf);
71 
72  // use open + uncached mem because we may not have enough memory for fopen
73  int fd=open(dumpname, O_WRONLY|O_CREAT|O_TRUNC, 0777);
74  if(fd >= 0) {
75  int *sp;
76  asm volatile( "MOV %0,SP\n" :"=r"(sp));
77  pb->h.ver = DBG_DUMP_VERSION;
78  pb->h.time = time(NULL);
79  pb->h.tick = get_tick_count();
88  pb->h.sp = (int)sp;
90  if(user_data) {
91  pb->h.user_data_len = user_data_len;
92  pb->h.user_val = (int)user_data;
93  } else {
94  pb->h.user_data_len = 0;
95  pb->h.user_val = user_data_len;
96  }
97 
98  pb->h.flags = flags;
99 
100  int m_count=0;
101  // count so we can store it in the header
102  int i;
103  for(i=0;i<MAX_NUM_LOADED_MODULES;i++) {
104  const module_entry *m = module_get_adr(i);
105  if(m) {
106  m_count++;
107  }
108  }
109  pb->h.module_count = m_count;
110  pb->h.module_info_size = sizeof(mod_info);
111  sprintf(pb->h.build_string,"%s,%s,%s,%s,%s,%s",
118 
119  write(fd,&pb->h,sizeof(dumpheader));
120 
121  if(!(flags & DBG_DUMP_FL_NOMEMINFO)) {
122  GetMemInfo(&pb->m);
123  } else {
124  memset(&pb->m,0,sizeof(cam_meminfo));
125  }
126  write(fd,&pb->m,sizeof(cam_meminfo));
127 
128  // if no exmem don't check
129  memset(&pb->m,0,sizeof(cam_meminfo));
130  if(!(flags & DBG_DUMP_FL_NOEXMEMINFO)) {
131  GetExMemInfo(&pb->m);
132  }
133  write(fd,&pb->m,sizeof(cam_meminfo));
134 
135  // assume modules haven't gone away since count, might not be valid?
136  for(i=0;i<MAX_NUM_LOADED_MODULES;i++) {
137  const module_entry *m = module_get_adr(i);
138  if(!m) {
139  continue;
140  }
141  pb->mi.index = i;
142  memcpy(&pb->mi.m,m,sizeof(module_entry));
143  memcpy(&pb->mi.h,m->hdr,sizeof(flat_hdr));
144  write(fd,&pb->mi,sizeof(mod_info));
145  }
146 
147  // clean cache for write()
149 
151  if(user_data_len && user_data) {
152  // we assume user_data has been flushed out by preceding
153  write(fd,ADR_TO_UNCACHED(user_data),user_data_len);
154  }
155  close(fd);
156  } else {
157  script_console_add_error( (long)"failed to open dump file" );
158  }
159 }