一,run命令执行数据流
二,调用堆栈
在fxShell中执行run命令的执行数据流:
添加go语言打印堆栈方法:引入包"fmt""runtime/debug",调用fmt.Printf("%s", debug.Stack()) 参考 https://blog.csdn.net/kongxx/article/details/76167000
声明(CreateComponent,LaunchInfo)地方,sdk/fidl/fuchsia.sys/launcher.fidl 编译时编译到各个模块下,比如out/default/gen/gopaths/ifconfig/src/fidl/fuchsia/sys/impl.go
声明(ComponentControllerPtr)地方,out/default/fidling/gen/sdk/fidl/fuchsia.sys/fuchsia/sys/cpp/fidl.h
LauncherSyncPtr的NewRequest(),即sdk/lib/fidl/cpp/synchronous_interface_ptr.h的NewRequest();
ComponentIndexPtr的FuzzySearch(),声明src/sys/component_index/fidl/index.fidl,实现out/default/fidling/gen/src/./fidl.cc;//内调Send();
官方文档, https://fuchsia.googlesource.com/fuchsia/+/master/docs/development/languages/fidl/reference/wire-format/README.md#messages-for-transactions
shell中输入run命令,入口src/sys/tools/run/main.cc的main();//转到launch();//内调LauncherSyncPtr的CreateComponent(),即out/default/gen/./impl.go的CreateComponent();
~~//内调ComponentControllerWithCtxInterface的Send(),即third_party/go/src/syscall/zx/fidl/interface.go的Send();//内调message.go的MarshalHeaderThenMessage();//内调Marshal();
~~//...//内调sdk/lib/fidl/cpp/internal/message_sender.cc的SendMessage();//内调zircon/./message.h的Write();//内调zx_channel_write();
~~//服务端读取数据,处理数据;
kernel唤醒守护进程:src/sys/pkg/bin/pkgfs/pkgfs/pkgfs.go的Serve();//内调garnet/go/src/thinfs/zircon/rpc/rpc.go的Serve();
~~//内调third_party/go/src/syscall/zx/fidl/bindings.go的Serve();//内调third_party/go/src/syscall/zx/dispatch/dispatcher.go的Serve();
~~//内调waitContext结构体的callback();//内调third_party/go/src/syscall/zx/fidl/bindings.go的Init();//转到dispatch();
~~//内调fuchsia/third_party/go/src/syscall/zx/io/impl.go的Dispatch();//转到DispatchImplWithCtx2();
~~//内调garnet/go/src/thinfs/zircon/rpc/rpc.go的Write();//内调src/sys/pkg/bin/pkgfs/pkgfs/package_install_directory.go的Write();
~~//内调src/sys/pkg/bin/pkgfs/index/dynamic_index.go的Fulfill();
=======
系统的fidl文件:zircon/system/fidl/fuchsia-hardware-input/input.fidl;同级目录下有好多fidl后缀文件;
~~//生成文件目录,out/default.zircon/gen/system/fidl/fuchsia-hardware-input
~~//比如,input.fidl中GetMaxInputReportSize(),//生成client.c的fuchsia_hardware_input_DeviceGetMaxInputReportSize();
~~//内调zx_channel_call();//内调kernel/lib/syscalls/channel.cc的zx_channel_call();//内调SYSCALL_zx_channel_call_noretry(),SYSCALL_zx_channel_call_finish();
~~//VDSO_SYSCALL_zx_channel_call_noretry宏定义在生成的头文件out/default.zircon/kernel-x64-clang/gen/kernel/lib/userabi/vdso-code.h;
~~//生成server.c的fuchsia_hardware_input_Device_dispatch();//转到fuchsia_hardware_input_Device_try_dispatch();
========
appmgr命令的入口src/sys/appmgr/main.cc的main();//内调zx_take_startup_handle(),zx::channel::create(),fdio_open();
sysmgr命令的入口src/sys/sysmgr/main.cc的main();
basemgr命令的入口src/modular/bin/basemgr/main.cc的main();
run命令的入口src/sys/tools/run/main.cc的main();//转到launch();//内调LauncherSyncPtr的CreateComponent();
far命令的入口src/sys/pkg/bin/far/main.cc的main();
实用小工具(源码zircon/system/uapp/psutils/): ps , top , kill , killall , vmos , memgraph , kstats , threads , signal , handles ;
实用小工具(源码garnet/bin): time , uname , trace ;
实用小工具(源码third_party/sbase/): cat , find , head , mv , printf , printenv , pwd , sleep , wc , which , whoami , grep , join , hostname , rm , sha1sum ;
fidlc命令源码,zircon/tools/fidl/compiler/main.cc; 编译后位置out/default/host_x64/fidlc;
fuchsia的ps命令执行:zircon/system/uapp/psutils/ps.c的main();//内调ps_internal.c的show_all_jobs();//内调walker.cc的walk_root_job_tree();
~~//内调zx::channel::create(),fdio_service_connect("/svc/fuchsia.boot.RootJob"),walk_job_tree();
~~//zx_object_get_info(ZX_INFO_HANDLE_BASIC),zx_object_get_info(),mini-process.c中write_ctx_message();
~~//递归调用zx_object_get_child(),object.cc的sys_object_get_child();文件zircon/vdso/object.fidl;
zircon没有全局文件系统,每个进程有自己的namespace,在__libc_extensions_init中会创建RootNamespace,通过namespace.cc的fdio_ns_bind()绑定RemoteFilesystem到指定目录;