Beispiel #1
0
static void
maintenance_info_sections (char *arg, int from_tty)
{
  if (exec_bfd)
    {
      printf_filtered (_("Exec file:\n"));
      printf_filtered ("    `%s', ", bfd_get_filename (exec_bfd));
      wrap_here ("        ");
      printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
      if (arg && *arg && match_substring (arg, "ALLOBJ"))
	{
	  struct objfile *ofile;
	  struct obj_section *osect;

	  /* Only this function cares about the 'ALLOBJ' argument; 
	     if 'ALLOBJ' is the only argument, discard it rather than
	     passing it down to print_objfile_section_info (which 
	     wouldn't know how to handle it).  */
	  if (strcmp (arg, "ALLOBJ") == 0)
	    arg = NULL;

	  ALL_OBJFILES (ofile)
	    {
	      printf_filtered (_("  Object file: %s\n"), 
			       bfd_get_filename (ofile->obfd));
	      ALL_OBJFILE_OSECTIONS (ofile, osect)
		{
		  print_objfile_section_info (ofile->obfd, osect, arg);
		}
	    }
	}
      else 
Beispiel #2
0
static void
print_objfile_section_info(bfd *abfd, struct obj_section *asect,
			   const char *string)
{
  flagword flags = bfd_get_section_flags(abfd, asect->the_bfd_section);
  const char *name = bfd_section_name(abfd, asect->the_bfd_section);

  if ((string == NULL) || (*string == '\0')
      || match_substring(string, name)
      || match_bfd_flags(string, flags))
    {
      maint_print_section_info(name, flags, asect->addr, asect->endaddr,
			  (unsigned long)asect->the_bfd_section->filepos);
    }
}
Beispiel #3
0
static void
print_bfd_section_info(bfd *abfd, asection *asect, void *arg)
{
  flagword flags = bfd_get_section_flags(abfd, asect);
  const char *name = bfd_section_name(abfd, asect);

  if ((arg == NULL) || (*((char *)arg) == '\0')
      || match_substring((char *)arg, name)
      || match_bfd_flags((char *)arg, flags))
    {
      CORE_ADDR addr, endaddr;

      addr = bfd_section_vma(abfd, asect);
      endaddr = (addr + bfd_section_size(abfd, asect));
      maint_print_section_info(name, flags, addr, endaddr,
                               (unsigned long)asect->filepos);
    }
}
Beispiel #4
0
static void
print_objfile_section_info (bfd *abfd, 
			    struct obj_section *asect, 
			    const char *string)
{
  flagword flags = bfd_get_section_flags (abfd, asect->the_bfd_section);
  const char *name = bfd_section_name (abfd, asect->the_bfd_section);

  if (string == NULL || *string == '\0'
      || match_substring (string, name)
      || match_bfd_flags (string, flags))
    {
      struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
      int addr_size = gdbarch_addr_bit (gdbarch) / 8;

      maint_print_section_info (name, flags,
				obj_section_addr (asect),
				obj_section_endaddr (asect),
				asect->the_bfd_section->filepos,
				addr_size);
    }
}
Beispiel #5
0
static void
print_bfd_section_info (bfd *abfd, 
			asection *asect, 
			void *arg)
{
  flagword flags = bfd_get_section_flags (abfd, asect);
  const char *name = bfd_section_name (abfd, asect);

  if (arg == NULL || *((char *) arg) == '\0'
      || match_substring ((char *) arg, name)
      || match_bfd_flags ((char *) arg, flags))
    {
      struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
      int addr_size = gdbarch_addr_bit (gdbarch) / 8;
      CORE_ADDR addr, endaddr;

      addr = bfd_section_vma (abfd, asect);
      endaddr = addr + bfd_section_size (abfd, asect);
      maint_print_section_info (name, flags, addr, endaddr,
				asect->filepos, addr_size);
    }
}
Beispiel #6
0
int main()
{
    std::string s("aaabbbccd123456eeffgg");
    std::smatch match;
    // This one also works but matches more than is required
    // std::regex braced_regex("(\\D+)(\\d{2,})(\\D+)");
    std::regex braced_regex("([[:alpha:]]+?)(\\d+)([[:alpha:]]+?)");
    std::regex plus_regex("(\\w+?)(\\d+)(\\w+?)");

    auto printer = [](auto& match) {
            std::ssub_match sub(match);
            std::string match_substring(sub.str());
            std::cout <<  match_substring << '\n';
    };

    std::regex_match(s, match, braced_regex);
    std::cout << "Number of braced matches: " << match.size() << '\n';  
    std::for_each(match.begin(), match.end(), printer);

    std::regex_match(s, match, plus_regex);
    std::cout << "Number of plus matches: " << match.size() << '\n';  
    std::for_each(match.begin(), match.end(), printer);
    return 0;
}
Beispiel #7
0
static int 
match_bfd_flags (char *string, flagword flags)
{
  if (flags & SEC_ALLOC)
    if (match_substring (string, "ALLOC"))
      return 1;
  if (flags & SEC_LOAD)
    if (match_substring (string, "LOAD"))
      return 1;
  if (flags & SEC_RELOC)
    if (match_substring (string, "RELOC"))
      return 1;
  if (flags & SEC_READONLY)
    if (match_substring (string, "READONLY"))
      return 1;
  if (flags & SEC_CODE)
    if (match_substring (string, "CODE"))
      return 1;
  if (flags & SEC_DATA)
    if (match_substring (string, "DATA"))
      return 1;
  if (flags & SEC_ROM)
    if (match_substring (string, "ROM"))
      return 1;
  if (flags & SEC_CONSTRUCTOR)
    if (match_substring (string, "CONSTRUCTOR"))
      return 1;
  if (flags & SEC_HAS_CONTENTS)
    if (match_substring (string, "HAS_CONTENTS"))
      return 1;
  if (flags & SEC_NEVER_LOAD)
    if (match_substring (string, "NEVER_LOAD"))
      return 1;
  if (flags & SEC_COFF_SHARED_LIBRARY)
    if (match_substring (string, "COFF_SHARED_LIBRARY"))
      return 1;
  if (flags & SEC_IS_COMMON)
    if (match_substring (string, "IS_COMMON"))
      return 1;

  return 0;
}