Пример #1
0
func (info *DumpFileInfo) GenTencentDumpInfo() {
	path := "./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_

	version := info.info_["version"]

	count := strings.Count(version, "_")
	if count > 1 {
		index := strings.Index(version, "_")
		version = version[:index]
	}

	context := file.ReadFile(path)
	intputlibname := goCfgMgr.Get("libname", "inputname").(string)
	outputlibname := goCfgMgr.Get("libname", "outputname").(string)

	ref_str := strings.Replace(outputlibname, ".", "\\.", 1)
	re := regexp.MustCompile(ref_str)
	finale_context := string(context)
	re.ReplaceAllLiteralString(finale_context, version+"_"+intputlibname)

	file.WriteFile(path, []byte(finale_context), os.O_TRUNC)

	cmd := exec.Command("/bin/sh", "./gen_ndk_info.sh", info.info_["version"], info.file_name_, info.project)
	_, err := cmd.Output()
	if err != nil {
		log.Println("GenNdkfile err:" + err.Error())
	}

}
Пример #2
0
/* 初始化数据库引擎 */
func InitCheck() (*CheckDumpMysql, error) {
	if sql_check_instance == nil {
		sql_check_instance = new(CheckDumpMysql)

		mysql_port := goCfgMgr.Get("mysql", "Port").(string)
		mysql_host := goCfgMgr.Get("mysql", "Host").(string)
		mysql_user := goCfgMgr.Get("mysql", "User").(string)
		mysql_password := goCfgMgr.Get("mysql", "PassWord").(string)
		mysql_db := goCfgMgr.Get("mysql", "DataBase").(string)

		open_str := mysql_user + ":" + mysql_password + "@tcp(" + mysql_host + ":" + mysql_port + ")/" + mysql_db + "?charset=utf8"

		db, err := sql.Open("mysql", open_str)

		if err != nil {
			log.Println("database initialize error : ", err.Error())
			return nil, err
		}
		sql_check_instance.db = db
		sql_check_instance.db.SetMaxOpenConns(20)
		check_sql = true
	}

	return sql_check_instance, nil
}
Пример #3
0
func (info *DumpFileInfo) GenSym() bool {
	// 查找是否有对应的 sym文件

	version := info.info_["version"]

	count := strings.Count(version, "_")
	if count > 1 {
		index := strings.Index(version, "_")
		version = version[:index]
	}

	result := file.IsFileExists("./" + info.project + "/lib/" + info.info_["version"] + ".txt")
	if result {
		return true
	}

	lib_name := "./" + info.project + "/lib/" + version + "_" + goCfgMgr.Get("libname", "inputname").(string)
	log.Println("find lib_name :" + lib_name)
	result = file.IsFileExists(lib_name)
	if result {
		cmd := exec.Command("/bin/sh", "gensym.sh", version, info.project, info.lianyun, goCfgMgr.Get("libname", "inputname").(string), goCfgMgr.Get("libname", "outputname").(string), info.info_["version"])
		_, err := cmd.Output()
		if err != nil {
			log.Println("GenSym err:" + err.Error())
			return false
		}
		return true
	}

	return false
}
Пример #4
0
func (info *DumpFileInfo) GenNdkfile() {
	/* eg.
	03-24 15:34:32.361: I/DEBUG(130): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	03-24 15:34:32.361: I/DEBUG(130): Build fingerprint: '111'
	03-24 15:34:32.361: I/DEBUG(130): pid: 11142, tid: 11365, name: dfdsf  >>> sfsaf <<<
	03-24 15:34:32.794: I/DEBUG(130): backtrace:
	03-24 15:34:32.794: I/DEBUG(130):     #00  pc 0069D08F  libpishell.so ()
	03-24 15:34:32.794: I/DEBUG(130):     #01  pc 5e4ade49  libpishell.so ()
	*/
	max_info_count := 3
	info_key := ""

	file_context := "03-24 15:34:32.361: I/DEBUG(130): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"
	file_context += "03-24 15:34:32.361: I/DEBUG(130): Build fingerprint: '111'\n"
	file_context += "03-24 15:34:32.361: I/DEBUG(130): pid: 11142, tid: 11365, name: dfdsf  >>> sfsaf <<<\n"
	file_context += "03-24 15:34:32.794: I/DEBUG(130): backtrace:\n"
	stack_head := "03-24 15:34:32.794: I/DEBUG(130):     #"
	for i := 0; i < len(info.stack_lib_name); i++ {
		result_str := ""
		address := info.stack_address[i] - info.so_address

		var buf = make([]byte, 4)
		binary.BigEndian.PutUint32(buf, uint32(address))

		libname := info.stack_lib_name[i]
		if libname == goCfgMgr.Get("libname", "outputname").(string) {
			libname = goCfgMgr.Get("libname", "inputname").(string)
		}

		version := info.info_["version"]

		count := strings.Count(version, "_")
		if count > 1 {
			index := strings.Index(version, "_")
			version = version[:index]
		}

		if i < 10 {
			result_str = "0" + strconv.Itoa(i) + "  pc " + hex.EncodeToString(buf) + "  " + version + "_" + libname + " ()\n"
			file_context += (stack_head + result_str)
		}

		if max_info_count > 0 {
			info_key = info_key + hex.EncodeToString(buf) + "_"
			max_info_count--
		}

	}
	file_context += "\n"

	path := "./" + info.project + "/dump/" + info.info_["version"]
	file.WriteFile(path+"/"+info.file_name_+".ndk", []byte(file_context), os.O_TRUNC)

	cmd := exec.Command("/bin/sh", "./gen_ndk_info.sh", info.info_["version"], info.file_name_+".ndk", info.project)
	_, err := cmd.Output()
	if err != nil {
		log.Println("GenNdkfile err:" + err.Error())
	}
}
Пример #5
0
func main() {
	arg_num := len(os.Args)
	if arg_num < 4 {
		log.Printf("[a|java|c|js] [并发数量] [测试次数]\n")
		return
	}

	mod := os.Args[1]

	test_thread_num, err := strconv.Atoi(os.Args[2])
	if err != nil {
		log.Println("error happened ,exit")
		return
	}

	test_num, err := strconv.Atoi(os.Args[3])
	if err != nil {
		log.Println("error happened ,exit")
		return
	}
	ver := goCfgMgr.Get("project", "ver").(string)
	server_address := "http://" + goCfgMgr.Get("basic", "Host").(string) + ":" +
		goCfgMgr.Get("basic", "Port").(string) + "/?pat=post&pro=" +
		goCfgMgr.Get("project", "name").(string) + "&ver=" + ver
	c = make(chan int)
	for j := 0; j < test_num; j++ {
		for i := 0; i < test_thread_num; i++ {
			if mod == "java" {
				go TestJava(server_address, ver)
			} else if mod == "js" {
				go TestJs(server_address, ver)
			} else if mod == "c" {
				go TestC(server_address, ver)
			} else if mod == "a" {
				go TestJava(server_address, ver)
				go TestJs(server_address, ver)
				go TestC(server_address, ver)
			}
		}

		for i := 0; i < test_thread_num; i++ {
			<-c
		}
		time.Sleep(100 * time.Millisecond)
	}
}
Пример #6
0
func Start() {
	server_address := goCfgMgr.Get("basic", "Host").(string) + ":" +
		goCfgMgr.Get("basic", "Port").(string)

	ctx := gozd.Context{
		Hash:    "pin_dump_test",
		Logfile: os.TempDir() + "/pin_dump_test.log",
		Directives: map[string]gozd.Server{
			"sock": gozd.Server{
				Network: "unix",
				Address: os.TempDir() + "/pin_dump_test.sock",
			},
			"port1": gozd.Server{
				Network: "tcp",
				Address: server_address,
			},
		},
	}
	dumpProcessChan = make(chan int, 15)
	cl := make(chan net.Listener, 1)
	go handleListners(cl)
	sig, err := gozd.Daemonize(ctx, cl) // returns channel that connects with daemon
	if err != nil {
		log.Println("error: ", err)
		return
	}

	// other initializations or config setting

	for s := range sig {
		switch s {
		case syscall.SIGHUP, syscall.SIGUSR2:
			// do some custom jobs while reload/hotupdate

		case syscall.SIGTERM:
			// do some clean up and exit
			return
		}
	}

	dbinfo.Init()

	go dbinfo.Check_Sql_Connect()
	go debug.CheckMemStats()
}
Пример #7
0
func main() {
	path, _ := osext.ExecutableFolder()
	os.Chdir(path)

	go func() {
		log.Println(http.ListenAndServe(goCfgMgr.Get("basic", "Host").(string)+":10022", nil))
	}()
	DoomAnalysis.Start()
}
Пример #8
0
func (info *DumpFileInfo) GenNdkDumpInfo() {
	context := file.ReadFile("./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_ + ".info")
	//context := file.ReadFile("./a.txt.info")
	start_pos := 0

	open_stack := false
	open_lib_info := false

	for i := 0; i < len(context); i++ {
		if context[i] == '\n' {
			if i-start_pos > 1 {
				temp_str := string(context[start_pos:i])

				matched, _ := regexp.MatchString("(?i:^Thread).*(crashed)", temp_str)
				if matched {
					//log.Println("regexp : ", temp_str)
					open_stack = true
				}

				if open_stack {
					info.GenNdkStack(temp_str)
					matched, _ = regexp.MatchString("(?i:^Thread)[\\s]\\d{1,2}$", temp_str)
					if matched {
						//log.Println("regexp : ", temp_str)
						open_stack = false
					}
				}

				matched, _ = regexp.MatchString("(?i:^Loaded)[\\s](modules:)$", temp_str)
				if matched {
					//log.Println("regexp : ", temp_str)
					open_lib_info = true
				}

				if open_lib_info {
					libname := goCfgMgr.Get("libname", "outputname").(string)
					matched, _ = regexp.MatchString("0x[0-9|a-f]{8}\\s-\\s0x[0-9|a-f]{8}\\s{2}"+libname+"\\s{2}\\?{3}$", temp_str)
					if matched {
						//log.Println("regexp : ", temp_str)
						info.GenNdkSoAddress(temp_str)
						open_lib_info = false
					}
				}

			}

			start_pos = i + 1

		}
	}

	info.GenNdkfile()

}
Пример #9
0
func init() {
	defer func() {
		if err := recover(); err != nil {
			log.Println("Invalid config file.")
			os.Exit(1)
		}
	}()

	Args = make(map[string]string)
	Args["MTAddr"] = config.Get("address", nil).(string)
	if Args["MTAddr"] == "" {
		log.Fatal("Megaton server address not specified. Check config file first!")
	}
}
Пример #10
0
func GetProName(pro string, lianyun string) string {
	log.Println("GetProName:", pro)
	pro_list := goCfgMgr.Get("project", pro).(map[string]interface{})

	for i, u := range pro_list {
		switch value := u.(type) {
		case string:
			if i == lianyun {
				return value
			}
		default:
			fmt.Println(value, "is of a type I don't know how to handle ")
		}

	}

	return pro
}
Пример #11
0
func (info *DumpFileInfo) GenDbInfo() {
	context := file.ReadFile("./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_ + ".ndk.info")
	//context := file.ReadFile("./a.txt.info")
	start_pos := 0

	address_info := 3
	info_str := ""
	info_key := ""
	for i := 0; i < len(context); i++ {
		if context[i] == '\n' {
			if i-start_pos > 1 {
				temp_str := string(context[start_pos:i])

				re := regexp.MustCompile("pc\\s{1}[0-9|a-f]{8}")
				matched := re.FindString(temp_str)

				if matched != "" && address_info > 0 {
					libname := goCfgMgr.Get("libname", "inputname").(string)
					prostack_flag, _ := regexp.MatchString(libname, temp_str)
					if prostack_flag {
						re = regexp.MustCompile("[0-9|a-f]{8}")
						key := re.FindString(matched)

						info_key = info_key + "_" + key
						address_info--
					}

				}

				info_str = info_str + temp_str + "<br>"

			}

			start_pos = i + 1

		}
	}
	//db.CreateDB(info.project, info.info_["version"], info_key, info_str, info.info_["UUID"])
	mysql_c, db_err := dbinfo.Init()
	if db_err == nil {
		mysql_c.AddInfo(info.project, info.info_["version"], info_key, info_str, info.info_["UUID"], info.lianyun)
		mysql_c.AddDeviceInfo(info.project, info.info_["version"], info_key, info.info_["device"], info.lianyun, info.info_["UUID"])
	}
}