| 1310 | */ |
| 1311 | |
| 1312 | LIST * builtin_backtrace( FRAME * frame, int flags ) |
| 1313 | { |
| 1314 | LIST * const levels_arg = lol_get( frame->args, 0 ); |
| 1315 | int levels = list_empty( levels_arg ) |
| 1316 | ? (int)( (unsigned int)(-1) >> 1 ) |
| 1317 | : atoi( object_str( list_front( levels_arg ) ) ); |
| 1318 | |
| 1319 | LIST * result = L0; |
| 1320 | for ( ; ( frame = frame->prev ) && levels; --levels ) |
| 1321 | { |
| 1322 | char const * file; |
| 1323 | int line; |
| 1324 | char buf[ 32 ]; |
| 1325 | string module_name[ 1 ]; |
| 1326 | get_source_line( frame, &file, &line ); |
| 1327 | sprintf( buf, "%d", line ); |
| 1328 | string_new( module_name ); |
| 1329 | if ( frame->module->name ) |
| 1330 | { |
| 1331 | string_append( module_name, object_str( frame->module->name ) ); |
| 1332 | string_append( module_name, "." ); |
| 1333 | } |
| 1334 | result = list_push_back( result, object_new( file ) ); |
| 1335 | result = list_push_back( result, object_new( buf ) ); |
| 1336 | result = list_push_back( result, object_new( module_name->value ) ); |
| 1337 | result = list_push_back( result, object_new( frame->rulename ) ); |
| 1338 | string_free( module_name ); |
| 1339 | } |
| 1340 | return result; |
| 1341 | } |
| 1342 | |
| 1343 | |
| 1344 | /* |
nothing calls this directly
no test coverage detected