showpath

Synopsis

 void showpath(string, string, eset)

Description

Given a source, a destination and an edge set, the showpath command will list all the paths between the source and the destination (if any) that exist in the given edge set. For example, when studying a call structure of a program, it may be interesting to know all function call paths that would result in function A calling function B. This command provides exactly that functionality, as will be explored further in the example below.

Example

In this example we will find out all the possible ways in which the library function sprintf() can be called in a program. To do that, we will use showpath to determine all possible call sequences that result in function main(), which is the starting point of the execution, to invoke, either directly or indirectly, the function sprintf()

In the listing below, we first use projection through the @label attribute to find entity names of functions main() and sprintf (they are main.o[.text+0x4c] and /lib/libc-2.3.2.so[.text+0x3cac0] respectively) and then invoke showpath to get the possible call sequences from one to the other. The sequences are reported in terms of entity names; to retrieve the function names, we woul have to look them up in the @label relation again.

>> @label . {"\"sprintf\""}
/lib/libc-2.3.2.so[.text+0x3cac0]
>> @label . {"\"main\""}
main.o[.text+0x4c]
>>
>>
>> showpath ("main.o[.text+0x4c]" , "/lib/libc-2.3.2.so[.text+0x3cac0]", cLinks)
main.o[.text+0x4c] -> parser.o[.text+0xdc6] -> /lib/libc-2.3.2.so[.text+0x3cac0]
main.o[.text+0x4c] -> machine.o[.text+0x445] -> machine.o[.text+0x252] -> /lib/libc-2.3.2.so[.text+0x3cac0]
main.o[.text+0x4c] -> parser.o[.text+0x22b] -> parser.o[.text+0x32] -> /lib/libc-2.3.2.so[.text+0x3cac0]
main.o[.text+0x4c] -> parser.o[.text+0xdc6] -> parser.o[.text+0x32] -> /lib/libc-2.3.2.so[.text+0x3cac0]
main.o[.text+0x4c] -> machine.o[.text+0x445] -> machine.o[.text+0x388] -> machine.o[.text+0x252] -> /lib/libc-2.3.2.so[.text+0x3cac0]
main.o[.text+0x4c] -> parser.o[.text+0x22b] -> parser.o[.text+0x179] -> parser.o[.text+0x32] -> /lib/libc-2.3.2.so[.text+0x3cac0]
main.o[.text+0x4c] -> parser.o[.text+0xdc6] -> parser.o[.text+0x179] -> parser.o[.text+0x32] -> /lib/libc-2.3.2.so[.text+0x3cac0]

See Also

showedge showtree show