function instrument_file($filename) { //echo "Instrumenting file : $filename"; global $unique_trace_id, $just_remove_instrumentation; global $html_output, $newline, $braket_level, $file_trace_id, $function_trace_id, $file_thread_ID, $skip_instrument; $infile = fopen($filename, "r"); //no way if (!$infile) { return; } // $html_output="<br>"; $html_output = ""; $newline = "\r\n"; $result_file = ""; $braket_level = 0; $file_trace_id = 0; //some way to subidentify this trace call $function_trace_id = 0; //some way to subidentify this trace call $file_thread_ID = "GetCurrentThreadId()"; //some way to identify in which thread this callstack is $skip_instrument = 0; //for enum,struct,class $big_comment_detected = 0; // if we are inside /**/ then we do not process data $prev_line = ""; while (!feof($infile)) { $line = fgets($infile); //skip already inserted instrumentation if (strpos("#" . $line, "INSTRUMENTATION_CALLSTACK_MONITOR") != 0) { continue; } if ($just_remove_instrumentation != 1) { /* //in case line containes more then 1 { we will reformat it into multiple lines each containing only 1 $line2=str_replace(array("\n","\r"),"",$line); $line2=str_replace("{","NO_FRIKKIN_WAY_TO_HAVETHIS_TWICE{NO_FRIKKIN_WAY_TO_HAVETHIS_TWICE",$line2); $line2=str_replace("}","NO_FRIKKIN_WAY_TO_HAVETHIS_TWICE}NO_FRIKKIN_WAY_TO_HAVETHIS_TWICE",$line2); $sublines = explode("NO_FRIKKIN_WAY_TO_HAVETHIS_TWICE",$line2); //echo $line2."<br>"; if( count($sublines ) > 3 ) //1 braket = 3 parts { $new_line=""; foreach($sublines as $key => $line3 ) if( strlen(trim($line)) > 0 ) { $t = instrument_1_line($line3); if(strpos("#".$t,"\n")!=0) $new_line.=$t; else $new_line.=$t."{$newline}".$html_output; } $line = $new_line; } else if( count($sublines ) > 1 ) $line = instrument_1_line($line); else $line = $line;*/ $line = instrument_1_line($line, $prev_line); } $prev_line = $line; $result_file .= $line . "{$html_output}"; } $file_trace_id++; fclose($infile); return $result_file; }
function instrument_file($filename, $ident, $macro) { //echo "Instrumenting file : $filename"; global $just_remove_instrumentation; global $html_output, $newline, $braket_level, $file_trace_id, $function_trace_id, $file_thread_ID, $skip_instrument; global $found_object_function; $infile = fopen($filename, "r"); //no way if (!$infile) { return; } // $html_output="<br>"; $html_output = ""; $newline = "\r\n"; $result_file = ""; $braket_level = 0; $skip_instrument = 0; //for enum,struct,class $big_comment_detected = 0; // if we are inside /**/ then we do not process data $found_object_function = 0; $prev_line = ""; while (!feof($infile)) { $line = fgets($infile); //skip already inserted instrumentation if (strpos("#" . $line, $macro) != 0) { continue; } if ($just_remove_instrumentation != 1) { $line = instrument_1_line($line, $prev_line, $ident, $macro); } $prev_line = $line; $result_file .= $line . "{$html_output}"; } $file_trace_id++; fclose($infile); return $result_file; }