xref: /linux/tools/perf/util/addr_location.c (revision bf4afc53b77aeaa48b5409da5c8da6bb4eff7f43)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "addr_location.h"
3 #include "map.h"
4 #include "maps.h"
5 #include "thread.h"
6 
7 void addr_location__init(struct addr_location *al)
8 {
9 	al->thread = NULL;
10 	al->map = NULL;
11 	al->sym = NULL;
12 	al->srcline = NULL;
13 	al->addr = 0;
14 	al->level = 0;
15 	al->filtered = 0;
16 	al->cpumode = 0;
17 	al->cpu = 0;
18 	al->socket = 0;
19 	al->parallelism = 1;
20 }
21 
22 /*
23  * The preprocess_sample method will return with reference counts for the
24  * in it, when done using (and perhaps getting ref counts if needing to
25  * keep a pointer to one of those entries) it must be paired with
26  * addr_location__exit(), so that the refcounts can be decremented.
27  */
28 void addr_location__exit(struct addr_location *al)
29 {
30 	map__zput(al->map);
31 	thread__zput(al->thread);
32 }
33 
34 void addr_location__copy(struct addr_location *dst, struct addr_location *src)
35 {
36 	thread__put(dst->thread);
37 	map__put(dst->map);
38 	*dst = *src;
39 	dst->thread = thread__get(src->thread);
40 	dst->map = map__get(src->map);
41 }
42