[debug] Adding the captured variable to the printing of the closures

Reviewed By: sblackshear

Differential Revision: D6702916

fbshipit-source-id: c752691
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent d71d759344
commit 66b1956e9a

@ -246,8 +246,11 @@ let rec pp_ pe pp_t f e =
| Exn e -> | Exn e ->
F.fprintf f "EXN %a" pp_exp e F.fprintf f "EXN %a" pp_exp e
| Closure {name; captured_vars} -> | Closure {name; captured_vars} ->
let id_exps = List.map ~f:(fun (id_exp, _, _) -> id_exp) captured_vars in if List.is_empty captured_vars then F.fprintf f "(%a)" pp_exp (Const (Cfun name))
F.fprintf f "(%a)" (Pp.comma_seq pp_exp) (Const (Cfun name) :: id_exps) else
F.fprintf f "(%a,%a)" pp_exp (Const (Cfun name))
(Pp.comma_seq (pp_captured_var pe pp_t))
captured_vars
| Lvar pv -> | Lvar pv ->
Pvar.pp pe f pv Pvar.pp pe f pv
| Lfield (e, fld, _) -> | Lfield (e, fld, _) ->
@ -266,6 +269,14 @@ let rec pp_ pe pp_t f e =
subtype subtype
and pp_captured_var pe pp_t f (exp, var, _) =
match exp with
| Lvar evar when Pvar.equal var evar ->
F.fprintf f "%a" (Pvar.pp pe) var
| _ ->
F.fprintf f "(%a %a)" (pp_ pe pp_t) exp (Pvar.pp pe) var
let pp_printenv pe pp_typ f e = pp_ pe (pp_typ pe) f e let pp_printenv pe pp_typ f e = pp_ pe (pp_typ pe) f e
let pp f e = pp_printenv Pp.text Typ.pp f e let pp f e = pp_printenv Pp.text Typ.pp f e

