HPCToolkit
fnbounds_static.c
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //*********************************************************************
48 // system includes
49 //*********************************************************************
50 
51 #include <assert.h>
52 
53 //*********************************************************************
54 // local includes
55 //*********************************************************************
56 
57 #include "fnbounds_interface.h"
58 #include "fnbounds_file_header.h"
59 
60 #include <loadmap.h>
61 #include <files.h>
62 
63 //*********************************************************************
64 
65 //-------------------------------------------------------------------------
66 // the external variables below will be defined in a
67 // machine-generated file
68 //-------------------------------------------------------------------------
69 
70 // TODO:tallent: abstract with hpcfnbounds (cf. dump_file_symbols())
71 // and fnbounds_read_nm_file()
72 extern unsigned long hpcrun_nm_addrs[];
73 extern unsigned long hpcrun_nm_addrs_len;
74 extern unsigned long hpcrun_reference_offset;
75 extern int hpcrun_is_relocatable;
76 
77 //-------------------------------------------------------------------------
78 // local data
79 //-------------------------------------------------------------------------
80 
82 
83 
84 
85 //-------------------------------------------------------------------------
86 // interface functions
87 //-------------------------------------------------------------------------
88 int
90 {
91  void *lm_beg_fn = (void*)hpcrun_nm_addrs[0];
92  void *lm_end_fn = (void*)hpcrun_nm_addrs[hpcrun_nm_addrs_len - 1];
93  long lm_size = lm_end_fn - lm_beg_fn;
94 
95  struct fnbounds_file_header fh;
99  fh.mmap_size = 0;
100 
101  dso_info_t *dso =
103  &fh, lm_beg_fn, lm_end_fn, lm_size);
104  fnbounds_executable_dso = hpcrun_loadmap_map(dso);
105 
106  return 0;
107 }
108 
109 
112 {
113  return (fnbounds_table_t)
114  { .table = (void**) hpcrun_nm_addrs, .len = hpcrun_nm_addrs_len};
115 }
116 
117 
118 int
119 fnbounds_query(void *pc)
120 {
121  assert(0);
122  return 0;
123 }
124 
125 
126 int
127 fnbounds_add(char *module_name, void *start, void *end)
128 {
129  assert(0);
130  return 0;
131 }
132 
133 
134 bool
135 fnbounds_enclosing_addr(void *ip, void **start, void **end, load_module_t **lm)
136 {
139  ip, start, end);
140  if (lm) {
141  *lm = lm_;
142  }
143  return (ret == 0);
144 }
145 
146 
147 void
149 {
150 }
151 
152 
153 void
155 {
156 }
int fnbounds_init()
unsigned long hpcrun_reference_offset
int fnbounds_query(void *pc)
unsigned long hpcrun_nm_addrs[]
int fnbounds_table_lookup(void **table, int length, void *ip, void **start, void **end)
dso_info_t * hpcrun_dso_make(const char *name, void **table, struct fnbounds_file_header *fh, void *startaddr, void *endaddr, unsigned long map_size)
Definition: loadmap.c:130
fnbounds_table_t fnbounds_fetch_executable_table(void)
unsigned long hpcrun_nm_addrs_len
load_module_t * hpcrun_loadmap_map(dso_info_t *dso)
Definition: loadmap.c:389
int fnbounds_add(char *module_name, void *start, void *end)
const char * hpcrun_files_executable_pathname()
Definition: files.c:367
unsigned long reference_offset
void fnbounds_release_lock(void)
void fnbounds_fini()
#define NULL
Definition: ElfHelper.cpp:85
bool fnbounds_enclosing_addr(void *ip, void **start, void **end, load_module_t **lm)
int hpcrun_is_relocatable
static load_module_t * fnbounds_executable_dso