Implemented state machine for SR4 autoconf #3

Merged
DataHoarder merged 1 commit from function-line-matching into master 2021-11-08 13:01:21 +00:00
Owner

Added logging on several functions, match line count of target better, patched differences

Modified how EPL state machine gets initialized

Use this script to debug differences with relative line numbers

<?php

$entries = [];
$indentation = [];

$r = [
 "#( pSwapRomImg=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#([hH]andle=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#( code=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#( glort=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#([pP]tr=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#( schedPortSpeeds=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#(= ?)(0x[0-9a-f]{8,})#" => '$1(ptr)',
];

$find = [];
$replace = [];

foreach($r as $k => $v){
	$find[] = $k;
	$replace[] = $v;
}

$stack = ["__main"];

while(!feof(STDIN) and ($line = fgets(STDIN)) !== false){
	$line = trim($line);
	$parts = explode(":", $line);
	$indent = 0;
	if(count($parts) >= 6){
		$p = $parts;
		switch($parts[0]){
			case "ENTRY":
				//Example: ENTRY:fsmd:alos/linux/fm_alos_alloc.c:fmAlloc:580:Entering... size=32
				$k = $p[1] . ":" . $p[2] . ":" . $p[3];

				//line number
				if(isset($entries[$k])){
					$entries[$k][] = (int) $p[4];
				}else{
					$entries[$k] = [(int) $p[4]];
				}

			case "EXIT":
			case "WARNING":
			case "ERROR":
			case "FATAL":
			case "INFO":
			case "DEBUG":
			case "PRINT":
			case "DEBUG2":
			case "DEBUG3":
			case "ASSERT":
			case "UNKNOWN_LVL":
				$k = $p[1] . ":" . $p[2] . ":" . $p[3];
				if(isset($entries[$k])){
					$parts[4] = "+" . (((int) $p[4]) - end($entries[$k])); //Relative position
				}else{
					$parts[4] = "@" . $p[4]; //Absolute position
				}

				if($parts[0] === "EXIT" and isset($entries[$k])){
					$indentation[$p[1]] = isset($indentation[$p[1]]) ? $indentation[$p[1]] - 1 : 0;
					array_pop($entries[$k]);
					if(count($entries[$k]) === 0){
						unset($entries[$k]);
					}

					do{

					}while(count($stack) > 0 and array_pop($stack) !== $p[3]);
					if(count($stack) === 0){
						echo "TOO MANY EXITS " . $p[3] . PHP_EOL;
					}

				}
				$parts[3] = end($stack) . " -> " . $parts[3];
				$indent = $indentation[$parts[1]] ?? 0;
				if($p[0] === "ENTRY"){
					$indentation[$p[1]] = isset($indentation[$p[1]]) ? $indentation[$p[1]] + 1 : 1;
					$stack[] = $p[3];
				}
				$parts[3] = "  " . $parts[3];
				unset($parts[2]); //Remove file name

				$parts[5] = preg_replace($find, $replace, $p[5]);
				break;
		}
	}

	echo str_repeat(" ", $indent) . implode(":", $parts) . PHP_EOL;
}

foreach($entries as $k => $missing){
	echo "$k is missing exit on ". count($missing) . " entries" . PHP_EOL;
}

Added logging on several functions, match line count of target better, patched differences Modified how EPL state machine gets initialized Use this script to debug differences with relative line numbers ```php <?php $entries = []; $indentation = []; $r = [ "#( pSwapRomImg=)(0x[0-9a-f]+)#" => '$1(ptr)', "#([hH]andle=)(0x[0-9a-f]+)#" => '$1(ptr)', "#( code=)(0x[0-9a-f]+)#" => '$1(ptr)', "#( glort=)(0x[0-9a-f]+)#" => '$1(ptr)', "#([pP]tr=)(0x[0-9a-f]+)#" => '$1(ptr)', "#( schedPortSpeeds=)(0x[0-9a-f]+)#" => '$1(ptr)', "#(= ?)(0x[0-9a-f]{8,})#" => '$1(ptr)', ]; $find = []; $replace = []; foreach($r as $k => $v){ $find[] = $k; $replace[] = $v; } $stack = ["__main"]; while(!feof(STDIN) and ($line = fgets(STDIN)) !== false){ $line = trim($line); $parts = explode(":", $line); $indent = 0; if(count($parts) >= 6){ $p = $parts; switch($parts[0]){ case "ENTRY": //Example: ENTRY:fsmd:alos/linux/fm_alos_alloc.c:fmAlloc:580:Entering... size=32 $k = $p[1] . ":" . $p[2] . ":" . $p[3]; //line number if(isset($entries[$k])){ $entries[$k][] = (int) $p[4]; }else{ $entries[$k] = [(int) $p[4]]; } case "EXIT": case "WARNING": case "ERROR": case "FATAL": case "INFO": case "DEBUG": case "PRINT": case "DEBUG2": case "DEBUG3": case "ASSERT": case "UNKNOWN_LVL": $k = $p[1] . ":" . $p[2] . ":" . $p[3]; if(isset($entries[$k])){ $parts[4] = "+" . (((int) $p[4]) - end($entries[$k])); //Relative position }else{ $parts[4] = "@" . $p[4]; //Absolute position } if($parts[0] === "EXIT" and isset($entries[$k])){ $indentation[$p[1]] = isset($indentation[$p[1]]) ? $indentation[$p[1]] - 1 : 0; array_pop($entries[$k]); if(count($entries[$k]) === 0){ unset($entries[$k]); } do{ }while(count($stack) > 0 and array_pop($stack) !== $p[3]); if(count($stack) === 0){ echo "TOO MANY EXITS " . $p[3] . PHP_EOL; } } $parts[3] = end($stack) . " -> " . $parts[3]; $indent = $indentation[$parts[1]] ?? 0; if($p[0] === "ENTRY"){ $indentation[$p[1]] = isset($indentation[$p[1]]) ? $indentation[$p[1]] + 1 : 1; $stack[] = $p[3]; } $parts[3] = " " . $parts[3]; unset($parts[2]); //Remove file name $parts[5] = preg_replace($find, $replace, $p[5]); break; } } echo str_repeat(" ", $indent) . implode(":", $parts) . PHP_EOL; } foreach($entries as $k => $missing){ echo "$k is missing exit on ". count($missing) . " entries" . PHP_EOL; } ```
DataHoarder added 1 commit 2021-11-08 12:46:01 +00:00
Added logging on several functions, match line count of target better, patched differences
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
e2392eadf7
Modified how EPL state machine gets initialized

