Skip to content

Commit 545b805

Browse files
committed
feat: add getLastLocation and getLastLine
1 parent d9e41fc commit 545b805

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

qlsrc/pprof_ext/profile.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ class Sample instanceof int {
189189
* [profile.proto:117](../../doc/adapters/pprof/profile.proto#L117)
190190
*/
191191
Location getLocation(int index) { sample_to_location_id(this, index, result) }
192+
int locationNum() { result = max(int index, Location loc| loc = getLocation(index) | index) + 1 }
193+
Location getLastLocation() { result = getLocation(locationNum()-1) }
192194

193195
/**
194196
* The type and unit of each value is defined by the corresponding
@@ -380,6 +382,8 @@ class Location instanceof int {
380382
* the last index is the outermost caller.
381383
*/
382384
Line getLine(int index) { location_to_line(this, index, result) }
385+
int lineNum() { result = max(int index, Line line | getLine(index) = line | index)+1 }
386+
Line getLastLine() { result = getLine(lineNum()-1) }
383387

384388
/** Returns the mapping this location belongs to. */
385389
Mapping getMapping() { result = mapping_id }
@@ -439,3 +443,8 @@ class Function instanceof int {
439443
/** Line number in source file. */
440444
int getStartLine() { result = start_line }
441445
}
446+
447+
bindingset[s]
448+
string pkgpath(string s) {
449+
result = s.splitAt(".", 0)
450+
}

0 commit comments

Comments
 (0)