source: rtems/cpukit/libdl/rtl-trace.c @ 8709aa04

5
Last change on this file since 8709aa04 was d4edbdbc, checked in by Sebastian Huber <sebastian.huber@…>, on 03/20/15 at 13:09:26

Replace www.rtems.com with www.rtems.org

  • Property mode set to 100644
File size: 2.7 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 "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    "load",
62    "unload",
63    "section",
64    "symbol",
65    "reloc",
66    "global-sym",
67    "load-sect",
68    "allocator",
69    "unresolved",
70    "detail"
71  };
72
73  rtems_rtl_trace_mask set_value = 0;
74  rtems_rtl_trace_mask clear_value = 0;
75  bool                 set = true;
76  int                  arg;
77  int                  t;
78
79  for (arg = 1; arg < argc; arg++)
80  {
81    if (argv[arg][0] == '-')
82    {
83      switch (argv[arg][1])
84      {
85        case 'h':
86          printf ("usage: %s [-hl] [set/clear] [flags]\n", argv[0]);
87          return 0;
88        case 'l':
89          printf ("%s: valid flags to set or clear are:\n", argv[0]);
90          for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
91            printf ("  %s\n", table[t]);
92          return 0;
93        default:
94          printf ("error: unknown option\n");
95          return 1;
96      }
97    }
98    else
99    {
100      if (strcmp (argv[arg], "set") == 0)
101        set = true;
102      if (strcmp (argv[arg], "clear") == 0)
103        set = false;
104      else if (strcmp (argv[arg], "all") == 0)
105      {
106        if (set)
107          set_value = RTEMS_RTL_TRACE_ALL;
108        else
109          clear_value = RTEMS_RTL_TRACE_ALL;
110      }
111      else
112      {
113        for (t = 0; t < (sizeof (table) / sizeof (const char*)); t++)
114        {
115          if (strcmp (argv[arg], table[t]) == 0)
116          {
117            if (set)
118              set_value = 1 << t;
119            else
120              clear_value = 1 << t;
121            break;
122          }
123        }
124      }
125
126      rtems_rtl_trace_flags |= set_value;
127      rtems_rtl_trace_flags &= ~clear_value;
128    }
129  }
130
131  return 0;
132}
133
134#endif
Note: See TracBrowser for help on using the repository browser.