Sfoglia il codice sorgente

[eval] limit length of Bytes string when debugging

eventually there should be some extra fields, see #8029
Jens Fischer 6 anni fa
parent
commit
a680099253
2 ha cambiato i file con 11 aggiunte e 2 eliminazioni
  1. 1 1
      src/compiler/main.ml
  2. 10 1
      src/macro/eval/evalDebugSocket.ml

+ 1 - 1
src/compiler/main.ml

@@ -565,7 +565,7 @@ try
 			let raise_reserved description =
 				raise (Arg.Bad (description ^ " and cannot be defined from the command line"))
 			in
-			if List.mem var reserved_flags then raise_reserved (Printf.sprintf "`%s` is a reserved copiler flag" var);
+			if List.mem var reserved_flags then raise_reserved (Printf.sprintf "`%s` is a reserved compiler flag" var);
 			List.iter (fun ns ->
 				if ExtString.String.starts_with var (ns ^ ".") then raise_reserved (Printf.sprintf "`%s` uses the reserved compiler flag namespace `%s.*`" var ns)
 			) reserved_flag_namespaces;

+ 10 - 1
src/macro/eval/evalDebugSocket.ml

@@ -95,7 +95,16 @@ let var_to_json name value vio env =
 		| VArray va -> jv "Array" (array_elems (EvalArray.to_list va)) va.alength
 		| VVector vv -> jv "Vector" (array_elems (Array.to_list vv)) (Array.length vv)
 		| VInstance vi ->
-			let class_name = EvalDebugMisc.safe_call env.env_eval EvalPrinting.value_string v in
+			let class_name () = EvalDebugMisc.safe_call env.env_eval EvalPrinting.value_string v in
+            let num_children,class_name = match vi.ikind with
+            | IMutex _ -> 1,class_name()
+            | IThread _ -> 1,class_name()
+            | IBytes bytes ->
+				let max = 40 in
+				let s = Bytes.to_string bytes in
+				List.length (instance_fields vi),String.sub s 0 max ^ (if String.length s > max then "..." else "")
+            | _ -> List.length (instance_fields vi),class_name()
+            in
 			let num_children = match vi.ikind with
 			| IMutex _ -> 1
 			| IThread _ -> 1