GCC Middle and Back End API Reference
simple-diagnostic-path.h
Go to the documentation of this file.
1/* Concrete classes for implementing diagnostic paths, using tree.
2 Copyright (C) 2019-2025 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_SIMPLE_DIAGNOSTIC_PATH_H
22#define GCC_SIMPLE_DIAGNOSTIC_PATH_H
23
24#include "diagnostics/paths.h"
26
27/* Concrete subclasses of the abstract base classes
28 declared in diagnostic-path.h. */
29
30/* A simple implementation of diagnostic event.
31 This uses "tree" and so is not in "namespace diagnostics". */
32
34{
35 public:
37
38 simple_diagnostic_event (location_t loc, tree fndecl, int depth,
39 const char *desc,
40 thread_id_t thread_id = 0);
42
43 location_t get_location () const final override { return m_loc; }
44 int get_stack_depth () const final override { return m_depth; }
45 void print_desc (pretty_printer &pp) const final override;
51 meaning get_meaning () const final override
52 {
53 return meaning ();
54 }
55 bool connect_to_next_event_p () const final override
56 {
58 }
60 {
61 return m_thread_id;
62 }
63
68
69 tree get_fndecl () const { return m_fndecl; }
70
71 private:
72 location_t m_loc;
76 char *m_desc; // has been i18n-ed and formatted
79};
80
81/* A simple implementation of diagnostics::paths::thread. */
82
84{
85public:
86 simple_diagnostic_thread (const char *name) : m_name (name) {}
87 label_text get_name (bool) const final override
88 {
89 return label_text::borrow (m_name);
90 }
91
92private:
93 const char *m_name; // has been i18n-ed and formatted
94};
95
96/* A simple implementation of diagnostic_path, as a vector of
97 simple_diagnostic_event instances. */
98
100{
101 public:
106
108 pretty_printer *event_pp);
109
110 unsigned num_events () const final override { return m_events.length (); }
111 const event & get_event (int idx) const final override;
112 unsigned num_threads () const final override { return m_threads.length (); }
113 const thread &
114 get_thread (thread_id_t) const final override;
115 bool
116 same_function_p (int event_idx_a,
117 int event_idx_b) const final override;
118
119 thread_id_t add_thread (const char *name);
120
121 event_id_t add_event (location_t loc, tree fndecl, int depth,
122 const char *fmt, ...)
125 add_thread_event (thread_id_t thread_id,
126 location_t loc, tree fndecl, int depth,
127 const char *fmt, ...)
129
130 void connect_to_next_event ();
131
133
134 private:
137
138 /* (for use by add_event). */
141};
142
143#endif /* ! GCC_SIMPLE_DIAGNOSTIC_PATH_H */
Definition vec.h:1813
Definition logical-locations.h:101
Definition paths.h:83
Definition paths.h:207
Definition paths.h:198
Definition pretty-print.h:241
bool connect_to_next_event_p() const final override
Definition simple-diagnostic-path.h:55
thread_id_t get_thread_id() const final override
Definition simple-diagnostic-path.h:59
diagnostics::logical_locations::key m_logical_loc
Definition simple-diagnostic-path.h:74
thread_id_t m_thread_id
Definition simple-diagnostic-path.h:78
bool m_connected_to_next_event
Definition simple-diagnostic-path.h:77
meaning get_meaning() const final override
Definition simple-diagnostic-path.h:51
diagnostics::logical_locations::key get_logical_location() const final override
Definition simple-diagnostic-path.h:47
location_t get_location() const final override
Definition simple-diagnostic-path.h:43
~simple_diagnostic_event()
Definition simple-diagnostic-path.cc:179
void print_desc(pretty_printer &pp) const final override
Definition simple-diagnostic-path.cc:185
int m_depth
Definition simple-diagnostic-path.h:75
tree m_fndecl
Definition simple-diagnostic-path.h:73
location_t m_loc
Definition simple-diagnostic-path.h:72
simple_diagnostic_event(location_t loc, tree fndecl, int depth, const char *desc, thread_id_t thread_id=0)
Definition simple-diagnostic-path.cc:164
void connect_to_next_event()
Definition simple-diagnostic-path.h:64
diagnostics::paths::thread_id_t thread_id_t
Definition simple-diagnostic-path.h:36
char * m_desc
Definition simple-diagnostic-path.h:76
tree get_fndecl() const
Definition simple-diagnostic-path.h:69
int get_stack_depth() const final override
Definition simple-diagnostic-path.h:44
diagnostics::paths::event_id_t event_id_t
Definition simple-diagnostic-path.h:105
pretty_printer * m_event_pp
Definition simple-diagnostic-path.h:139
diagnostics::paths::thread thread
Definition simple-diagnostic-path.h:102
simple_diagnostic_path(const tree_logical_location_manager &logical_loc_mgr, pretty_printer *event_pp)
Definition simple-diagnostic-path.cc:40
void disable_event_localization()
Definition simple-diagnostic-path.h:132
bool same_function_p(int event_idx_a, int event_idx_b) const final override
Definition simple-diagnostic-path.cc:65
auto_delete_vec< simple_diagnostic_event > m_events
Definition simple-diagnostic-path.h:136
unsigned num_events() const final override
Definition simple-diagnostic-path.h:110
const event & get_event(int idx) const final override
Definition simple-diagnostic-path.cc:53
bool m_localize_events
Definition simple-diagnostic-path.h:140
const thread & get_thread(thread_id_t) const final override
Definition simple-diagnostic-path.cc:59
event_id_t event_id_t add_thread_event(thread_id_t thread_id, location_t loc, tree fndecl, int depth, const char *fmt,...) ATTRIBUTE_GCC_DIAG(6
Definition simple-diagnostic-path.cc:117
auto_delete_vec< simple_diagnostic_thread > m_threads
Definition simple-diagnostic-path.h:135
thread_id_t add_thread(const char *name)
Definition simple-diagnostic-path.cc:73
diagnostics::paths::thread_id_t thread_id_t
Definition simple-diagnostic-path.h:103
unsigned num_threads() const final override
Definition simple-diagnostic-path.h:112
diagnostics::paths::event event
Definition simple-diagnostic-path.h:104
event_id_t add_event(location_t loc, tree fndecl, int depth, const char *fmt,...) ATTRIBUTE_GCC_DIAG(5
Definition simple-diagnostic-path.cc:88
event_id_t event_id_t void connect_to_next_event()
Definition simple-diagnostic-path.cc:153
const char * m_name
Definition simple-diagnostic-path.h:93
simple_diagnostic_thread(const char *name)
Definition simple-diagnostic-path.h:86
label_text get_name(bool) const final override
Definition simple-diagnostic-path.h:87
Definition tree-logical-location.h:32
static key key_from_tree(tree node)
Definition tree-logical-location.h:50
union tree_node * tree
Definition coretypes.h:97
#define ATTRIBUTE_GCC_DIAG(m, n)
Definition diagnostic-core.h:71
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2009
int thread_id_t
Definition event-id.h:71
diagnostic_event_id_t event_id_t
Definition event-id.h:66