3 * Contains a PP profile specification
5 * @remark Copyright 2003 OProfile authors
6 * @remark Read the file COPYING
8 * @author Philippe Elie
11 #ifndef PROFILE_SPEC_H
12 #define PROFILE_SPEC_H
18 #include "filename_spec.h"
19 #include "comma_list.h"
20 #include "locate_images.h"
23 * Holds a parsed profile spec composed of tag:value pairs, as given in
24 * pp_interface documentation.
26 * @internal implemented through a map of string, pointer to function member
27 * indexed by tag_name.
33 * @param args a vector of non options strings
34 * @param extra extra image paths to search
36 * Factory returning a profile_spec instance storing all valid
37 * tag:value contained in args vector doing also alias
38 * substitution, non-valid tag:value options are considered
41 static profile_spec create(std::list<std::string> const & args,
42 std::vector<std::string> const & image_path,
43 std::string const & root_path);
46 * @param exclude_dependent whether to exclude dependent sub-images
47 * @param exclude_cg whether to exclude call graph file
49 * Use the spec to generate the list of candidate sample files.
51 std::list<std::string>
52 generate_file_list(bool exclude_dependent, bool exclude_cg) const;
55 * @param file_spec the filename specification to check
57 * return true if filename match the spec. PP:3.24 internal loop
59 bool match(filename_spec const & file_spec) const;
63 * returns an empty string if not using an archive.
65 std::string get_archive_path() const;
71 * @param tag_value a "tag:value" to interpret, all error throw an
72 * invalid_argument exception.
74 void parse(std::string const & tag_value);
77 * @param image an image or a libray name given on command line
79 * Used for e.g. "opreport /bin/mybinary". We don't know yet
80 * if this is an application or a dependent image.
82 void set_image_or_lib_name(std::string const & image);
85 * @param str a "tag:value"
87 * return true if tag is a valid tag
89 bool is_valid_tag(std::string const & str);
92 * implement tag parsing: PP:3.3 to 3.16
94 void parse_archive_path(std::string const &);
95 void parse_session(std::string const &);
96 void parse_session_exclude(std::string const &);
97 void parse_image(std::string const &);
98 void parse_image_exclude(std::string const &);
99 void parse_lib_image(std::string const &);
100 void parse_event(std::string const &);
101 void parse_count(std::string const &);
102 void parse_unitmask(std::string const &);
103 void parse_tid(std::string const &);
104 void parse_tgid(std::string const &);
105 void parse_cpu(std::string const &);
107 typedef void (profile_spec::*action_t)(std::string const &);
108 typedef std::map<std::string, action_t> parse_table_t;
109 parse_table_t parse_table;
112 * @param tag_value input "tag:value" string
113 * @param value if success return the value part of tag_value
114 * helper for set/is_valid_tag public interface
116 * return null if tag is not valid, else return the pointer to member
117 * function to apply and the value in value parameter
119 action_t get_handler(std::string const & tag_value,
120 std::string & value);
122 std::string archive_path;
124 std::vector<std::string> session;
125 std::vector<std::string> session_exclude;
126 std::vector<std::string> image;
127 std::vector<std::string> image_exclude;
128 std::vector<std::string> lib_image;
129 comma_list<std::string> event;
130 comma_list<int> count;
131 comma_list<unsigned int> unitmask;
132 comma_list<pid_t> tid;
133 comma_list<pid_t> tgid;
135 // specified by user on command like opreport image1 image2 ...
136 std::vector<std::string> image_or_lib_image;
139 /// extra search path for images
140 extra_images extra_found_images;
143 #endif /* !PROFILE_SPEC_H */