source: rtems/cpukit/libdl/rtl-trace.c @ 58c34961

5
Last change on this file since 58c34961 was 58c34961, checked in by Chris Johns <chrisj@…>, on 08/12/16 at 08:02:52

libdl: Fix cache corruption bugs.

This patch fixes a number of bugs in the cache when requests are
made to read close to the end of the file and the data is copied
from the top of the cache buffer to the bottom of the buffer. This
was compounded by attempting to read past the end of the file.

Closes #2754.

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