Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Side by Side Diff: gdb/objc-lang.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/objc-exp.y ('k') | gdb/objfiles.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Objective-C language support routines for GDB, the GNU debugger. 1 /* Objective-C language support routines for GDB, the GNU debugger.
2 2
3 Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc.
4 4
5 Contributed by Apple Computer, Inc. 5 Contributed by Apple Computer, Inc.
6 Written by Michael Snyder. 6 Written by Michael Snyder.
7 7
8 This file is part of GDB. 8 This file is part of GDB.
9 9
10 This program is free software; you can redistribute it and/or modify 10 This program is free software; you can redistribute it and/or modify
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 objc_parse, 517 objc_parse,
518 objc_error, 518 objc_error,
519 null_post_parser, 519 null_post_parser,
520 objc_printchar, /* Print a character constant */ 520 objc_printchar, /* Print a character constant */
521 objc_printstr, /* Function to print string constant */ 521 objc_printstr, /* Function to print string constant */
522 objc_emit_char, 522 objc_emit_char,
523 c_print_type, /* Print a type using appropriate syntax */ 523 c_print_type, /* Print a type using appropriate syntax */
524 c_print_typedef, /* Print a typedef using appropriate syntax */ 524 c_print_typedef, /* Print a typedef using appropriate syntax */
525 c_val_print, /* Print a value using appropriate syntax */ 525 c_val_print, /* Print a value using appropriate syntax */
526 c_value_print, /* Print a top-level value */ 526 c_value_print, /* Print a top-level value */
527 default_read_var_value, /* la_read_var_value */
527 objc_skip_trampoline, /* Language specific skip_trampoline */ 528 objc_skip_trampoline, /* Language specific skip_trampoline */
528 "self", /* name_of_this */ 529 "self", /* name_of_this */
529 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ 530 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
530 basic_lookup_transparent_type,/* lookup_transparent_type */ 531 basic_lookup_transparent_type,/* lookup_transparent_type */
531 objc_demangle, /* Language specific symbol demangler */ 532 objc_demangle, /* Language specific symbol demangler */
532 NULL, /* Language specific 533 NULL, /* Language specific
533 class_name_from_physname */ 534 class_name_from_physname */
534 objc_op_print_tab, /* Expression operators for printing */ 535 objc_op_print_tab, /* Expression operators for printing */
535 1, /* C-style arrays */ 536 1, /* C-style arrays */
536 0, /* String lower bound */ 537 0, /* String lower bound */
537 default_word_break_characters, 538 default_word_break_characters,
538 default_make_symbol_completion_list, 539 default_make_symbol_completion_list,
539 c_language_arch_info, 540 c_language_arch_info,
540 default_print_array_index, 541 default_print_array_index,
541 default_pass_by_reference, 542 default_pass_by_reference,
542 default_get_string, 543 default_get_string,
543 strcmp_iw_ordered, 544 NULL,»» » » /* la_get_symbol_name_cmp */
544 iterate_over_symbols, 545 iterate_over_symbols,
545 LANG_MAGIC 546 LANG_MAGIC
546 }; 547 };
547 548
548 /* 549 /*
549 * ObjC: 550 * ObjC:
550 * Following functions help construct Objective-C message calls. 551 * Following functions help construct Objective-C message calls.
551 */ 552 */
552 553
553 struct selname /* For parsing Objective-C. */ 554 struct selname /* For parsing Objective-C. */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 error (_("Can't find selector \"%s\""), p); 630 error (_("Can't find selector \"%s\""), p);
630 write_exp_elt_longcst (selid); 631 write_exp_elt_longcst (selid);
631 xfree(p); 632 xfree(p);
632 write_exp_elt_longcst (val); /* Number of args */ 633 write_exp_elt_longcst (val); /* Number of args */
633 xfree(sel); 634 xfree(sel);
634 635
635 return val; 636 return val;
636 } 637 }
637 638
638 /* 639 /*
639 * Function: specialcmp (char *a, char *b) 640 * Function: specialcmp (const char *a, const char *b)
640 * 641 *
641 * Special strcmp: treats ']' and ' ' as end-of-string. 642 * Special strcmp: treats ']' and ' ' as end-of-string.
642 * Used for qsorting lists of objc methods (either by class or selector). 643 * Used for qsorting lists of objc methods (either by class or selector).
643 */ 644 */
644 645
645 static int 646 static int
646 specialcmp (char *a, char *b) 647 specialcmp (const char *a, const char *b)
647 { 648 {
648 while (*a && *a != ' ' && *a != ']' && *b && *b != ' ' && *b != ']') 649 while (*a && *a != ' ' && *a != ']' && *b && *b != ' ' && *b != ']')
649 { 650 {
650 if (*a != *b) 651 if (*a != *b)
651 return *a - *b; 652 return *a - *b;
652 a++, b++; 653 a++, b++;
653 } 654 }
654 if (*a && *a != ' ' && *a != ']') 655 if (*a && *a != ' ' && *a != ']')
655 return 1; /* a is longer therefore greater. */ 656 return 1; /* a is longer therefore greater. */
656 if (*b && *b != ' ' && *b != ']') 657 if (*b && *b != ' ' && *b != ']')
657 return -1; /* a is shorter therefore lesser. */ 658 return -1; /* a is shorter therefore lesser. */
658 return 0; /* a and b are identical. */ 659 return 0; /* a and b are identical. */
659 } 660 }
660 661
661 /* 662 /*
662 * Function: compare_selectors (const void *, const void *) 663 * Function: compare_selectors (const void *, const void *)
663 * 664 *
664 * Comparison function for use with qsort. Arguments are symbols or 665 * Comparison function for use with qsort. Arguments are symbols or
665 * msymbols Compares selector part of objc method name alphabetically. 666 * msymbols Compares selector part of objc method name alphabetically.
666 */ 667 */
667 668
668 static int 669 static int
669 compare_selectors (const void *a, const void *b) 670 compare_selectors (const void *a, const void *b)
670 { 671 {
671 char *aname, *bname; 672 const char *aname, *bname;
672 673
673 aname = SYMBOL_PRINT_NAME (*(struct symbol **) a); 674 aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
674 bname = SYMBOL_PRINT_NAME (*(struct symbol **) b); 675 bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
675 if (aname == NULL || bname == NULL) 676 if (aname == NULL || bname == NULL)
676 error (_("internal: compare_selectors(1)")); 677 error (_("internal: compare_selectors(1)"));
677 678
678 aname = strchr(aname, ' '); 679 aname = strchr(aname, ' ');
679 bname = strchr(bname, ' '); 680 bname = strchr(bname, ' ');
680 if (aname == NULL || bname == NULL) 681 if (aname == NULL || bname == NULL)
681 error (_("internal: compare_selectors(2)")); 682 error (_("internal: compare_selectors(2)"));
682 683
683 return specialcmp (aname+1, bname+1); 684 return specialcmp (aname+1, bname+1);
684 } 685 }
685 686
686 /* 687 /*
687 * Function: selectors_info (regexp, from_tty) 688 * Function: selectors_info (regexp, from_tty)
688 * 689 *
689 * Implements the "Info selectors" command. Takes an optional regexp 690 * Implements the "Info selectors" command. Takes an optional regexp
690 * arg. Lists all objective c selectors that match the regexp. Works 691 * arg. Lists all objective c selectors that match the regexp. Works
691 * by grepping thru all symbols for objective c methods. Output list 692 * by grepping thru all symbols for objective c methods. Output list
692 * is sorted and uniqued. 693 * is sorted and uniqued.
693 */ 694 */
694 695
695 static void 696 static void
696 selectors_info (char *regexp, int from_tty) 697 selectors_info (char *regexp, int from_tty)
697 { 698 {
698 struct objfile *objfile; 699 struct objfile *objfile;
699 struct minimal_symbol *msymbol; 700 struct minimal_symbol *msymbol;
700 char *name; 701 const char *name;
701 char *val; 702 char *val;
702 int matches = 0; 703 int matches = 0;
703 int maxlen = 0; 704 int maxlen = 0;
704 int ix; 705 int ix;
705 char myregexp[2048]; 706 char myregexp[2048];
706 char asel[256]; 707 char asel[256];
707 struct symbol **sym_arr; 708 struct symbol **sym_arr;
708 int plusminus = 0; 709 int plusminus = 0;
709 710
710 if (regexp == NULL) 711 if (regexp == NULL)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 name = (char *) strchr (name+2, ' '); 756 name = (char *) strchr (name+2, ' ');
756 if (name == NULL) 757 if (name == NULL)
757 { 758 {
758 complaint (&symfile_complaints, 759 complaint (&symfile_complaints,
759 _("Bad method name '%s'"), 760 _("Bad method name '%s'"),
760 SYMBOL_NATURAL_NAME (msymbol)); 761 SYMBOL_NATURAL_NAME (msymbol));
761 continue; 762 continue;
762 } 763 }
763 if (regexp == NULL || re_exec(++name) != 0) 764 if (regexp == NULL || re_exec(++name) != 0)
764 { 765 {
765 » char *mystart = name; 766 » const char *mystart = name;
766 » char *myend = (char *) strchr (mystart, ']'); 767 » const char *myend = strchr (mystart, ']');
767 768
768 if (myend && (myend - mystart > maxlen)) 769 if (myend && (myend - mystart > maxlen))
769 maxlen = myend - mystart; /* Get longest selector. */ 770 maxlen = myend - mystart; /* Get longest selector. */
770 matches++; 771 matches++;
771 } 772 }
772 } 773 }
773 } 774 }
774 if (matches) 775 if (matches)
775 { 776 {
776 printf_filtered (_("Selectors matching \"%s\":\n\n"), 777 printf_filtered (_("Selectors matching \"%s\":\n\n"),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 /* 828 /*
828 * Function: compare_classes (const void *, const void *) 829 * Function: compare_classes (const void *, const void *)
829 * 830 *
830 * Comparison function for use with qsort. Arguments are symbols or 831 * Comparison function for use with qsort. Arguments are symbols or
831 * msymbols Compares class part of objc method name alphabetically. 832 * msymbols Compares class part of objc method name alphabetically.
832 */ 833 */
833 834
834 static int 835 static int
835 compare_classes (const void *a, const void *b) 836 compare_classes (const void *a, const void *b)
836 { 837 {
837 char *aname, *bname; 838 const char *aname, *bname;
838 839
839 aname = SYMBOL_PRINT_NAME (*(struct symbol **) a); 840 aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
840 bname = SYMBOL_PRINT_NAME (*(struct symbol **) b); 841 bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
841 if (aname == NULL || bname == NULL) 842 if (aname == NULL || bname == NULL)
842 error (_("internal: compare_classes(1)")); 843 error (_("internal: compare_classes(1)"));
843 844
844 return specialcmp (aname+1, bname+1); 845 return specialcmp (aname+1, bname+1);
845 } 846 }
846 847
847 /* 848 /*
848 * Function: classes_info(regexp, from_tty) 849 * Function: classes_info(regexp, from_tty)
849 * 850 *
850 * Implements the "info classes" command for objective c classes. 851 * Implements the "info classes" command for objective c classes.
851 * Lists all objective c classes that match the optional regexp. 852 * Lists all objective c classes that match the optional regexp.
852 * Works by grepping thru the list of objective c methods. List will 853 * Works by grepping thru the list of objective c methods. List will
853 * be sorted and uniqued (since one class may have many methods). 854 * be sorted and uniqued (since one class may have many methods).
854 * BUGS: will not list a class that has no methods. 855 * BUGS: will not list a class that has no methods.
855 */ 856 */
856 857
857 static void 858 static void
858 classes_info (char *regexp, int from_tty) 859 classes_info (char *regexp, int from_tty)
859 { 860 {
860 struct objfile *objfile; 861 struct objfile *objfile;
861 struct minimal_symbol *msymbol; 862 struct minimal_symbol *msymbol;
862 char *name; 863 const char *name;
863 char *val; 864 char *val;
864 int matches = 0; 865 int matches = 0;
865 int maxlen = 0; 866 int maxlen = 0;
866 int ix; 867 int ix;
867 char myregexp[2048]; 868 char myregexp[2048];
868 char aclass[256]; 869 char aclass[256];
869 struct symbol **sym_arr; 870 struct symbol **sym_arr;
870 871
871 if (regexp == NULL) 872 if (regexp == NULL)
872 strcpy(myregexp, ".* "); /* Null input: match all objc classes. */ 873 strcpy(myregexp, ".* "); /* Null input: match all objc classes. */
(...skipping 21 matching lines...) Expand all
894 ALL_MSYMBOLS (objfile, msymbol) 895 ALL_MSYMBOLS (objfile, msymbol)
895 { 896 {
896 QUIT; 897 QUIT;
897 name = SYMBOL_NATURAL_NAME (msymbol); 898 name = SYMBOL_NATURAL_NAME (msymbol);
898 if (name && 899 if (name &&
899 (name[0] == '-' || name[0] == '+') && 900 (name[0] == '-' || name[0] == '+') &&
900 name[1] == '[') /* Got a method name. */ 901 name[1] == '[') /* Got a method name. */
901 if (regexp == NULL || re_exec(name+2) != 0) 902 if (regexp == NULL || re_exec(name+2) != 0)
902 { 903 {
903 /* Compute length of classname part. */ 904 /* Compute length of classname part. */
904 » char *mystart = name + 2; 905 » const char *mystart = name + 2;
905 » char *myend = (char *) strchr(mystart, ' '); 906 » const char *myend = strchr (mystart, ' ');
906 907
907 if (myend && (myend - mystart > maxlen)) 908 if (myend && (myend - mystart > maxlen))
908 maxlen = myend - mystart; 909 maxlen = myend - mystart;
909 matches++; 910 matches++;
910 } 911 }
911 } 912 }
912 if (matches) 913 if (matches)
913 { 914 {
914 printf_filtered (_("Classes matching \"%s\":\n\n"), 915 printf_filtered (_("Classes matching \"%s\":\n\n"),
915 regexp ? regexp : "*"); 916 regexp ? regexp : "*");
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 return s2; 1113 return s2;
1113 } 1114 }
1114 1115
1115 static void 1116 static void
1116 find_methods (char type, const char *class, const char *category, 1117 find_methods (char type, const char *class, const char *category,
1117 const char *selector, 1118 const char *selector,
1118 VEC (const_char_ptr) **symbol_names) 1119 VEC (const_char_ptr) **symbol_names)
1119 { 1120 {
1120 struct objfile *objfile = NULL; 1121 struct objfile *objfile = NULL;
1121 1122
1122 char *symname = NULL; 1123 const char *symname = NULL;
1123 1124
1124 char ntype = '\0'; 1125 char ntype = '\0';
1125 char *nclass = NULL; 1126 char *nclass = NULL;
1126 char *ncategory = NULL; 1127 char *ncategory = NULL;
1127 char *nselector = NULL; 1128 char *nselector = NULL;
1128 1129
1129 static char *tmp = NULL; 1130 static char *tmp = NULL;
1130 static unsigned int tmplen = 0; 1131 static unsigned int tmplen = 0;
1131 1132
1132 gdb_assert (symbol_names != NULL); 1133 gdb_assert (symbol_names != NULL);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 return 0; 1760 return 0;
1760 1761
1761 res = find_implementation_from_class (gdbarch, sstr.class, sel); 1762 res = find_implementation_from_class (gdbarch, sstr.class, sel);
1762 if (new_pc != 0) 1763 if (new_pc != 0)
1763 *new_pc = res; 1764 *new_pc = res;
1764 if (res == 0) 1765 if (res == 0)
1765 return 1; 1766 return 1;
1766 return 0; 1767 return 0;
1767 } 1768 }
1768 1769
1770 /* Provide a prototype to silence -Wmissing-prototypes. */
1771 extern initialize_file_ftype _initialize_objc_lang;
1772
1769 void 1773 void
1770 _initialize_objc_lang (void) 1774 _initialize_objc_lang (void)
1771 { 1775 {
1772 objc_objfile_data = register_objfile_data (); 1776 objc_objfile_data = register_objfile_data ();
1773 } 1777 }
OLDNEW
« no previous file with comments | « gdb/objc-exp.y ('k') | gdb/objfiles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698