linux中fprintf函数,linux-如何使用frama-c命令处理printf(“”,)和...

我正在使用此代码生成C程序的控制流程图.除内置功能(如printf和scanf)外,该功能对于所有功能均正常运行.我可以在此代码中进行哪些更改以按原样输出内置函数?

open Cil

open Cil_types

let print_stmt out =

function

| Instr i -> !Ast_printer.d_instr out i

| Return _ -> Format.pp_print_string out ""

| Goto _ -> Format.pp_print_string out ""

| Break _ -> Format.pp_print_string out ""

| Continue _ -> Format.pp_print_string out ""

| If (e,_,_,_) -> Format.fprintf out "if %a" !Ast_printer.d_exp e

| Switch(e,_,_,_) -> Format.fprintf out "switch %a" !Ast_printer.d_exp e

| Loop _ -> Format.fprintf out ""

| Block _ -> Format.fprintf out ""

| UnspecifiedSequence _ -> Format.fprintf out ""

| TryFinally _ | TryExcept _ -> Format.fprintf out ""

class print_cfg out =

object

inherit Visitor.frama_c_inplace

method vstmt_aux s =

Format.fprintf out "s%d@[[label=\"%a\"]@];@\n" s.sid print_stmt s.skind;

List.iter

(fun succ -> Format.fprintf out "s%d -> s%d;@\n" s.sid succ.sid)

s.succs;

DoChildren

method vglob_aux g =

match g with

| GFun(f,loc) ->

Format.fprintf out "@[subgraph cluster_%a {@\n\

graph [label=\"%a\"];@\n"

Cil_datatype.Varinfo.pretty f.svar

Cil_datatype.Varinfo.pretty f.svar;

ChangeDoChildrenPost([g], fun g -> Format.fprintf out "}@\n@]"; g)

| _ -> SkipChildren

method vfile f =

Format.fprintf out "@[digraph cfg {@\n";

ChangeDoChildrenPost (f,fun f -> Format.fprintf out "}@."; f)

end

let run () =

let chan = open_out "cfg.out" in

let fmt = Format.formatter_of_out_channel chan in

Visitor.visitFramacFileSameGlobals (new print_cfg fmt) (Ast.get())

let () = Db.Main.extend run

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值