source: rtems/cpukit/libdl/rtl-trace.c @ 89c59be

5
Last change on this file since 89c59be was 89c59be, checked in by Chris Johns <chrisj@…>, on 12/17/18 at 05:36:48

libdl: Add symbol searching and loading from archives.

  • Load archive symbol tables to support searching of archives for symbols.
  • Search archive symbols and load the object file that contains the symbol.
  • Search the global and archives until all remaining unresolved symbols are not found. Group the loaded object files in the pending queue.
  • Run the object file and loaded dependents as a group before adding to the main object list.
  • Remove orphaned object files after references are removed.

Updates #3686

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.org/license/LICENSE.
7 */
8/**
9 * @file
10 *
11 * @ingroup rtems_rtld
12 *
13 * @brief RTEMS Run-Time Link Editor Trace
14 *
15 * A configurable tracer for the RTL. See the header file for the enable and
16 * disable.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <stdio.h>
24#include <string.h>
25
26#include <rtems/rtl/rtl-trace.h>
27
28#if RTEMS_RTL_TRACE
29static rtems_rtl_trace_mask rtems_rtl_trace_flags;
30
31bool
32rtems_rtl_trace (rtems_rtl_trace_mask mask)
33{
34  bool result = false;
35  if (mask & rtems_rtl_trace_flags)
36    result = true;
37  return result;
38}
39
40rtems_rtl_trace_mask
41rtems_rtl_trace_set_mask (rtems_rtl_trace_mask mask)
42{
43  rtems_rtl_trace_mask state = rtems_rtl_trace_flags;
44  rtems_rtl_trace_flags |= mask;
45  return state;
46}
47
48rtems_rtl_trace_mask
49rtems_rtl_trace_clear_mask (rtems_rtl_trace_mask mask)
50{
51  rtems_rtl_trace_mask state = rtems_rtl_trace_flags;
52  rtems_rtl_trace_flags &= ~mask;
53  return state;
54}
55
56int
57rtems_rtl_trace_shell_command (int argc, char *argv[])
58{
59  const char* table[] =
60  {
61    "detail",
62    "warning",
63    "load",
64    "unload",
65    "section",
66    "symbol",
67    "reloc",
68    "global-sym",
69    "load-sect",
70    "allocator",
71    "unresolved",
72    "cache",
73    "archives",
74    "dependency"
75  };
76
77  rtems_rtl_trace_mask set_value = 0;
78  rtems_rtl_trace_mask clear_value = 0;
79  bool                 set = true;
80  int                  arg;
81  int                  t;
82
83  for (arg = 1; arg < argc; arg++)
84  {
85    if (argv[arg][0] == '-')
86    {
87      switch (argv[arg][1])
88      {
89        case 'h':
90          printf ("usage: %s [-hl] [set/clear] [flags]\n", argv[0]);
91          return 0;
92        case 'l':
93          printf ("%s: valid flags to set or clear are:\n", argv[0]);
94          for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
95            printf ("  %s\n", table[t]);
96          return 0;
97        default:
98          printf ("error: unknown option\n");
99          return 1;
100      }
101    }
102    else
103    {
104      if (strcmp (argv[arg], "set") == 0)
105        set = true;
106      if (strcmp (argv[arg], "clear") == 0)
107        set = false;
108      else if (strcmp (argv[arg], "all") == 0)
109      {
110        if (set)
111          set_value = RTEMS_RTL_TRACE_ALL;
112        else
113          clear_value = RTEMS_RTL_TRACE_ALL;
114      }
115      else
116      {
117        for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
118        {
119          if (strcmp (argv[arg], table[t]) == 0)
120          {
121            if (set)
122              set_value = 1 << t;
123            else
124              clear_value = 1 << t;
125            break;
126          }
127        }
128      }
129
130      rtems_rtl_trace_flags |= set_value;
131      rtems_rtl_trace_flags &= ~clear_value;
132    }
133  }
134
135  return 0;
136}
137
138#endif
Note: See TracBrowser for help on using the repository browser.