Use this script to debug differences with relative line numbers

```php
<?php

$entries = [];
$indentation = [];

$r = [
 "#( pSwapRomImg=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#([hH]andle=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#( code=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#( glort=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#([pP]tr=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#( schedPortSpeeds=)(0x[0-9a-f]+)#" => '$1(ptr)',
 "#(= ?)(0x[0-9a-f]{8,})#" => '$1(ptr)',
];

$find = [];
$replace = [];

foreach($r as $k => $v){
	$find[] = $k;
	$replace[] = $v;
}

$stack = ["__main"];

while(!feof(STDIN) and ($line = fgets(STDIN)) !== false){
	$line = trim($line);
	$parts = explode(":", $line);
	$indent = 0;
	if(count($parts) >= 6){
		$p = $parts;
		switch($parts[0]){
			case "ENTRY":
				//Example: ENTRY:fsmd:alos/linux/fm_alos_alloc.c:fmAlloc:580:Entering... size=32
				$k = $p[1] . ":" . $p[2] . ":" . $p[3];

				//line number
				if(isset($entries[$k])){
					$entries[$k][] = (int) $p[4];
				}else{
					$entries[$k] = [(int) $p[4]];
				}

			case "EXIT":
			case "WARNING":
			case "ERROR":
			case "FATAL":
			case "INFO":
			case "DEBUG":
			case "PRINT":
			case "DEBUG2":
			case "DEBUG3":
			case "ASSERT":
			case "UNKNOWN_LVL":
				$k = $p[1] . ":" . $p[2] . ":" . $p[3];
				if(isset($entries[$k])){
					$parts[4] = "+" . (((int) $p[4]) - end($entries[$k])); //Relative position
				}else{
					$parts[4] = "@" . $p[4]; //Absolute position
				}

				if($parts[0] === "EXIT" and isset($entries[$k])){
					$indentation[$p[1]] = isset($indentation[$p[1]]) ? $indentation[$p[1]] - 1 : 0;
					array_pop($entries[$k]);
					if(count($entries[$k]) === 0){
						unset($entries[$k]);
					}

					do{

					}while(count($stack) > 0 and array_pop($stack) !== $p[3]);
					if(count($stack) === 0){
						echo "TOO MANY EXITS " . $p[3] . PHP_EOL;
					}

				}
				$parts[3] = end($stack) . " -> " . $parts[3];
				$indent = $indentation[$parts[1]] ?? 0;
				if($p[0] === "ENTRY"){
					$indentation[$p[1]] = isset($indentation[$p[1]]) ? $indentation[$p[1]] + 1 : 1;
					$stack[] = $p[3];
				}
				$parts[3] = "  " . $parts[3];
				unset($parts[2]); //Remove file name

				$parts[5] = preg_replace($find, $replace, $p[5]);
				break;
		}
	}

	echo str_repeat(" ", $indent) . implode(":", $parts) . PHP_EOL;
}

foreach($entries as $k => $missing){
	echo "$k is missing exit on ". count($missing) . " entries" . PHP_EOL;
}

```
DataHoarder merged commit e2392eadf7 into master 2021-11-08 13:01:21 +00:00
DataHoarder deleted branch function-line-matching 2021-11-08 13:01:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: FM10K/IES#3
No description provided.