1 /* ======================================================================== */
2 /*  Routines for managing source code in the debugger.                      */
3 /* ======================================================================== */
4 #ifndef SOURCE_H_
5 #define SOURCE_H_
6 
7 typedef struct source_file_info
8 {
9     const char *name;
10     text_file  *text;
11 } source_file_info;
12 
13 extern source_file_info *source_file;
14 extern int               source_files;
15 
16 typedef enum
17 {
18     SMAP_SMART,     /* detect multi-line macros and pull from listing */
19     SMAP_SOURCE,
20     SMAP_LISTING
21 } smap_mode;
22 
23 void        set_source_map_mode(smap_mode mode);
24 
25 /* ======================================================================== */
26 /*  PROCESS_SOURCE_MAP   -- Process a source-map file                       */
27 /*                                                                          */
28 /*  Directive lines:                                                        */
29 /*      CWD <string>         Source directory where AS1600 ran              */
30 /*      PATH <string>        Adds <string> to AS1600 search path            */
31 /*      LISTING <string>     Indicates <string> is the AS1600 listing file  */
32 /*      FILE <string>        Sets <string> as the current source file       */
33 /*                                                                          */
34 /*  Mapping lines:                                                          */
35 /*      <addr> <addr> <flags> <source_line> <listing_line>                  */
36 /*                                                                          */
37 /* ======================================================================== */
38 void process_source_map(const char *fname);
39 
40 /* ======================================================================== */
41 /*  SOURCE_FOR_ADDR      -- Try to find code for this address, if any       */
42 /*                          exists.  Pull from source or listing based on   */
43 /*                          the current mode.                               */
44 /* ======================================================================== */
45 const char *source_for_addr(uint32_t addr);
46 
47 /* ======================================================================== */
48 /*  FILE_LINE_FOR_ADDR   -- Get the file and line associated with an addr.  */
49 /* ======================================================================== */
50 int file_line_for_addr(uint32_t addr, int *line);
51 
52 /* ======================================================================== */
53 /*  SOURCE_FOR_FILE_LINE -- Get the source line associated with the file    */
54 /*                          handle and source line, if any.                 */
55 /* ======================================================================== */
56 const char *source_for_file_line(int file, int line);
57 
58 #endif
59