| 1372 | */ |
| 1373 | |
| 1374 | LIST * builtin_backtrace( FRAME * frame, int flags ) |
| 1375 | { |
| 1376 | LIST * const levels_arg = lol_get( frame->args, 0 ); |
| 1377 | int levels = list_empty( levels_arg ) |
| 1378 | ? (int)( (unsigned int)(-1) >> 1 ) |
| 1379 | : atoi( object_str( list_front( levels_arg ) ) ); |
| 1380 | |
| 1381 | LIST * result = L0; |
| 1382 | for ( ; ( frame = frame->prev ) && levels; --levels ) |
| 1383 | { |
| 1384 | char const * file; |
| 1385 | int line; |
| 1386 | char buf[ 32 ]; |
| 1387 | string module_name[ 1 ]; |
| 1388 | get_source_line( frame, &file, &line ); |
| 1389 | sprintf( buf, "%d", line ); |
| 1390 | string_new( module_name ); |
| 1391 | if ( frame->module->name ) |
| 1392 | { |
| 1393 | string_append( module_name, object_str( frame->module->name ) ); |
| 1394 | string_append( module_name, "." ); |
| 1395 | } |
| 1396 | result = list_push_back( result, object_new( file ) ); |
| 1397 | result = list_push_back( result, object_new( buf ) ); |
| 1398 | result = list_push_back( result, object_new( module_name->value ) ); |
| 1399 | result = list_push_back( result, object_new( frame->rulename ) ); |
| 1400 | string_free( module_name ); |
| 1401 | } |
| 1402 | return result; |
| 1403 | } |
| 1404 | |
| 1405 | |
| 1406 | /* |
nothing calls this directly
no test coverage detected