(gconfig *GlobalConfig)
| 873 | } |
| 874 | |
| 875 | func (this *ModuleConfig) LoadConfig(gconfig *GlobalConfig) { |
| 876 | |
| 877 | // 一些配置文件有关的逻辑 |
| 878 | // 1. 无论 uprobe 还是 syscall 指定的配置即为要hook的 |
| 879 | // 2. syscall 有内置解析配置 需要配合命令行 -s/--syscall 使用 |
| 880 | // 3. 指定了 syscall 类型的配置 则不会采用内置配置 也会无视 -s/--syscall |
| 881 | |
| 882 | for _, file := range gconfig.ConfigFiles { |
| 883 | content, err := ioutil.ReadFile(file) |
| 884 | if err != nil { |
| 885 | panic(err) |
| 886 | } |
| 887 | base_config := &FileConfig{} |
| 888 | err = json.Unmarshal(content, base_config) |
| 889 | if err != nil { |
| 890 | panic(err) |
| 891 | } |
| 892 | switch base_config.Type { |
| 893 | case "uprobe": |
| 894 | config := &UprobeFileConfig{} |
| 895 | err = json.Unmarshal(content, config) |
| 896 | if err != nil { |
| 897 | panic(err) |
| 898 | } |
| 899 | err = gconfig.Parse_Libinfo(config.Library, this.StackUprobeConf) |
| 900 | if err != nil { |
| 901 | panic(err) |
| 902 | } |
| 903 | err = this.StackUprobeConf.Parse_FileConfig(config) |
| 904 | if err != nil { |
| 905 | panic(err) |
| 906 | } |
| 907 | case "syscall": |
| 908 | config := &SyscallFileConfig{} |
| 909 | err = json.Unmarshal(content, config) |
| 910 | if err != nil { |
| 911 | panic(err) |
| 912 | } |
| 913 | err = this.SysCallConf.Parse_FileConfig(config) |
| 914 | if err != nil { |
| 915 | panic(err) |
| 916 | } |
| 917 | default: |
| 918 | panic(fmt.Sprintf("unsupported config type %s", base_config.Type)) |
| 919 | } |
| 920 | |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | func (this *ModuleConfig) Info() string { |
| 925 | // 调用号信息 |
no test coverage detected