MCPcopy Create free account
hub / github.com/TASEmulators/fceux / dbgFileLoad

Method dbgFileLoad

src/ld65dbg.cpp:263–405  ·  view source on GitHub ↗

---------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

261 }
262 //---------------------------------------------------------------------------------------------------
263 int database::dbgFileLoad( const char *dbgFilePath )
264 {
265 static constexpr size_t lineSize = 4096;
266 FILE *fp;
267 dbgLine line( lineSize );
268 char lineType[64];
269 fceuScopedPtr <char> keyValueBuffer( new char[ lineSize ], FCEU_ALLOC_TYPE_NEW_ARRAY );
270
271 fp = ::fopen( dbgFilePath, "r");
272
273 if (fp == NULL)
274 {
275 return -1;
276 }
277
278 while ( line.readFromFile(fp) != NULL )
279 {
280 //printf("%s", line.getLine());
281
282 if ( line.readToken( lineType, sizeof(lineType) ) )
283 {
284 int id = -1, size = 0, startAddr = 0, ofs = -1, parentID = -1, scopeID = -1, segmentID = -1;
285 int value = 0;
286 unsigned char segType = segment::READ;
287 char name[256];
288 char type[32];
289
290 name[0] = 0;
291 type[0] = 0;
292
293 while ( line.readKeyValuePair( keyValueBuffer.get(), lineSize) )
294 {
295 char *key, *val;
296
297 line.splitKeyValuePair( keyValueBuffer.get(), &key, &val );
298
299 //printf(" Key '%s' -> Value '%s' \n", key, val );
300
301 if ( strcmp( key, "id") == 0 )
302 {
303 id = strtol( val, nullptr, 0 );
304 }
305 else if ( strcmp( key, "name") == 0 )
306 {
307 strncpy( name, val, sizeof(name));
308 }
309 else if ( strcmp( key, "size") == 0 )
310 {
311 size = strtol( val, nullptr, 0 );
312 }
313 else if ( strcmp( key, "val") == 0 )
314 {
315 value = strtol( val, nullptr, 0 );
316 }
317 else if ( strcmp( key, "scope") == 0 )
318 {
319 scopeID = strtol( val, nullptr, 0 );
320 }

Callers 1

ld65LoadDebugFileMethod · 0.80

Calls 5

readFromFileMethod · 0.80
readTokenMethod · 0.80
readKeyValuePairMethod · 0.80
splitKeyValuePairMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected