()
| 519 | } |
| 520 | |
| 521 | func DumpSymbolRet() { |
| 522 | for _, point := range mconfig.StackUprobeConf.Points { |
| 523 | if point.Symbol == "" { |
| 524 | continue |
| 525 | } |
| 526 | content, err := util.RunCommand("sh", "-c", fmt.Sprintf("readelf -s %s | grep %s", point.LibPath, point.Symbol)) |
| 527 | if err != nil { |
| 528 | Logger.Printf("warn, readelf parse for %s failed, lib:%s", point.Symbol, point.LibPath) |
| 529 | continue |
| 530 | } |
| 531 | var ( |
| 532 | sym_num uint32 |
| 533 | sym_value int64 |
| 534 | sym_size int64 |
| 535 | sym_type string |
| 536 | sym_bind string |
| 537 | sym_vis string |
| 538 | sym_ndx string |
| 539 | sym_name string |
| 540 | ) |
| 541 | lines := strings.Split(content, "\n") |
| 542 | for _, line := range lines { |
| 543 | line = strings.TrimSpace(line) |
| 544 | if line == "" { |
| 545 | continue |
| 546 | } |
| 547 | reader := strings.NewReader(line) |
| 548 | n, err := fmt.Fscanf(reader, "%d: %x %d %s %s %s %s %s", &sym_num, &sym_value, &sym_size, &sym_type, &sym_bind, &sym_vis, &sym_ndx, &sym_name) |
| 549 | if err == nil && n == 8 { |
| 550 | ret_info, err := util.FindRet(point.LibPath, sym_value, sym_size) |
| 551 | if err != nil || ret_info == "" { |
| 552 | Logger.Printf("FindRet for %s failed, sym:%s offset:0x%x", point.Symbol, sym_name, sym_value) |
| 553 | continue |
| 554 | } else { |
| 555 | Logger.Printf("FindRet for %s -> [%s] sym:%s offset:0x%x", point.Symbol, ret_info, sym_name, sym_value) |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | os.Exit(0) |
| 561 | } |
| 562 | |
| 563 | func FindPidByName(name string) []uint32 { |
| 564 | var pid_list []uint32 |
no test coverage detected