@ -41,7 +41,7 @@ digraph iCFG {
"capture#A#instance.d411336575e4bf632a1828f5f5979726_2" [label="2: Exit A_capture \n " color=yellow style=filled] "capture#A#instance.d411336575e4bf632a1828f5f5979726_2" [label="2: Exit A_capture \n " color=yellow style=filled]
"capture#A#instance.d411336575e4bf632a1828f5f5979726_3" [label="3: Message Call: sHandler: \n n$0=*&self:A* [line 47, column 4]\n n$1=*n$0._b:B* [line 47, column 4]\n n$2=*&self:A* [line 47, column 16]\n _fun_B_sHandler:(n$1:B*,(_fun_objc_blockA_capture_1,n$2):_fn_(*)) virtual block_params [line 47, column 3]\n " shape="box"] "capture#A#instance.d411336575e4bf632a1828f5f5979726_3" [label="3: Message Call: sHandler: \n n$0=*&self:A* [line 47, column 4]\n n$1=*n$0._b:B* [line 47, column 4]\n n$2=*&self:A* [line 47, column 16]\n _fun_B_sHandler:(n$1:B*,(_fun_objc_blockA_capture_1,(n$2 &self)):_fn_(*)) virtual block_params [line 47, column 3]\n " shape="box"]
"capture#A#instance.d411336575e4bf632a1828f5f5979726_3" -> "capture#A#instance.d411336575e4bf632a1828f5f5979726_2" ; "capture#A#instance.d411336575e4bf632a1828f5f5979726_3" -> "capture#A#instance.d411336575e4bf632a1828f5f5979726_2" ;

@ -85,7 +85,7 @@ digraph iCFG {
"blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_3" -> "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_2" ; "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_3" -> "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_2" ;
"blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_4" [label="4: DeclStmt \n n$13=*&x:int* [line 33, column 28]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_blockPostBad_2,n$13) [line 33, column 3]\n " shape="box"] "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_4" [label="4: DeclStmt \n n$13=*&x:int* [line 33, column 28]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_blockPostBad_2,(n$13 &x)) [line 33, column 3]\n " shape="box"]
"blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_4" -> "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_3" ; "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_4" -> "blockPostBad#BlockVar#instance.60292f870cad8c1a5cefdbfe4194d6f9_3" ;
@ -104,7 +104,7 @@ digraph iCFG {
"blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_3" -> "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_2" ; "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_3" -> "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_2" ;
"blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_4" [label="4: DeclStmt \n n$18=*&x:int* [line 42, column 28]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_blockPostOk_3,n$18) [line 42, column 3]\n " shape="box"] "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_4" [label="4: DeclStmt \n n$18=*&x:int* [line 42, column 28]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_blockPostOk_3,(n$18 &x)) [line 42, column 3]\n " shape="box"]
"blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_4" -> "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_3" ; "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_4" -> "blockPostOk#BlockVar#instance.1bb64a946f8b169b31996644931ed82d_3" ;
@ -127,7 +127,7 @@ digraph iCFG {
"capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_3" -> "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_2" ; "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_3" -> "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_2" ;
"capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_4" [label="4: DeclStmt \n n$22=*&x:int* [line 50, column 27]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_capturedNullDeref_4,n$22) [line 50, column 3]\n " shape="box"] "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_4" [label="4: DeclStmt \n n$22=*&x:int* [line 50, column 27]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_capturedNullDeref_4,(n$22 &x)) [line 50, column 3]\n " shape="box"]
"capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_4" -> "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_3" ; "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_4" -> "capturedNullDeref#BlockVar#instance.48c44f7ae26caf7a1ac522523ebac894_3" ;
@ -150,7 +150,7 @@ digraph iCFG {
"capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_4" -> "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_3" ; "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_4" -> "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_3" ;
"capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_5" [label="5: DeclStmt \n n$27=*&x:int* [line 59, column 27]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_capturedNoNullDeref_5,n$27) [line 59, column 3]\n " shape="box"] "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_5" [label="5: DeclStmt \n n$27=*&x:int* [line 59, column 27]\n *&my_block:_fn_(*)=(_fun_objc_blockBlockVar_capturedNoNullDeref_5,(n$27 &x)) [line 59, column 3]\n " shape="box"]
"capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_5" -> "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_4" ; "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_5" -> "capturedNoNullDeref#BlockVar#instance.ebe646baaabdc58144a5916780ee8c76_4" ;

@ -11,7 +11,7 @@ digraph iCFG {
"f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_3" -> "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_2" ; "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_3" -> "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_2" ;
"f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_4" [label="4: Message Call: foo:and: \n n$2=*&self:B* [line 25, column 10]\n n$3=*n$2.h:int [line 25, column 10]\n n$4=*&self:B* const [line 26, column 11]\n _fun_B_foo:and:(n$3:int,(_fun_objc_blockB_f_1,n$4):_fn_(*)) block_params [line 25, column 3]\n " shape="box"] "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_4" [label="4: Message Call: foo:and: \n n$2=*&self:B* [line 25, column 10]\n n$3=*n$2.h:int [line 25, column 10]\n n$4=*&self:B* const [line 26, column 11]\n _fun_B_foo:and:(n$3:int,(_fun_objc_blockB_f_1,(n$4 &self)):_fn_(*)) block_params [line 25, column 3]\n " shape="box"]
"f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_4" -> "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_3" ; "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_4" -> "f#B#instance.f1371ff5e7f410d3df6a2e71ff0a814e_3" ;

@ -49,7 +49,7 @@ digraph iCFG {
"main1.38f534a9576db7ec6ebcbca8c111f942_7" -> "main1.38f534a9576db7ec6ebcbca8c111f942_6" ; "main1.38f534a9576db7ec6ebcbca8c111f942_7" -> "main1.38f534a9576db7ec6ebcbca8c111f942_6" ;
"main1.38f534a9576db7ec6ebcbca8c111f942_8" [label="8: BinaryOperatorStmt: Assign \n n$9=*&x:int [line 18, column 14]\n *&addblock:_fn_(*)=(_fun_objc_blockmain1_2,n$9) [line 18, column 3]\n " shape="box"] "main1.38f534a9576db7ec6ebcbca8c111f942_8" [label="8: BinaryOperatorStmt: Assign \n n$9=*&x:int [line 18, column 14]\n *&addblock:_fn_(*)=(_fun_objc_blockmain1_2,(n$9 &x)) [line 18, column 3]\n " shape="box"]
"main1.38f534a9576db7ec6ebcbca8c111f942_8" -> "main1.38f534a9576db7ec6ebcbca8c111f942_7" ; "main1.38f534a9576db7ec6ebcbca8c111f942_8" -> "main1.38f534a9576db7ec6ebcbca8c111f942_7" ;
@ -76,7 +76,7 @@ digraph iCFG {
"objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_4" -> "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_3" ; "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_4" -> "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_3" ;
"objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_5" [label="5: BinaryOperatorStmt: Assign \n n$15=*&x:int [line 24, column 17]\n n$16=*&bla:int [line 24, column 17]\n *&addblock2:_fn_(*)=(_fun_objc_blockobjc_blockmain1_2_3,n$15,n$16) [line 24, column 5]\n " shape="box"] "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_5" [label="5: BinaryOperatorStmt: Assign \n n$15=*&x:int [line 24, column 17]\n n$16=*&bla:int [line 24, column 17]\n *&addblock2:_fn_(*)=(_fun_objc_blockobjc_blockmain1_2_3,(n$15 &x),(n$16 &bla)) [line 24, column 5]\n " shape="box"]
"objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_5" -> "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_4" ; "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_5" -> "objc_blockmain1_2.0d332204bbe33f46a9283d2c0df5700a_4" ;

@ -44,7 +44,7 @@ digraph iCFG {
"m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_11" -> "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_10" ; "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_11" -> "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_10" ;
"m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_12" [label="12: BinaryOperatorStmt: Assign \n n$5=*&z:int [line 25, column 7]\n *&b:_fn_(*)=(_fun_objc_blockMy_manager_m_1,n$5) [line 25, column 3]\n " shape="box"] "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_12" [label="12: BinaryOperatorStmt: Assign \n n$5=*&z:int [line 25, column 7]\n *&b:_fn_(*)=(_fun_objc_blockMy_manager_m_1,(n$5 &z)) [line 25, column 3]\n " shape="box"]
"m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_12" -> "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_11" ; "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_12" -> "m#My_manager#instance.e773f849d062cb9801497b62f5c98f5e_11" ;

@ -32,7 +32,7 @@ digraph iCFG {
"blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_8" -> "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_5" ; "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_8" -> "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_5" ;
"blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_8" -> "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_6" ; "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_8" -> "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_6" ;
"blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_9" [label="9: BinaryOperatorStmt: Assign \n n$5=*&newImage:CGImage* [line 25, column 7]\n *&b:_fn_(*)=(_fun_objc_blockMy_manager_blockReleaseTODO_1,n$5) [line 25, column 3]\n " shape="box"] "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_9" [label="9: BinaryOperatorStmt: Assign \n n$5=*&newImage:CGImage* [line 25, column 7]\n *&b:_fn_(*)=(_fun_objc_blockMy_manager_blockReleaseTODO_1,(n$5 &newImage)) [line 25, column 3]\n " shape="box"]
"blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_9" -> "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_8" ; "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_9" -> "blockReleaseTODO#My_manager#instance.8c1d633cf596e86a307167d9425628a8_8" ;

@ -37,7 +37,7 @@ digraph iCFG {
"block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_3" -> "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_2" ; "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_3" -> "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_2" ;
"block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_4" [label="4: Call _fun__dispatch_once \n n$6=*&a:DispatchA* [line 39, column 24]\n _fun__dispatch_once(&#GB<codetoanalyze/objc/shared/block/dispatch.m>$DispatchA_block_attribute_once:long*,(_fun_objc_blockDispatchA_block_attribute_2,n$6):_fn_(*)) block_params [line 39, column 3]\n " shape="box"] "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_4" [label="4: Call _fun__dispatch_once \n n$6=*&a:DispatchA* [line 39, column 24]\n _fun__dispatch_once(&#GB<codetoanalyze/objc/shared/block/dispatch.m>$DispatchA_block_attribute_once:long*,(_fun_objc_blockDispatchA_block_attribute_2,(n$6 &a)):_fn_(*)) block_params [line 39, column 3]\n " shape="box"]
"block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_4" -> "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_3" ; "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_4" -> "block_attribute#DispatchA#class.df997e345dbf19ec3438c667c942e14a_3" ;

@ -188,7 +188,7 @@ digraph iCFG {
"blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_3" -> "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_2" ; "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_3" -> "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_2" ;
"blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_4" [label="4: DeclStmt \n n$42=*&x:int* [line 96, column 22]\n *&blk:_fn_(*)=(_fun_objc_blockMemoryLeakExample_blockCapturedVarLeak_1,n$42) [line 96, column 3]\n " shape="box"] "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_4" [label="4: DeclStmt \n n$42=*&x:int* [line 96, column 22]\n *&blk:_fn_(*)=(_fun_objc_blockMemoryLeakExample_blockCapturedVarLeak_1,(n$42 &x)) [line 96, column 3]\n " shape="box"]
"blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_4" -> "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_3" ; "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_4" -> "blockCapturedVarLeak#MemoryLeakExample#instance.53bb018bc84d6a696dc756e20b5b3f52_3" ;
@ -211,7 +211,7 @@ digraph iCFG {
"blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_3" -> "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_2" ; "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_3" -> "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_2" ;
"blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_4" [label="4: DeclStmt \n n$49=*&x:int* [line 105, column 22]\n *&blk:_fn_(*)=(_fun_objc_blockMemoryLeakExample_blockFreeNoLeakTODO_2,n$49) [line 105, column 3]\n " shape="box"] "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_4" [label="4: DeclStmt \n n$49=*&x:int* [line 105, column 22]\n *&blk:_fn_(*)=(_fun_objc_blockMemoryLeakExample_blockFreeNoLeakTODO_2,(n$49 &x)) [line 105, column 3]\n " shape="box"]
"blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_4" -> "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_3" ; "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_4" -> "blockFreeNoLeakTODO#MemoryLeakExample#instance.745cca07ccdb517734d79c9d7a1eaed8_3" ;

Loading…
Cancel
Save