source: mainline/kernel/generic/include/debug/line.h@ 55c5cb05

topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 55c5cb05 was 001957b6, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 22 months ago

ccheck

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2023 Jiří Zárevúcky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef DWARFS_LINE_H_
30#define DWARFS_LINE_H_
31
32#include <stdbool.h>
33#include <stddef.h>
34#include <stdint.h>
35
36struct debug_line_program_header {
37 uint64_t unit_length;
38 uint64_t header_length;
39 const uint8_t *unit_end;
40 const uint8_t *header_end;
41 const uint8_t *standard_opcode_lengths;
42 size_t standard_opcode_lengths_size;
43 unsigned width;
44 uint16_t version;
45 uint8_t minimum_instruction_length;
46 bool default_is_stmt;
47 int8_t line_base;
48 uint8_t line_range;
49 uint8_t opcode_base;
50
51 union {
52 struct {
53 const uint8_t *include_directories;
54 const uint8_t *include_directories_end;
55 const uint8_t *file_names;
56 } v3;
57 struct {
58 uint64_t directories_count;
59 uint64_t file_names_count;
60 const uint8_t *directory_entry_format;
61 const uint8_t *directory_entry_format_end;
62 const uint8_t *directories;
63 const uint8_t *directories_end;
64 const uint8_t *file_name_entry_format;
65 const uint8_t *file_name_entry_format_end;
66 const uint8_t *file_names;
67 const uint8_t *file_names_end;
68 uint8_t address_size;
69 uint8_t segment_selector_size;
70 uint8_t directory_entry_format_count;
71 uint8_t file_name_entry_format_count;
72 uint8_t maximum_operations_per_instruction;
73 } v5;
74 };
75};
76
77struct debug_line_program {
78 const struct debug_line_program_header *hdr;
79 const uint8_t *program;
80 const uint8_t *program_end;
81
82 uintptr_t address;
83 int op_advance;
84 int file;
85 int line;
86 int column;
87
88 bool end_sequence;
89 bool truncated;
90};
91
92static inline struct debug_line_program debug_line_program_create(const uint8_t *program,
93 const uint8_t *const program_end,
94 const struct debug_line_program_header *hdr)
95{
96 return (struct debug_line_program) {
97 .hdr = hdr,
98 .program = program,
99 .program_end = program_end,
100 .end_sequence = true,
101 .truncated = false,
102 };
103}
104
105extern bool debug_line_get_address_info(uintptr_t addr, int op_index, const char **file, const char **dir, int *line, int *col);
106
107#endif /* DWARFS_LINE_H_ */
Note: See TracBrowser for help on using the repository browser.