NameComponents returns the components of the printable name to be used for a node.
()
| 165 | |
| 166 | // NameComponents returns the components of the printable name to be used for a node. |
| 167 | func (i *NodeInfo) NameComponents() []string { |
| 168 | var name []string |
| 169 | if i.Address != 0 { |
| 170 | name = append(name, fmt.Sprintf("%016x", i.Address)) |
| 171 | } |
| 172 | if fun := i.Name; fun != "" { |
| 173 | name = append(name, fun) |
| 174 | } |
| 175 | |
| 176 | switch { |
| 177 | case i.Lineno != 0: |
| 178 | s := fmt.Sprintf("%s:%d", i.File, i.Lineno) |
| 179 | if i.Columnno != 0 { |
| 180 | s += fmt.Sprintf(":%d", i.Columnno) |
| 181 | } |
| 182 | // User requested line numbers, provide what we have. |
| 183 | name = append(name, s) |
| 184 | case i.File != "": |
| 185 | // User requested file name, provide it. |
| 186 | name = append(name, i.File) |
| 187 | case i.Name != "": |
| 188 | // User requested function name. It was already included. |
| 189 | case i.Objfile != "": |
| 190 | // Only binary name is available |
| 191 | name = append(name, "["+filepath.Base(i.Objfile)+"]") |
| 192 | default: |
| 193 | // Do not leave it empty if there is no information at all. |
| 194 | name = append(name, "<unknown>") |
| 195 | } |
| 196 | return name |
| 197 | } |
| 198 | |
| 199 | // comparePrintableName compares NodeInfo lexicographically the same way as `i.PrintableName() < right.PrintableName()`, but much more performant. |
| 200 | func (i *NodeInfo) comparePrintableName(right NodeInfo) (equal bool, less bool) { |
no outgoing calls
no test coverage detected