function
Functions management
Function
Bases: dict
Function object
This class represents a binary function within the Program.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto_index
|
Index
|
Protobuf index of the function |
required |
func
|
'Pb.Function'
|
Protobuf data |
required |
program
|
Program
|
Program reference |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
start |
int
|
Start address |
name |
str
|
Function name |
mangled_name |
str
|
Function mangled name (it might be equal to the function name) |
program |
Program
|
Program reference |
type |
'FunctionType'
|
Function type |
func |
'FunctionType'
|
Protobuf data |
Source code in bindings/python/quokka/function.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
blocks
property
Returns a dictionary which is used to reference all basic blocks by their address.
callees
cached
property
Return the list of calls made by this function. The semantic of a "call" is to jump or call to the starting of a function. Beware that this might lead to different results than the program call graph.
Note: The list is not deduplicated so a target may occur multiple time.
callers
cached
property
Retrieve the function callers (the ones calling this function)
comments
property
Return the function comments
constants
cached
property
Lists constants used in the function
end
cached
property
Get the last address of the function
graph
cached
property
Return the CFG of the function as DiGraph object
has_body
property
Check if the function has a body (e.g. at least one block)
in_degree
cached
property
Function in degree
instructions
property
Yields the function instruction
name
property
writable
Return the function name
out_degree
cached
property
Function out degree
prototype
property
writable
Return the function prototype if any
size
cached
property
Return the function size
strings
cached
property
Return the list of strings referenced by the function
__getitem__(address)
Lazy loader for blocks within the function
Source code in bindings/python/quokka/function.py
156 157 158 159 160 161 162 163 164 165 166 167 | |
__hash__()
Hash value
Source code in bindings/python/quokka/function.py
357 358 359 | |
__init__(proto_index, func, program)
Constructor
Source code in bindings/python/quokka/function.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
__repr__()
Function representation
Source code in bindings/python/quokka/function.py
365 366 367 | |
__str__()
Function representation
Source code in bindings/python/quokka/function.py
361 362 363 | |
add_comment(comment)
Add a comment to the function
Source code in bindings/python/quokka/function.py
193 194 195 196 | |
add_edge(source, destination, type)
Add an edge to the function CFG
Source code in bindings/python/quokka/function.py
198 199 200 201 202 203 204 205 206 | |
coalesce_block_ranges(block_ranges)
staticmethod
Merge adjacent or overlapping block ranges into a reduced list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_ranges
|
list[tuple[int, int]]
|
Sorted list of (start, end) tuples. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[AddressT, AddressT]]
|
A list of merged (start, end) tuples. |
Source code in bindings/python/quokka/function.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
get_instruction(address)
Get the instruction at address
Source code in bindings/python/quokka/function.py
279 280 281 282 283 284 285 286 287 288 | |
in_function(address)
Check if an address belongs to the function.
Source code in bindings/python/quokka/function.py
265 266 267 268 269 270 271 272 273 274 275 276 277 | |
items()
Return the block addresses and blocks of the function
Source code in bindings/python/quokka/function.py
178 179 180 181 | |
keys()
Return the block addresses of the function
Source code in bindings/python/quokka/function.py
174 175 176 | |
values()
Return the blocks of the function
Source code in bindings/python/quokka/function.py
169 170 171 172 | |
dereference_thunk(item, caller=False)
Dereference a thunk
This method is used to resolve a thunk calls / callers. As thunk function only have 1 relation : FUNC (call x) -> THUNK X -> X , it disrupts the call graph and heuristics based on graph degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Function
|
A function |
required |
caller
|
bool
|
True if we want to find the callers (e.g. the functions that call item) False if we want to find the callee (e.g. function that are called by item) |
False
|
Raises:
| Type | Description |
|---|---|
ThunkMissingError
|
When no thunk has been found |
FunctionMissingError
|
When no function has been found |
Source code in bindings/python/quokka/function.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
resolve_effective_degrees(item)
Compute a Function {in, out} degrees by resolving thunks
Source code in bindings/python/quokka/function.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |