summaryrefslogtreecommitdiffstats
path: root/src/path.h
blob: c3c20c0bbe5c7e8d9c29cb242dc9bd4e37220cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Copyright 2018 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __PDBG_PATH_H
#define __PDBG_PATH_H

#include <libpdbg.h>

/**
 * @brief Parse a list of path target strings
 *
 * @param[in]  arg An array of strings
 * @param[in]  arg_count The number of strings
 * @return true on success, false on error
 */
bool path_target_parse(const char **arg, int arg_count);

/**
 * @brief Check if there are any path targets
 *
 * @return true if number of path targets > 0, false otherwise
 */
bool path_target_present(void);

/**
 * @brief Add a target to the list
 *
 * @param[in]  target pdbg target
 * @return true on success, false on error
 */
bool path_target_add(struct pdbg_target *target);

/**
 * @brief Check if the specified target is selected
 *
 * @param[in]  target pdbg target
 * @return true if the target is selected, false otherwise
 */
bool path_target_selected(struct pdbg_target *target);

/**
 * @brief Print the list of path targets to stdout
 */
void path_target_dump(void);

/**
 * @brief Iterator for list of path targets
 *
 * @param[in]  prev The last pdbg target
 * @return the next pdbg target in the list, NULL otherwise
 *
 * If prev is NULL, then return the first pdbg target in the list.
 * If there are no more pdbg targets in the list, NULL is returned.
 */
struct pdbg_target *path_target_next(struct pdbg_target *prev);

/**
 * @brief Iterator for a list of path targets of specified class
 *
 * @param[in]  klass The class of the targets required
 * @param[in]  prev The last pdbg target
 * @return the next matching pdbg target in the list, NULL otherwise
 *
 * If prev is NULL, then return the first matching pdbg target in the list.
 * If there are no more matching pdbg targets, NULL is returned.
 */
struct pdbg_target *path_target_next_class(const char *klass,
					   struct pdbg_target *prev);

/**
 * @brief Macro for iterating through all path targets
 *
 * target is of type struct pdbg_target
 */
#define for_each_path_target(target)           \
	for (target = path_target_next(NULL);  \
	     target;                           \
	     target = path_target_next(target))

/**
 * @brief Macro for iterating through all path targets of specific class
 *
 * class is of type char *
 * target is of type struct pdbg_target
 */
#define for_each_path_target_class(class, target)           \
	for (target = path_target_next_class(class, NULL);  \
	     target;                                        \
	     target = path_target_next_class(class, target))

#endif
OpenPOWER on IntegriCloud