OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.18.50/] [gas/] [remap.c] - Diff between revs 38 and 156

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 156
/* Remap file names for debug info for GNU assembler.
/* Remap file names for debug info for GNU assembler.
   Copyright 2007 Free Software Foundation, Inc.
   Copyright 2007 Free Software Foundation, Inc.
 
 
   This file is part of GAS, the GNU Assembler.
   This file is part of GAS, the GNU Assembler.
 
 
   GAS is free software; you can redistribute it and/or modify
   GAS is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
   any later version.
 
 
   GAS is distributed in the hope that it will be useful,
   GAS is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with GAS; see the file COPYING.  If not, write to the Free
   along with GAS; see the file COPYING.  If not, write to the Free
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
   02110-1301, USA.  */
   02110-1301, USA.  */
 
 
#include "as.h"
#include "as.h"
 
 
/* Structure recording the mapping from source file and directory
/* Structure recording the mapping from source file and directory
   names at compile time to those to be embedded in debug
   names at compile time to those to be embedded in debug
   information.  */
   information.  */
typedef struct debug_prefix_map
typedef struct debug_prefix_map
{
{
  const char *old_prefix;
  const char *old_prefix;
  const char *new_prefix;
  const char *new_prefix;
  size_t old_len;
  size_t old_len;
  size_t new_len;
  size_t new_len;
  struct debug_prefix_map *next;
  struct debug_prefix_map *next;
} debug_prefix_map;
} debug_prefix_map;
 
 
/* Linked list of such structures.  */
/* Linked list of such structures.  */
debug_prefix_map *debug_prefix_maps;
debug_prefix_map *debug_prefix_maps;
 
 
 
 
/* Record a debug file prefix mapping.  ARG is the argument to
/* Record a debug file prefix mapping.  ARG is the argument to
   -fdebug-prefix-map and must be of the form OLD=NEW.  */
   -fdebug-prefix-map and must be of the form OLD=NEW.  */
 
 
void
void
add_debug_prefix_map (const char *arg)
add_debug_prefix_map (const char *arg)
{
{
  debug_prefix_map *map;
  debug_prefix_map *map;
  const char *p;
  const char *p;
  char *o;
  char *o;
 
 
  p = strchr (arg, '=');
  p = strchr (arg, '=');
  if (!p)
  if (!p)
    {
    {
      as_fatal (_("invalid argument '%s' to -fdebug-prefix-map"), arg);
      as_fatal (_("invalid argument '%s' to -fdebug-prefix-map"), arg);
      return;
      return;
    }
    }
  map = xmalloc (sizeof (debug_prefix_map));
  map = xmalloc (sizeof (debug_prefix_map));
  o = xstrdup (arg);
  o = xstrdup (arg);
  map->old_prefix = o;
  map->old_prefix = o;
  map->old_len = p - arg;
  map->old_len = p - arg;
  o[map->old_len] = 0;
  o[map->old_len] = 0;
  p++;
  p++;
  map->new_prefix = xstrdup (p);
  map->new_prefix = xstrdup (p);
  map->new_len = strlen (p);
  map->new_len = strlen (p);
  map->next = debug_prefix_maps;
  map->next = debug_prefix_maps;
  debug_prefix_maps = map;
  debug_prefix_maps = map;
}
}
 
 
/* Perform user-specified mapping of debug filename prefixes.  Return
/* Perform user-specified mapping of debug filename prefixes.  Return
   the new name corresponding to FILENAME.  */
   the new name corresponding to FILENAME.  */
 
 
const char *
const char *
remap_debug_filename (const char *filename)
remap_debug_filename (const char *filename)
{
{
  debug_prefix_map *map;
  debug_prefix_map *map;
  char *s;
  char *s;
  const char *name;
  const char *name;
  size_t name_len;
  size_t name_len;
 
 
  for (map = debug_prefix_maps; map; map = map->next)
  for (map = debug_prefix_maps; map; map = map->next)
    if (strncmp (filename, map->old_prefix, map->old_len) == 0)
    if (strncmp (filename, map->old_prefix, map->old_len) == 0)
      break;
      break;
  if (!map)
  if (!map)
    return filename;
    return filename;
  name = filename + map->old_len;
  name = filename + map->old_len;
  name_len = strlen (name) + 1;
  name_len = strlen (name) + 1;
  s = (char *) alloca (name_len + map->new_len);
  s = (char *) alloca (name_len + map->new_len);
  memcpy (s, map->new_prefix, map->new_len);
  memcpy (s, map->new_prefix, map->new_len);
  memcpy (s + map->new_len, name, name_len);
  memcpy (s + map->new_len, name, name_len);
  return xstrdup (s);
  return xstrdup (s);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.