mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 10:47:27 +08:00 
			
		
		
		
	Added info functions
This commit is contained in:
		| @ -263,7 +263,7 @@ func printVar(p *proctl.DebuggedProcess, args ...string) error { | |||||||
|  |  | ||||||
| func info(p *proctl.DebuggedProcess, args ...string) error { | func info(p *proctl.DebuggedProcess, args ...string) error { | ||||||
| 	if len(args) == 0 { | 	if len(args) == 0 { | ||||||
| 		return fmt.Errorf("not enough arguments") | 		return fmt.Errorf("not enough arguments. expected info type [regex].") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Allow for optional regex | 	// Allow for optional regex | ||||||
| @ -275,23 +275,36 @@ func info(p *proctl.DebuggedProcess, args ...string) error { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	var data []string | ||||||
|  |  | ||||||
| 	switch args[0] { | 	switch args[0] { | ||||||
| 	case "sources": | 	case "sources": | ||||||
| 		files := make([]string, 0, len(p.GoSymTable.Files)) | 		data = make([]string, 0, len(p.GoSymTable.Files)) | ||||||
| 		for f := range p.GoSymTable.Files { | 		for f := range p.GoSymTable.Files { | ||||||
| 			if filter == nil || filter.Match([]byte(f)) { | 			if filter == nil || filter.Match([]byte(f)) { | ||||||
| 				files = append(files, f) | 				data = append(data, f) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 		break | ||||||
|  |  | ||||||
| 		sort.Sort(sort.StringSlice(files)) | 	case "functions": | ||||||
|  | 		data = make([]string, 0, len(p.GoSymTable.Funcs)) | ||||||
| 		for _, f := range files { | 		for _, f := range p.GoSymTable.Funcs { | ||||||
| 			fmt.Printf("%s\n", f) | 			if f.Sym != nil && (filter == nil || filter.Match([]byte(f.Name))) { | ||||||
|  | 				data = append(data, f.Name) | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
|  | 		break | ||||||
|  |  | ||||||
| 	default: | 	default: | ||||||
| 		return fmt.Errorf("unsupported info type, must be sources") | 		return fmt.Errorf("unsupported info type, must be sources or functions") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// sort and output data | ||||||
|  | 	sort.Sort(sort.StringSlice(data)) | ||||||
|  |  | ||||||
|  | 	for _, d := range data { | ||||||
|  | 		fmt.Printf("%s\n", d) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 epipho
					epipho