--- crash-4.1.0/main.c 2009-11-20 14:38:03.000000000 -0500 +++ crash-4.1.1/main.c 2009-11-03 10:48:22.000000000 -0500 @@ -594,12 +594,12 @@ } /* - * get_command_line() reads, parses and stores input command lines + * process_command_line() reads, parses and stores input command lines * in the global args[] array. exec_command() figures out what to * do with the parsed line. */ while (TRUE) { - get_command_line(); + process_command_line(); exec_command(); } } --- crash-4.1.0/tools.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/tools.c 2009-11-17 09:38:26.000000000 -0500 @@ -2113,9 +2113,9 @@ optind++; if (args[optind]) { if (decimal(args[optind], 0)) - print_max = atoi(args[optind]); + *gdb_print_max = atoi(args[optind]); else if (hexadecimal(args[optind], 0)) - print_max = (unsigned int) + *gdb_print_max = (unsigned int) htol(args[optind], FAULT_ON_ERROR, NULL); else @@ -2123,29 +2123,29 @@ } if (runtime) - fprintf(fp, "print_max: %d\n", print_max); + fprintf(fp, "print_max: %d\n", *gdb_print_max); return; } else if (STREQ(args[optind], "null-stop")) { optind++; if (args[optind]) { if (STREQ(args[optind], "on")) - stop_print_at_null = 1; + *gdb_stop_print_at_null = 1; else if (STREQ(args[optind], "off")) - stop_print_at_null = 0; + *gdb_stop_print_at_null = 0; else if (IS_A_NUMBER(args[optind])) { value = stol(args[optind], FAULT_ON_ERROR, NULL); if (value) - stop_print_at_null = 1; + *gdb_stop_print_at_null = 1; else - stop_print_at_null = 0; + *gdb_stop_print_at_null = 0; } else goto invalid_set_command; } if (runtime) fprintf(fp, "null-stop: %s\n", - stop_print_at_null ? "on" : "off"); + *gdb_stop_print_at_null ? "on" : "off"); return; } else if (STREQ(args[optind], "dumpfile")) { @@ -2310,7 +2310,7 @@ pc->output_radix == 10 ? "decimal" : pc->output_radix == 16 ? "hexadecimal" : "unknown"); fprintf(fp, " refresh: %s\n", tt->flags & TASK_REFRESH ? "on" : "off"); - fprintf(fp, " print_max: %d\n", print_max); + fprintf(fp, " print_max: %d\n", *gdb_print_max); fprintf(fp, " console: %s\n", pc->console ? pc->console : "(not assigned)"); fprintf(fp, " debug: %ld\n", pc->debug); @@ -2322,7 +2322,7 @@ fprintf(fp, " dumpfile: %s\n", pc->dumpfile); fprintf(fp, " unwind: %s\n", kt->flags & DWARF_UNWIND ? "on" : "off"); fprintf(fp, " zero_excluded: %s\n", *diskdump_flags & ZERO_EXCLUDED ? "on" : "off"); - fprintf(fp, " null-stop: %s\n", stop_print_at_null ? "on" : "off"); + fprintf(fp, " null-stop: %s\n", *gdb_stop_print_at_null ? "on" : "off"); } @@ -4314,6 +4314,25 @@ } /* + * Change the size of the previously-allocated memory block + * pointed to by oldbuf to newsize bytes. Copy the minimum + * of oldsize and newsize bytes from the oldbuf to the newbuf, + * and return the address of the new buffer, which will have + * a different address than oldbuf. + */ +char * +resizebuf(char *oldbuf, long oldsize, long newsize) +{ + char *newbuf; + + newbuf = GETBUF(newsize); + BCOPY(oldbuf, newbuf, MIN(oldsize, newsize)); + FREEBUF(oldbuf); + + return newbuf; +} + +/* * Return the number of bits set in an int or long. */ --- crash-4.1.0/help.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/help.c 2009-10-27 11:48:13.000000000 -0400 @@ -26,11 +26,21 @@ static void display_input_info(void); static void display_README(void); static char *gnu_public_license[]; +static char *gnu_public_license_v3[]; static char *version_info[]; static char *output_info[]; static char *input_info[]; static char *README[]; +#define GPLv2 2 +#define GPLv3 3 + +#if defined(GDB_7_0) +static int GPL_version = GPLv3; +#else +static int GPL_version = GPLv2; +#endif + static char *program_usage_info[] = { "\nUsage:\n %s [-h [opt]][-v][-s][-i file][-d num] [-S] [mapfile] [namelist] [dumpfile]\n", @@ -1271,7 +1281,7 @@ char *help_bt[] = { "bt", "backtrace", -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) "[-a|-g|-r|-t|-T|-l|-e|-E|-f|-o|-O] [-R ref] [ -I ip ] [-S sp] [pid | taskp]", #else "[-a|-r|-t|-l|-e|-f|-g] [-R ref] [ -I ip ] [-S sp] [pid | taskp]", @@ -1306,7 +1316,7 @@ " of this option toggles the backtrace method.", " x86_64: use old backtrace method by default; subsequent usage of this", " option toggles the backtrace method.", -#if !defined(GDB_6_0) && !defined(GDB_6_1) +#if !defined(GDB_6_0) && !defined(GDB_6_1) && !defined(GDB_7_0) " -g use gdb stack trace code. (alpha only)", #endif " -R ref display stack trace only if there is a reference to this symbol", @@ -2529,6 +2539,8 @@ " builtin for foreach", " builtin size *", " builtin dmesg log", +" builtin lsmod mod", +" builtin last ps -l", " ", " Create a new alias to be added to the list:\n", " %s> alias kp kmem -p", @@ -5299,8 +5311,19 @@ { int i; - for (i = 0; !strstr(gnu_public_license[i], "NO WARRANTY"); i++) - fprintf(fp, "%s\n", gnu_public_license[i]); + switch (GPL_version) + { + case GPLv2: + for (i = 0; !strstr(gnu_public_license[i], "NO WARRANTY"); i++) + fprintf(fp, "%s\n", gnu_public_license[i]); + break; + + case GPLv3: + for (i = 0; !strstr(gnu_public_license_v3[i], + "15. Disclaimer of Warranty."); i++) + fprintf(fp, "%s\n", gnu_public_license_v3[i]); + break; + } } /* @@ -5309,14 +5332,28 @@ static void display_warranty_info(void) { - int i; - - for (i = 0; !strstr(gnu_public_license[i], "NO WARRANTY"); i++) - ; + int i; - do { - fprintf(fp, "%s\n", gnu_public_license[i]); - } while (!strstr(gnu_public_license[i++], "END OF TERMS")); + switch (GPL_version) + { + case GPLv2: + for (i = 0; !strstr(gnu_public_license[i], "NO WARRANTY"); i++) + ; + + do { + fprintf(fp, "%s\n", gnu_public_license[i]); + } while (!strstr(gnu_public_license[i++], "END OF TERMS")); + break; + + case GPLv3: + for (i = 0; !strstr(gnu_public_license_v3[i], + "15. Disclaimer of Warranty."); i++) + ; + + while (!strstr(gnu_public_license_v3[i], "END OF TERMS")) + fprintf(fp, "%s\n", gnu_public_license_v3[i++]); + break; + } } static @@ -5604,6 +5641,631 @@ " END OF TERMS AND CONDITIONS\n", }; +static +char *gnu_public_license_v3[] = { +" GNU GENERAL PUBLIC LICENSE", +" Version 3, 29 June 2007", +"", +" Copyright (C) 2007 Free Software Foundation, Inc. ", +" Everyone is permitted to copy and distribute verbatim copies", +" of this license document, but changing it is not allowed.", +"", +" Preamble", +"", +" The GNU General Public License is a free, copyleft license for", +"software and other kinds of works.", +"", +" The licenses for most software and other practical works are designed", +"to take away your freedom to share and change the works. By contrast,", +"the GNU General Public License is intended to guarantee your freedom to", +"share and change all versions of a program--to make sure it remains free", +"software for all its users. We, the Free Software Foundation, use the", +"GNU General Public License for most of our software; it applies also to", +"any other work released this way by its authors. You can apply it to", +"your programs, too.", +"", +" When we speak of free software, we are referring to freedom, not", +"price. Our General Public Licenses are designed to make sure that you", +"have the freedom to distribute copies of free software (and charge for", +"them if you wish), that you receive source code or can get it if you", +"want it, that you can change the software or use pieces of it in new", +"free programs, and that you know you can do these things.", +"", +" To protect your rights, we need to prevent others from denying you", +"these rights or asking you to surrender the rights. Therefore, you have", +"certain responsibilities if you distribute copies of the software, or if", +"you modify it: responsibilities to respect the freedom of others.", +"", +" For example, if you distribute copies of such a program, whether", +"gratis or for a fee, you must pass on to the recipients the same", +"freedoms that you received. You must make sure that they, too, receive", +"or can get the source code. And you must show them these terms so they", +"know their rights.", +"", +" Developers that use the GNU GPL protect your rights with two steps:", +"(1) assert copyright on the software, and (2) offer you this License", +"giving you legal permission to copy, distribute and/or modify it.", +"", +" For the developers' and authors' protection, the GPL clearly explains", +"that there is no warranty for this free software. For both users' and", +"authors' sake, the GPL requires that modified versions be marked as", +"changed, so that their problems will not be attributed erroneously to", +"authors of previous versions.", +"", +" Some devices are designed to deny users access to install or run", +"modified versions of the software inside them, although the manufacturer", +"can do so. This is fundamentally incompatible with the aim of", +"protecting users' freedom to change the software. The systematic", +"pattern of such abuse occurs in the area of products for individuals to", +"use, which is precisely where it is most unacceptable. Therefore, we", +"have designed this version of the GPL to prohibit the practice for those", +"products. If such problems arise substantially in other domains, we", +"stand ready to extend this provision to those domains in future versions", +"of the GPL, as needed to protect the freedom of users.", +"", +" Finally, every program is threatened constantly by software patents.", +"States should not allow patents to restrict development and use of", +"software on general-purpose computers, but in those that do, we wish to", +"avoid the special danger that patents applied to a free program could", +"make it effectively proprietary. To prevent this, the GPL assures that", +"patents cannot be used to render the program non-free.", +"", +" The precise terms and conditions for copying, distribution and", +"modification follow.", +"", +" TERMS AND CONDITIONS", +"", +" 0. Definitions.", +"", +" \"This License\" refers to version 3 of the GNU General Public License.", +"", +" \"Copyright\" also means copyright-like laws that apply to other kinds of", +"works, such as semiconductor masks.", +"", +" \"The Program\" refers to any copyrightable work licensed under this", +"License. Each licensee is addressed as \"you\". \"Licensees\" and", +"\"recipients\" may be individuals or organizations.", +"", +" To \"modify\" a work means to copy from or adapt all or part of the work", +"in a fashion requiring copyright permission, other than the making of an", +"exact copy. The resulting work is called a \"modified version\" of the", +"earlier work or a work \"based on\" the earlier work.", +"", +" A \"covered work\" means either the unmodified Program or a work based", +"on the Program.", +"", +" To \"propagate\" a work means to do anything with it that, without", +"permission, would make you directly or secondarily liable for", +"infringement under applicable copyright law, except executing it on a", +"computer or modifying a private copy. Propagation includes copying,", +"distribution (with or without modification), making available to the", +"public, and in some countries other activities as well.", +"", +" To \"convey\" a work means any kind of propagation that enables other", +"parties to make or receive copies. Mere interaction with a user through", +"a computer network, with no transfer of a copy, is not conveying.", +"", +" An interactive user interface displays \"Appropriate Legal Notices\"", +"to the extent that it includes a convenient and prominently visible", +"feature that (1) displays an appropriate copyright notice, and (2)", +"tells the user that there is no warranty for the work (except to the", +"extent that warranties are provided), that licensees may convey the", +"work under this License, and how to view a copy of this License. If", +"the interface presents a list of user commands or options, such as a", +"menu, a prominent item in the list meets this criterion.", +"", +" 1. Source Code.", +"", +" The \"source code\" for a work means the preferred form of the work", +"for making modifications to it. \"Object code\" means any non-source", +"form of a work.", +"", +" A \"Standard Interface\" means an interface that either is an official", +"standard defined by a recognized standards body, or, in the case of", +"interfaces specified for a particular programming language, one that", +"is widely used among developers working in that language.", +"", +" The \"System Libraries\" of an executable work include anything, other", +"than the work as a whole, that (a) is included in the normal form of", +"packaging a Major Component, but which is not part of that Major", +"Component, and (b) serves only to enable use of the work with that", +"Major Component, or to implement a Standard Interface for which an", +"implementation is available to the public in source code form. A", +"\"Major Component\", in this context, means a major essential component", +"(kernel, window system, and so on) of the specific operating system", +"(if any) on which the executable work runs, or a compiler used to", +"produce the work, or an object code interpreter used to run it.", +"", +" The \"Corresponding Source\" for a work in object code form means all", +"the source code needed to generate, install, and (for an executable", +"work) run the object code and to modify the work, including scripts to", +"control those activities. However, it does not include the work's", +"System Libraries, or general-purpose tools or generally available free", +"programs which are used unmodified in performing those activities but", +"which are not part of the work. For example, Corresponding Source", +"includes interface definition files associated with source files for", +"the work, and the source code for shared libraries and dynamically", +"linked subprograms that the work is specifically designed to require,", +"such as by intimate data communication or control flow between those", +"subprograms and other parts of the work.", +"", +" The Corresponding Source need not include anything that users", +"can regenerate automatically from other parts of the Corresponding", +"Source.", +"", +" The Corresponding Source for a work in source code form is that", +"same work.", +"", +" 2. Basic Permissions.", +"", +" All rights granted under this License are granted for the term of", +"copyright on the Program, and are irrevocable provided the stated", +"conditions are met. This License explicitly affirms your unlimited", +"permission to run the unmodified Program. The output from running a", +"covered work is covered by this License only if the output, given its", +"content, constitutes a covered work. This License acknowledges your", +"rights of fair use or other equivalent, as provided by copyright law.", +"", +" You may make, run and propagate covered works that you do not", +"convey, without conditions so long as your license otherwise remains", +"in force. You may convey covered works to others for the sole purpose", +"of having them make modifications exclusively for you, or provide you", +"with facilities for running those works, provided that you comply with", +"the terms of this License in conveying all material for which you do", +"not control copyright. Those thus making or running the covered works", +"for you must do so exclusively on your behalf, under your direction", +"and control, on terms that prohibit them from making any copies of", +"your copyrighted material outside their relationship with you.", +"", +" Conveying under any other circumstances is permitted solely under", +"the conditions stated below. Sublicensing is not allowed; section 10", +"makes it unnecessary.", +"", +" 3. Protecting Users' Legal Rights From Anti-Circumvention Law.", +"", +" No covered work shall be deemed part of an effective technological", +"measure under any applicable law fulfilling obligations under article", +"11 of the WIPO copyright treaty adopted on 20 December 1996, or", +"similar laws prohibiting or restricting circumvention of such", +"measures.", +"", +" When you convey a covered work, you waive any legal power to forbid", +"circumvention of technological measures to the extent such circumvention", +"is effected by exercising rights under this License with respect to", +"the covered work, and you disclaim any intention to limit operation or", +"modification of the work as a means of enforcing, against the work's", +"users, your or third parties' legal rights to forbid circumvention of", +"technological measures.", +"", +" 4. Conveying Verbatim Copies.", +"", +" You may convey verbatim copies of the Program's source code as you", +"receive it, in any medium, provided that you conspicuously and", +"appropriately publish on each copy an appropriate copyright notice;", +"keep intact all notices stating that this License and any", +"non-permissive terms added in accord with section 7 apply to the code;", +"keep intact all notices of the absence of any warranty; and give all", +"recipients a copy of this License along with the Program.", +"", +" You may charge any price or no price for each copy that you convey,", +"and you may offer support or warranty protection for a fee.", +"", +" 5. Conveying Modified Source Versions.", +"", +" You may convey a work based on the Program, or the modifications to", +"produce it from the Program, in the form of source code under the", +"terms of section 4, provided that you also meet all of these conditions:", +"", +" a) The work must carry prominent notices stating that you modified", +" it, and giving a relevant date.", +"", +" b) The work must carry prominent notices stating that it is", +" released under this License and any conditions added under section", +" 7. This requirement modifies the requirement in section 4 to", +" \"keep intact all notices\".", +"", +" c) You must license the entire work, as a whole, under this", +" License to anyone who comes into possession of a copy. This", +" License will therefore apply, along with any applicable section 7", +" additional terms, to the whole of the work, and all its parts,", +" regardless of how they are packaged. This License gives no", +" permission to license the work in any other way, but it does not", +" invalidate such permission if you have separately received it.", +"", +" d) If the work has interactive user interfaces, each must display", +" Appropriate Legal Notices; however, if the Program has interactive", +" interfaces that do not display Appropriate Legal Notices, your", +" work need not make them do so.", +"", +" A compilation of a covered work with other separate and independent", +"works, which are not by their nature extensions of the covered work,", +"and which are not combined with it such as to form a larger program,", +"in or on a volume of a storage or distribution medium, is called an", +"\"aggregate\" if the compilation and its resulting copyright are not", +"used to limit the access or legal rights of the compilation's users", +"beyond what the individual works permit. Inclusion of a covered work", +"in an aggregate does not cause this License to apply to the other", +"parts of the aggregate.", +"", +" 6. Conveying Non-Source Forms.", +"", +" You may convey a covered work in object code form under the terms", +"of sections 4 and 5, provided that you also convey the", +"machine-readable Corresponding Source under the terms of this License,", +"in one of these ways:", +"", +" a) Convey the object code in, or embodied in, a physical product", +" (including a physical distribution medium), accompanied by the", +" Corresponding Source fixed on a durable physical medium", +" customarily used for software interchange.", +"", +" b) Convey the object code in, or embodied in, a physical product", +" (including a physical distribution medium), accompanied by a", +" written offer, valid for at least three years and valid for as", +" long as you offer spare parts or customer support for that product", +" model, to give anyone who possesses the object code either (1) a", +" copy of the Corresponding Source for all the software in the", +" product that is covered by this License, on a durable physical", +" medium customarily used for software interchange, for a price no", +" more than your reasonable cost of physically performing this", +" conveying of source, or (2) access to copy the", +" Corresponding Source from a network server at no charge.", +"", +" c) Convey individual copies of the object code with a copy of the", +" written offer to provide the Corresponding Source. This", +" alternative is allowed only occasionally and noncommercially, and", +" only if you received the object code with such an offer, in accord", +" with subsection 6b.", +"", +" d) Convey the object code by offering access from a designated", +" place (gratis or for a charge), and offer equivalent access to the", +" Corresponding Source in the same way through the same place at no", +" further charge. You need not require recipients to copy the", +" Corresponding Source along with the object code. If the place to", +" copy the object code is a network server, the Corresponding Source", +" may be on a different server (operated by you or a third party)", +" that supports equivalent copying facilities, provided you maintain", +" clear directions next to the object code saying where to find the", +" Corresponding Source. Regardless of what server hosts the", +" Corresponding Source, you remain obligated to ensure that it is", +" available for as long as needed to satisfy these requirements.", +"", +" e) Convey the object code using peer-to-peer transmission, provided", +" you inform other peers where the object code and Corresponding", +" Source of the work are being offered to the general public at no", +" charge under subsection 6d.", +"", +" A separable portion of the object code, whose source code is excluded", +"from the Corresponding Source as a System Library, need not be", +"included in conveying the object code work.", +"", +" A \"User Product\" is either (1) a \"consumer product\", which means any", +"tangible personal property which is normally used for personal, family,", +"or household purposes, or (2) anything designed or sold for incorporation", +"into a dwelling. In determining whether a product is a consumer product,", +"doubtful cases shall be resolved in favor of coverage. For a particular", +"product received by a particular user, \"normally used\" refers to a", +"typical or common use of that class of product, regardless of the status", +"of the particular user or of the way in which the particular user", +"actually uses, or expects or is expected to use, the product. A product", +"is a consumer product regardless of whether the product has substantial", +"commercial, industrial or non-consumer uses, unless such uses represent", +"the only significant mode of use of the product.", +"", +" \"Installation Information\" for a User Product means any methods,", +"procedures, authorization keys, or other information required to install", +"and execute modified versions of a covered work in that User Product from", +"a modified version of its Corresponding Source. The information must", +"suffice to ensure that the continued functioning of the modified object", +"code is in no case prevented or interfered with solely because", +"modification has been made.", +"", +" If you convey an object code work under this section in, or with, or", +"specifically for use in, a User Product, and the conveying occurs as", +"part of a transaction in which the right of possession and use of the", +"User Product is transferred to the recipient in perpetuity or for a", +"fixed term (regardless of how the transaction is characterized), the", +"Corresponding Source conveyed under this section must be accompanied", +"by the Installation Information. But this requirement does not apply", +"if neither you nor any third party retains the ability to install", +"modified object code on the User Product (for example, the work has", +"been installed in ROM).", +"", +" The requirement to provide Installation Information does not include a", +"requirement to continue to provide support service, warranty, or updates", +"for a work that has been modified or installed by the recipient, or for", +"the User Product in which it has been modified or installed. Access to a", +"network may be denied when the modification itself materially and", +"adversely affects the operation of the network or violates the rules and", +"protocols for communication across the network.", +"", +" Corresponding Source conveyed, and Installation Information provided,", +"in accord with this section must be in a format that is publicly", +"documented (and with an implementation available to the public in", +"source code form), and must require no special password or key for", +"unpacking, reading or copying.", +"", +" 7. Additional Terms.", +"", +" \"Additional permissions\" are terms that supplement the terms of this", +"License by making exceptions from one or more of its conditions.", +"Additional permissions that are applicable to the entire Program shall", +"be treated as though they were included in this License, to the extent", +"that they are valid under applicable law. If additional permissions", +"apply only to part of the Program, that part may be used separately", +"under those permissions, but the entire Program remains governed by", +"this License without regard to the additional permissions.", +"", +" When you convey a copy of a covered work, you may at your option", +"remove any additional permissions from that copy, or from any part of", +"it. (Additional permissions may be written to require their own", +"removal in certain cases when you modify the work.) You may place", +"additional permissions on material, added by you to a covered work,", +"for which you have or can give appropriate copyright permission.", +"", +" Notwithstanding any other provision of this License, for material you", +"add to a covered work, you may (if authorized by the copyright holders of", +"that material) supplement the terms of this License with terms:", +"", +" a) Disclaiming warranty or limiting liability differently from the", +" terms of sections 15 and 16 of this License; or", +"", +" b) Requiring preservation of specified reasonable legal notices or", +" author attributions in that material or in the Appropriate Legal", +" Notices displayed by works containing it; or", +"", +" c) Prohibiting misrepresentation of the origin of that material, or", +" requiring that modified versions of such material be marked in", +" reasonable ways as different from the original version; or", +"", +" d) Limiting the use for publicity purposes of names of licensors or", +" authors of the material; or", +"", +" e) Declining to grant rights under trademark law for use of some", +" trade names, trademarks, or service marks; or", +"", +" f) Requiring indemnification of licensors and authors of that", +" material by anyone who conveys the material (or modified versions of", +" it) with contractual assumptions of liability to the recipient, for", +" any liability that these contractual assumptions directly impose on", +" those licensors and authors.", +"", +" All other non-permissive additional terms are considered \"further", +"restrictions\" within the meaning of section 10. If the Program as you", +"received it, or any part of it, contains a notice stating that it is", +"governed by this License along with a term that is a further", +"restriction, you may remove that term. If a license document contains", +"a further restriction but permits relicensing or conveying under this", +"License, you may add to a covered work material governed by the terms", +"of that license document, provided that the further restriction does", +"not survive such relicensing or conveying.", +"", +" If you add terms to a covered work in accord with this section, you", +"must place, in the relevant source files, a statement of the", +"additional terms that apply to those files, or a notice indicating", +"where to find the applicable terms.", +"", +" Additional terms, permissive or non-permissive, may be stated in the", +"form of a separately written license, or stated as exceptions;", +"the above requirements apply either way.", +"", +" 8. Termination.", +"", +" You may not propagate or modify a covered work except as expressly", +"provided under this License. Any attempt otherwise to propagate or", +"modify it is void, and will automatically terminate your rights under", +"this License (including any patent licenses granted under the third", +"paragraph of section 11).", +"", +" However, if you cease all violation of this License, then your", +"license from a particular copyright holder is reinstated (a)", +"provisionally, unless and until the copyright holder explicitly and", +"finally terminates your license, and (b) permanently, if the copyright", +"holder fails to notify you of the violation by some reasonable means", +"prior to 60 days after the cessation.", +"", +" Moreover, your license from a particular copyright holder is", +"reinstated permanently if the copyright holder notifies you of the", +"violation by some reasonable means, this is the first time you have", +"received notice of violation of this License (for any work) from that", +"copyright holder, and you cure the violation prior to 30 days after", +"your receipt of the notice.", +"", +" Termination of your rights under this section does not terminate the", +"licenses of parties who have received copies or rights from you under", +"this License. If your rights have been terminated and not permanently", +"reinstated, you do not qualify to receive new licenses for the same", +"material under section 10.", +"", +" 9. Acceptance Not Required for Having Copies.", +"", +" You are not required to accept this License in order to receive or", +"run a copy of the Program. Ancillary propagation of a covered work", +"occurring solely as a consequence of using peer-to-peer transmission", +"to receive a copy likewise does not require acceptance. However,", +"nothing other than this License grants you permission to propagate or", +"modify any covered work. These actions infringe copyright if you do", +"not accept this License. Therefore, by modifying or propagating a", +"covered work, you indicate your acceptance of this License to do so.", +"", +" 10. Automatic Licensing of Downstream Recipients.", +"", +" Each time you convey a covered work, the recipient automatically", +"receives a license from the original licensors, to run, modify and", +"propagate that work, subject to this License. You are not responsible", +"for enforcing compliance by third parties with this License.", +"", +" An \"entity transaction\" is a transaction transferring control of an", +"organization, or substantially all assets of one, or subdividing an", +"organization, or merging organizations. If propagation of a covered", +"work results from an entity transaction, each party to that", +"transaction who receives a copy of the work also receives whatever", +"licenses to the work the party's predecessor in interest had or could", +"give under the previous paragraph, plus a right to possession of the", +"Corresponding Source of the work from the predecessor in interest, if", +"the predecessor has it or can get it with reasonable efforts.", +"", +" You may not impose any further restrictions on the exercise of the", +"rights granted or affirmed under this License. For example, you may", +"not impose a license fee, royalty, or other charge for exercise of", +"rights granted under this License, and you may not initiate litigation", +"(including a cross-claim or counterclaim in a lawsuit) alleging that", +"any patent claim is infringed by making, using, selling, offering for", +"sale, or importing the Program or any portion of it.", +"", +" 11. Patents.", +"", +" A \"contributor\" is a copyright holder who authorizes use under this", +"License of the Program or a work on which the Program is based. The", +"work thus licensed is called the contributor's \"contributor version\".", +"", +" A contributor's \"essential patent claims\" are all patent claims", +"owned or controlled by the contributor, whether already acquired or", +"hereafter acquired, that would be infringed by some manner, permitted", +"by this License, of making, using, or selling its contributor version,", +"but do not include claims that would be infringed only as a", +"consequence of further modification of the contributor version. For", +"purposes of this definition, \"control\" includes the right to grant", +"patent sublicenses in a manner consistent with the requirements of", +"this License.", +"", +" Each contributor grants you a non-exclusive, worldwide, royalty-free", +"patent license under the contributor's essential patent claims, to", +"make, use, sell, offer for sale, import and otherwise run, modify and", +"propagate the contents of its contributor version.", +"", +" In the following three paragraphs, a \"patent license\" is any express", +"agreement or commitment, however denominated, not to enforce a patent", +"(such as an express permission to practice a patent or covenant not to", +"sue for patent infringement). To \"grant\" such a patent license to a", +"party means to make such an agreement or commitment not to enforce a", +"patent against the party.", +"", +" If you convey a covered work, knowingly relying on a patent license,", +"and the Corresponding Source of the work is not available for anyone", +"to copy, free of charge and under the terms of this License, through a", +"publicly available network server or other readily accessible means,", +"then you must either (1) cause the Corresponding Source to be so", +"available, or (2) arrange to deprive yourself of the benefit of the", +"patent license for this particular work, or (3) arrange, in a manner", +"consistent with the requirements of this License, to extend the patent", +"license to downstream recipients. \"Knowingly relying\" means you have", +"actual knowledge that, but for the patent license, your conveying the", +"covered work in a country, or your recipient's use of the covered work", +"in a country, would infringe one or more identifiable patents in that", +"country that you have reason to believe are valid.", +"", +" If, pursuant to or in connection with a single transaction or", +"arrangement, you convey, or propagate by procuring conveyance of, a", +"covered work, and grant a patent license to some of the parties", +"receiving the covered work authorizing them to use, propagate, modify", +"or convey a specific copy of the covered work, then the patent license", +"you grant is automatically extended to all recipients of the covered", +"work and works based on it.", +"", +" A patent license is \"discriminatory\" if it does not include within", +"the scope of its coverage, prohibits the exercise of, or is", +"conditioned on the non-exercise of one or more of the rights that are", +"specifically granted under this License. You may not convey a covered", +"work if you are a party to an arrangement with a third party that is", +"in the business of distributing software, under which you make payment", +"to the third party based on the extent of your activity of conveying", +"the work, and under which the third party grants, to any of the", +"parties who would receive the covered work from you, a discriminatory", +"patent license (a) in connection with copies of the covered work", +"conveyed by you (or copies made from those copies), or (b) primarily", +"for and in connection with specific products or compilations that", +"contain the covered work, unless you entered into that arrangement,", +"or that patent license was granted, prior to 28 March 2007.", +"", +" Nothing in this License shall be construed as excluding or limiting", +"any implied license or other defenses to infringement that may", +"otherwise be available to you under applicable patent law.", +"", +" 12. No Surrender of Others' Freedom.", +"", +" If conditions are imposed on you (whether by court order, agreement or", +"otherwise) that contradict the conditions of this License, they do not", +"excuse you from the conditions of this License. If you cannot convey a", +"covered work so as to satisfy simultaneously your obligations under this", +"License and any other pertinent obligations, then as a consequence you may", +"not convey it at all. For example, if you agree to terms that obligate you", +"to collect a royalty for further conveying from those to whom you convey", +"the Program, the only way you could satisfy both those terms and this", +"License would be to refrain entirely from conveying the Program.", +"", +" 13. Use with the GNU Affero General Public License.", +"", +" Notwithstanding any other provision of this License, you have", +"permission to link or combine any covered work with a work licensed", +"under version 3 of the GNU Affero General Public License into a single", +"combined work, and to convey the resulting work. The terms of this", +"License will continue to apply to the part which is the covered work,", +"but the special requirements of the GNU Affero General Public License,", +"section 13, concerning interaction through a network will apply to the", +"combination as such.", +"", +" 14. Revised Versions of this License.", +"", +" The Free Software Foundation may publish revised and/or new versions of", +"the GNU General Public License from time to time. Such new versions will", +"be similar in spirit to the present version, but may differ in detail to", +"address new problems or concerns.", +"", +" Each version is given a distinguishing version number. If the", +"Program specifies that a certain numbered version of the GNU General", +"Public License \"or any later version\" applies to it, you have the", +"option of following the terms and conditions either of that numbered", +"version or of any later version published by the Free Software", +"Foundation. If the Program does not specify a version number of the", +"GNU General Public License, you may choose any version ever published", +"by the Free Software Foundation.", +"", +" If the Program specifies that a proxy can decide which future", +"versions of the GNU General Public License can be used, that proxy's", +"public statement of acceptance of a version permanently authorizes you", +"to choose that version for the Program.", +"", +" Later license versions may give you additional or different", +"permissions. However, no additional obligations are imposed on any", +"author or copyright holder as a result of your choosing to follow a", +"later version.", +"", +" 15. Disclaimer of Warranty.", +"", +" THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY", +"APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT", +"HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY", +"OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,", +"THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR", +"PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM", +"IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF", +"ALL NECESSARY SERVICING, REPAIR OR CORRECTION.", +"", +" 16. Limitation of Liability.", +"", +" IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING", +"WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS", +"THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY", +"GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE", +"USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF", +"DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD", +"PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),", +"EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF", +"SUCH DAMAGES.", +"", +" 17. Interpretation of Sections 15 and 16.", +"", +" If the disclaimer of warranty and limitation of liability provided", +"above cannot be given local legal effect according to their terms,", +"reviewing courts shall apply local law that most closely approximates", +"an absolute waiver of all civil liability in connection with the", +"Program, unless a warranty or assumption of liability accompanies a", +"copy of the Program in return for a fee.", +"", +" END OF TERMS AND CONDITIONS", +}; + #define README_CRASH_VERSION "README_CRASH_VERSION" #define README_GNU_GDB_VERSION "README_GNU_GDB_VERSION" #define README_DATE "README_DATE" --- crash-4.1.0/task.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/task.c 2009-10-27 11:48:13.000000000 -0400 @@ -5146,7 +5146,7 @@ error(INFO, "line numbers are not available\n"); fd->flags &= ~FOREACH_l_FLAG; } -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) if ((fd->flags & FOREACH_g_FLAG)) error(FATAL, "bt -g option is not supported when issued from foreach\n"); @@ -5267,7 +5267,7 @@ if (fd->flags & FOREACH_e_FLAG) bt->flags |= BT_EFRAME_SEARCH; if (fd->flags & FOREACH_g_FLAG) -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) error(FATAL, "-g option is not supported with this version of gdb\n"); #else --- crash-4.1.0/kernel.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/kernel.c 2009-11-11 15:02:17.000000000 -0500 @@ -855,7 +855,7 @@ if (CRASHDEBUG(1)) { fprintf(fp, "\ngdb> ptype spinlock_t\n"); sprintf(buf, "ptype spinlock_t"); - gdb_pass_through(buf, NULL, 0); + gdb_pass_through(buf, NULL, GNU_RETURN_ON_ERROR); } non_matching_kernel(); } @@ -1184,7 +1184,7 @@ if (!user_mode && !(sp = value_search(req->addr, &offset))) { error(WARNING, - "%x: no associated kernel symbol found\n", + "%lx: no associated kernel symbol found\n", req->addr); unfiltered = TRUE; } @@ -1216,7 +1216,7 @@ if (unfiltered) { sprintf(buf1, "x/%ldi 0x%lx", req->count ? req->count : 1, req->addr); - gdb_pass_through(buf1, NULL, 0); + gdb_pass_through(buf1, NULL, GNU_RETURN_ON_ERROR); return; } @@ -1228,12 +1228,12 @@ sprintf(buf1, "x/%ldi 0x%lx", req->count ? req->count : 1, req->addr); pc->curcmd_flags |= MEMTYPE_UVADDR; - gdb_pass_through(buf1, NULL, 0); + gdb_pass_through(buf1, NULL, GNU_RETURN_ON_ERROR); return; } do_load_module_filter = module_symbol(req->addr, NULL, NULL, - NULL, output_radix); + NULL, *gdb_output_radix); if (!reverse) { req->command = GNU_RESOLVE_TEXT_ADDR; @@ -1822,7 +1822,7 @@ break; case 'g': -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) bt->flags |= BT_THREAD_GROUP; #else bt->flags |= BT_USE_GDB; @@ -4047,7 +4047,7 @@ for (i = 0, sct = sys_call_table; i < NR_syscalls; i++, sct++) { if (!(scp = value_symbol(*sct))) { if (CRASHDEBUG(1)) { - fprintf(fp, (output_radix == 16) ? + fprintf(fp, (*gdb_output_radix == 16) ? "%3x " : "%3d ", i); fprintf(fp, "invalid sys_call_table entry: %lx (%s)\n", @@ -4057,7 +4057,7 @@ continue; } - fprintf(fp, (output_radix == 16) ? "%3x " : "%3d ", i); + fprintf(fp, (*gdb_output_radix == 16) ? "%3x " : "%3d ", i); if (sys_ni_syscall && *sct == sys_ni_syscall) fprintf(fp, "%-26s ", "sys_ni_syscall"); else @@ -4097,7 +4097,7 @@ hdr_printed = cnt; if ((number = IS_A_NUMBER(spec))) - sprintf(buf3, (output_radix == 16) ? "%lx" : "%ld", + sprintf(buf3, (*gdb_output_radix == 16) ? "%lx" : "%ld", stol(spec, FAULT_ON_ERROR, NULL)); while (fgets(buf1, BUFSIZE, pc->tmpfile)) { --- crash-4.1.0/gdb_interface.c 2009-11-20 14:38:03.000000000 -0500 +++ crash-4.1.1/gdb_interface.c 2009-11-11 15:02:17.000000000 -0500 @@ -21,6 +21,18 @@ static int is_restricted_command(char *, ulong); int get_frame_offset(ulong); +int *gdb_output_format; +unsigned int *gdb_print_max; +int *gdb_prettyprint_structs; +int *gdb_prettyprint_arrays; +int *gdb_repeat_count_threshold; +int *gdb_stop_print_at_null; +unsigned int *gdb_output_radix; + +#ifdef GDB_7_0 +ulong gdb_user_print_option_address(char *); +#endif + /* * Called from main() this routine sets up the call-back hook such that * gdb's main() routine -- renamed gdb_main() -- will call back to @@ -57,19 +69,22 @@ } optind = 0; +#if defined(GDB_7_0) + deprecated_command_loop_hook = main_loop; +#else command_loop_hook = main_loop; - -#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1) +#endif +#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) gdb_main_entry(argc, argv); #else gdb_main(argc, argv); #endif } -#if defined(GDB_6_0) || defined(GDB_6_1) /* * Update any hooks that gdb has set. */ +#if defined(GDB_6_0) || defined(GDB_6_1) void update_gdb_hooks(void) { @@ -78,6 +93,14 @@ target_new_objfile_hook = NULL; } #endif +#if defined(GDB_7_0) +void +update_gdb_hooks(void) +{ + deprecated_command_loop_hook = pc->flags & VERSION_QUERY ? + exit_after_gdb_info : main_loop; +} +#endif void gdb_readnow_warning(void) @@ -102,9 +125,13 @@ display_gdb_banner(void) { optind = 0; +#if defined(GDB_7_0) + deprecated_command_loop_hook = exit_after_gdb_info; +#else command_loop_hook = exit_after_gdb_info; +#endif args[0] = "gdb"; -#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) gdb_main_entry(1, args); #else gdb_main(1, args); @@ -155,29 +182,56 @@ SIGACTION(SIGSEGV, restart, &pc->sigaction, NULL); /* + * Set up pointers to gdb variables. + */ +#if defined(GDB_7_0) + gdb_output_format = (int *) + gdb_user_print_option_address("output_format"); + gdb_print_max = (unsigned int *) + gdb_user_print_option_address("print_max"); + gdb_prettyprint_structs = (int *) + gdb_user_print_option_address("prettyprint_structs"); + gdb_prettyprint_arrays = (int *) + gdb_user_print_option_address("prettyprint_arrays"); + gdb_repeat_count_threshold = (int *) + gdb_user_print_option_address("repeat_count_threshold"); + gdb_stop_print_at_null = (int *) + gdb_user_print_option_address("stop_print_at_null"); + gdb_output_radix = (unsigned int *) + gdb_user_print_option_address("output_radix"); +#else + gdb_output_format = &output_format; + gdb_print_max = &print_max; + gdb_prettyprint_structs = &prettyprint_structs; + gdb_prettyprint_arrays = &prettyprint_arrays; + gdb_repeat_count_threshold = &repeat_count_threshold; + gdb_stop_print_at_null = &stop_print_at_null; + gdb_output_radix = &output_radix; +#endif + /* * If the output radix is set in an .rc file, then pc->output_radix * will be non-zero. Otherwise use the gdb default. */ if (pc->output_radix) { - output_radix = pc->output_radix; - output_format = (output_radix == 10) ? 0 : 'x'; + *gdb_output_radix = pc->output_radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } - switch (output_radix) + switch (*gdb_output_radix) { case 10: case 16: - pc->output_radix = output_radix; + pc->output_radix = *gdb_output_radix; break; default: - pc->output_radix = output_radix = 10; - output_format = 0; + pc->output_radix = *gdb_output_radix = 10; + *gdb_output_format = 0; } - prettyprint_structs = 1; - repeat_count_threshold = 0x7fffffff; - print_max = 256; -#if !defined(GDB_6_0) && !defined(GDB_6_1) + *gdb_prettyprint_structs = 1; + *gdb_repeat_count_threshold = 0x7fffffff; + *gdb_print_max = 256; +#if !defined(GDB_6_0) && !defined(GDB_6_1) && !defined(GDB_7_0) gdb_disassemble_from_exec = 0; #endif @@ -371,14 +425,14 @@ void dump_gdb_data(void) { - fprintf(fp, " prettyprint_arrays: %d\n", prettyprint_arrays); - fprintf(fp, " prettyprint_structs: %d\n", prettyprint_structs); - fprintf(fp, "repeat_count_threshold: %x\n", repeat_count_threshold); - fprintf(fp, " stop_print_at_null: %d\n", stop_print_at_null); - fprintf(fp, " print_max: %d\n", print_max); - fprintf(fp, " output_radix: %d\n", output_radix); + fprintf(fp, " prettyprint_arrays: %d\n", *gdb_prettyprint_arrays); + fprintf(fp, " prettyprint_structs: %d\n", *gdb_prettyprint_structs); + fprintf(fp, "repeat_count_threshold: %x\n", *gdb_repeat_count_threshold); + fprintf(fp, " stop_print_at_null: %d\n", *gdb_stop_print_at_null); + fprintf(fp, " print_max: %d\n", *gdb_print_max); + fprintf(fp, " output_radix: %d\n", *gdb_output_radix); fprintf(fp, " output_format: "); - switch (output_format) + switch (*gdb_output_format) { case 'x': fprintf(fp, "hex\n"); break; @@ -558,12 +612,12 @@ return; if (pc->output_radix) { - output_radix = pc->output_radix; - output_format = (output_radix == 10) ? 0 : 'x'; + *gdb_output_radix = pc->output_radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } - prettyprint_structs = 1; /* these may piss somebody off... */ - repeat_count_threshold = 0x7fffffff; + *gdb_prettyprint_structs = 1; /* these may piss somebody off... */ + *gdb_repeat_count_threshold = 0x7fffffff; error_hook = NULL; @@ -718,7 +772,8 @@ */ if (!is_restricted_command(args[1], FAULT_ON_ERROR)) { concat_args(buf, 1, 0); - gdb_pass_through(buf, NULL, 0); + if (!gdb_pass_through(buf, NULL, GNU_RETURN_ON_ERROR)) + error(INFO, "gdb request failed: %s\n", buf); } } @@ -841,6 +896,19 @@ return (pc->cur_req && (pc->cur_req->debug >= dval)); } +#ifdef GDB_7_0 +ulong +gdb_user_print_option_address(char *name) +{ + struct gnu_request request; + + request.command = GNU_USER_PRINT_OPTION; + request.name = name; + gdb_command_funnel(&request); + return request.addr; +} +#endif + #ifndef ALPHA /* * Stub routine needed for resolution by non-alpha, modified gdb code. --- crash-4.1.0/configure.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/configure.c 2009-11-20 11:33:19.000000000 -0500 @@ -18,18 +18,17 @@ /* * define, clear and undef dynamically update the top-level Makefile: * - * -b define: TARGET, GDB, GDB_FILES, GDB_OFILES and TARGET_CFLAGS + * -b define: TARGET, GDB, GDB_FILES, GDB_OFILES, GDB_PATCH_FILES, TARGET_CFLAGS and GPL_FILES * create: build_data.c * - * -d define: TARGET, GDB, GDB_FILES, GDB_OFILES, TARGET_CFLAGS, and + * -d define: TARGET, GDB, GDB_FILES, GDB_OFILES, GDB_PATCH_FILES, TARGET_CFLAGS, and * PROGRAM (for daemon) * create: build_data.c * - * -u clear: TARGET, GDB, GDB_FILES, GDB_OFILES, VERSION and TARGET_CFLAGS + * -u clear: TARGET, GDB, GDB_FILES, GDB_OFILES, VERSION, GDB_PATCH_FILES, TARGET_CFLAGS and GPL_FILES * undef: WARNING_ERROR, WARNING_OPTIONS * - * -r define: GDB_FILES, VERSION - * verify that no .rpmmacro file exists for the running shell + * -r define: GDB_FILES, VERSION, GDB_PATCH_FILES GPL_FILES * * -w define: WARNING_OPTIONS * undef: WARNING_ERROR @@ -54,8 +53,9 @@ #include #include -void build_configure(void); -void release_configure(char *); +struct supported_gdb_version; +void build_configure(struct supported_gdb_version *); +void release_configure(char *, struct supported_gdb_version *); void make_rh_rpm_package(char *, int); void unconfigure(void); void set_warnings(int); @@ -73,12 +73,11 @@ int file_exists(char *); int count_chars(char *, char); void make_build_data(char *); -void make_spec_file(void); -void gdb_configure(void); +void gdb_configure(struct supported_gdb_version *); int parse_line(char *, char **); -int setup_gdb_defaults(void); -struct supported_gdb_version; -int store_gdb_defaults(struct supported_gdb_version *); +struct supported_gdb_version *setup_gdb_defaults(void); +struct supported_gdb_version *store_gdb_defaults(struct supported_gdb_version *); +void make_spec_file(struct supported_gdb_version *); #define TRUE 1 #define FALSE 0 @@ -129,6 +128,8 @@ #define GDB_5_3 0 #define GDB_6_0 1 #define GDB_6_1 2 +#define GDB_7_0 3 +#define SUPPORTED_GDB_VERSIONS (GDB_7_0 + 1) int default_gdb = GDB_6_1; @@ -137,67 +138,48 @@ char *GDB_VERSION_IN; char *GDB_FILES; char *GDB_OFILES; -} supported_gdb_versions[3] = { + char *GDB_PATCH_FILES; + char *GDB_FLAGS; + char *GPL; +} supported_gdb_versions[SUPPORTED_GDB_VERSIONS] = { { "GDB=gdb-5.3post-0.20021129.36rh", "Red Hat Linux (5.3post-0.20021129.36rh)", "GDB_FILES=${GDB_5.3post-0.20021129.36rh_FILES}", - "GDB_OFILES=${GDB_5.3post-0.20021129.36rh_OFILES}" + "GDB_OFILES=${GDB_5.3post-0.20021129.36rh_OFILES}", + "GDB_PATCH_FILES=", + "GDB_FLAGS=-DGDB_5_3", + "GPLv2" }, { "GDB=gdb-6.0", "6.0", "GDB_FILES=${GDB_6.0_FILES}", - "GDB_OFILES=${GDB_6.0_OFILES}" + "GDB_OFILES=${GDB_6.0_OFILES}", + "GDB_PATCH_FILES=", + "GDB_FLAGS=-DGDB_6_0", + "GPLv2" }, { "GDB=gdb-6.1", "6.1", "GDB_FILES=${GDB_6.1_FILES}", - "GDB_OFILES=${GDB_6.1_OFILES}" + "GDB_OFILES=${GDB_6.1_OFILES}", + "GDB_PATCH_FILES=gdb-6.1.patch", + "GDB_FLAGS=-DGDB_6_1", + "GPLv2" + }, + { + "GDB=gdb-7.0", + "7.0", + "GDB_FILES=${GDB_7.0_FILES}", + "GDB_OFILES=${GDB_7.0_OFILES}", + "GDB_PATCH_FILES=gdb-7.0.patch", + "GDB_FLAGS=-DGDB_7_0", + "GPLv3" }, }; - -char *GDB_X86; -char *GDB_ALPHA; -char *GDB_PPC; -char *GDB_IA64; -char *GDB_S390; -char *GDB_S390X; -char *GDB_PPC64; -char *GDB_X86_64; - -/* - * copy of gdb-x.x/gdb/version.in file - */ -char *GDB_X86_VERSION_IN; -char *GDB_ALPHA_VERSION_IN; -char *GDB_PPC_VERSION_IN; -char *GDB_IA64_VERSION_IN; -char *GDB_S390_VERSION_IN; -char *GDB_S390X_VERSION_IN; -char *GDB_PPC64_VERSION_IN; -char *GDB_X86_64_VERSION_IN; - -char *GDB_FILES_X86; -char *GDB_FILES_ALPHA; -char *GDB_FILES_PPC; -char *GDB_FILES_IA64; -char *GDB_FILES_S390; -char *GDB_FILES_S390X; -char *GDB_FILES_PPC64; -char *GDB_FILES_X86_64; - -char *GDB_OFILES_X86; -char *GDB_OFILES_ALPHA; -char *GDB_OFILES_PPC; -char *GDB_OFILES_IA64; -char *GDB_OFILES_S390; -char *GDB_OFILES_S390X; -char *GDB_OFILES_PPC64; -char *GDB_OFILES_X86_64; - #define DAEMON 0x1 #define QUIET 0x2 @@ -209,7 +191,6 @@ int flags; char program[MAXSTRLEN]; char gdb_version[MAXSTRLEN]; - char gdb_version_in[MAXSTRLEN]; char release[MAXSTRLEN]; struct stat statbuf; } target_data = { 0 }; @@ -218,8 +199,9 @@ main(int argc, char **argv) { int c; + struct supported_gdb_version *sp; - setup_gdb_defaults(); + sp = setup_gdb_defaults(); while ((c = getopt(argc, argv, "gsqnWwubdr:p:P:")) > 0) { switch (c) { @@ -232,10 +214,10 @@ case 'd': target_data.flags |= DAEMON; case 'b': - build_configure(); + build_configure(sp); break; case 'r': - release_configure(optarg); + release_configure(optarg, sp); break; case 'p': make_rh_rpm_package(optarg, 0); @@ -249,10 +231,10 @@ set_warnings(c); break; case 's': - make_spec_file(); + make_spec_file(sp); break; case 'g': - gdb_configure(); + gdb_configure(sp); break; } } @@ -410,87 +392,50 @@ } void -build_configure(void) +build_configure(struct supported_gdb_version *sp) { FILE *fp1, *fp2; char buf[512]; char *target; char *target_CFLAGS; - char *gdb_version; - char *gdb_version_in; - char *gdb_files; - char *gdb_ofiles; get_current_configuration(); target = target_CFLAGS = NULL; - gdb_version = gdb_version_in = gdb_files = gdb_ofiles = NULL; switch (target_data.target) { case X86: target = TARGET_X86; target_CFLAGS = TARGET_CFLAGS_X86; - gdb_version = GDB_X86; - gdb_version_in = GDB_X86_VERSION_IN; - gdb_files = GDB_FILES_X86; - gdb_ofiles = GDB_OFILES_X86; break; case ALPHA: target = TARGET_ALPHA; target_CFLAGS = TARGET_CFLAGS_ALPHA; - gdb_version = GDB_ALPHA; - gdb_version_in = GDB_ALPHA_VERSION_IN; - gdb_files = GDB_FILES_ALPHA; - gdb_ofiles = GDB_OFILES_ALPHA; break; case PPC: target = TARGET_PPC; target_CFLAGS = TARGET_CFLAGS_PPC; - gdb_version = GDB_PPC; - gdb_version_in = GDB_PPC_VERSION_IN; - gdb_files = GDB_FILES_PPC; - gdb_ofiles = GDB_OFILES_PPC; break; case IA64: target = TARGET_IA64; target_CFLAGS = TARGET_CFLAGS_IA64; - gdb_version = GDB_IA64; - gdb_version_in = GDB_IA64_VERSION_IN; - gdb_files = GDB_FILES_IA64; - gdb_ofiles = GDB_OFILES_IA64; break; case S390: target = TARGET_S390; target_CFLAGS = TARGET_CFLAGS_S390; - gdb_version = GDB_S390; - gdb_version_in = GDB_S390_VERSION_IN; - gdb_files = GDB_FILES_S390; - gdb_ofiles = GDB_OFILES_S390; break; case S390X: target = TARGET_S390X; target_CFLAGS = TARGET_CFLAGS_S390X; - gdb_version = GDB_S390X; - gdb_version_in = GDB_S390X_VERSION_IN; - gdb_files = GDB_FILES_S390X; - gdb_ofiles = GDB_OFILES_S390X; break; case PPC64: target = TARGET_PPC64; target_CFLAGS = TARGET_CFLAGS_PPC64; - gdb_version = GDB_PPC64; - gdb_version_in = GDB_PPC64_VERSION_IN; - gdb_files = GDB_FILES_PPC64; - gdb_ofiles = GDB_OFILES_PPC64; break; case X86_64: target = TARGET_X86_64; target_CFLAGS = TARGET_CFLAGS_X86_64; - gdb_version = GDB_X86_64; - gdb_version_in = GDB_X86_64_VERSION_IN; - gdb_files = GDB_FILES_X86_64; - gdb_ofiles = GDB_OFILES_X86_64; break; } @@ -503,15 +448,19 @@ strlen("TARGET_CFLAGS=")) == 0) fprintf(fp2, "%s\n", target_CFLAGS); else if (strncmp(buf, "GDB_FILES=",strlen("GDB_FILES=")) == 0) - fprintf(fp2, "%s\n", gdb_files); + fprintf(fp2, "%s\n", sp->GDB_FILES); else if (strncmp(buf, "GDB_OFILES=",strlen("GDB_OFILES=")) == 0) - fprintf(fp2, "%s\n", gdb_ofiles); + fprintf(fp2, "%s\n", sp->GDB_OFILES); + else if (strncmp(buf, "GDB_PATCH_FILES=",strlen("GDB_PATCH_FILES=")) == 0) + fprintf(fp2, "%s\n", sp->GDB_PATCH_FILES); + else if (strncmp(buf, "GDB_FLAGS=",strlen("GDB_FLAGS=")) == 0) + fprintf(fp2, "%s\n", sp->GDB_FLAGS); + else if (strncmp(buf, "GPL_FILES=", strlen("GPL_FILES=")) == 0) + fprintf(fp2, "GPL_FILES=%s\n", strcmp(sp->GPL, "GPLv2") == 0 ? + "COPYING" : "COPYING3"); else if (strncmp(buf, "GDB=", strlen("GDB=")) == 0) { - fprintf(fp2, "%s\n", gdb_version); - sprintf(target_data.gdb_version, "%s", &gdb_version[4]); - bzero(target_data.gdb_version_in, MAXSTRLEN); - strncpy(target_data.gdb_version_in, gdb_version_in, - MIN(strlen(gdb_version_in), MAXSTRLEN-1)); + fprintf(fp2, "%s\n", sp->GDB); + sprintf(target_data.gdb_version, "%s", &sp->GDB[4]); } else fprintf(fp2, "%s", buf); @@ -523,7 +472,7 @@ } void -release_configure(char *gdb_version) +release_configure(char *gdb_version, struct supported_gdb_version *sp) { FILE *fp1, *fp2; int found; @@ -551,6 +500,11 @@ else if (strncmp(buf, "VERSION=", strlen("VERSION=")) == 0) fprintf(fp2, "VERSION=%s\n", target_data.release); + else if (strncmp(buf, "GDB_PATCH_FILES=", strlen("GDB_PATCH_FILES=")) == 0) + fprintf(fp2, "%s\n", sp->GDB_PATCH_FILES); + else if (strncmp(buf, "GPL_FILES=", strlen("GPL_FILES=")) == 0) + fprintf(fp2, "GPL_FILES=%s\n", strcmp(sp->GPL, "GPLv2") == 0 ? + "COPYING" : "COPYING3"); else fprintf(fp2, "%s", buf); @@ -631,61 +585,18 @@ } void -gdb_configure(void) +gdb_configure(struct supported_gdb_version *sp) { FILE *fp1, *fp2; char buf[512]; - char *gdb_version; get_current_configuration(); - gdb_version = NULL; - - switch (target_data.target) - { - case X86: - gdb_version = GDB_X86; - break; - case ALPHA: - gdb_version = GDB_ALPHA; - break; - case PPC: - gdb_version = GDB_PPC; - break; - case IA64: - gdb_version = GDB_IA64; - break; - case S390: - gdb_version = GDB_S390; - break; - case S390X: - gdb_version = GDB_S390X; - break; - case PPC64: - gdb_version = GDB_PPC64; - break; - case X86_64: - gdb_version = GDB_X86_64; - break; - } - - if ((strcmp(gdb_version, GDB_X86) != 0) && - (strcmp(gdb_version, GDB_ALPHA) != 0) && - (strcmp(gdb_version, GDB_PPC) != 0) && - (strcmp(gdb_version, GDB_IA64) != 0) && - (strcmp(gdb_version, GDB_S390) != 0) && - (strcmp(gdb_version, GDB_S390X) != 0) && - (strcmp(gdb_version, GDB_PPC64) != 0) && - (strcmp(gdb_version, GDB_X86_64) != 0)) { - fprintf(stderr, "divergent gdb versions\n"); - return; - } - makefile_setup(&fp1, &fp2); while (fgets(buf, 512, fp1)) { if (strncmp(buf, "GDB=", strlen("GDB=")) == 0) - fprintf(fp2, "%s\n", gdb_version); + fprintf(fp2, "%s\n", sp->GDB); else fprintf(fp2, "%s", buf); @@ -712,10 +623,16 @@ fprintf(fp2, "GDB_FILES=\n"); else if (strncmp(buf, "GDB_OFILES=",strlen("GDB_OFILES=")) == 0) fprintf(fp2, "GDB_OFILES=\n"); + else if (strncmp(buf, "GDB_PATCH_FILES=",strlen("GDB_PATCH_FILES=")) == 0) + fprintf(fp2, "GDB_PATCH_FILES=\n"); + else if (strncmp(buf, "GDB_FLAGS=",strlen("GDB_FLAGS=")) == 0) + fprintf(fp2, "GDB_FLAGS=\n"); else if (strncmp(buf, "GDB=", strlen("GDB=")) == 0) fprintf(fp2, "GDB=\n"); else if (strncmp(buf, "VERSION=", strlen("VERSION=")) == 0) fprintf(fp2, "VERSION=\n"); + else if (strncmp(buf, "GPL_FILES=", strlen("GPL_FILES=")) == 0) + fprintf(fp2, "GPL_FILES=\n"); else if (strncmp(buf, "WARNING_ERROR=", strlen("WARNING_ERROR=")) == 0) { shift_string_right(buf, 1); @@ -1048,7 +965,7 @@ } void -make_spec_file(void) +make_spec_file(struct supported_gdb_version *sp) { char *Version, *Release; char buf[512]; @@ -1073,7 +990,7 @@ printf("Name: %s\n", lower_case(target_data.program, buf)); printf("Version: %s\n", Version); printf("Release: %s\n", Release); - printf("License: GPLv2\n"); + printf("License: %s\n", sp->GPL); printf("Group: Development/Debuggers\n"); printf("Source: %%{name}-%%{version}.tar.gz\n"); printf("URL: http://people.redhat.com/anderson\n"); @@ -1162,44 +1079,28 @@ } /* - * Use the default gdb #defines unless there's a .gdb_config file - * containing statments for DEFAULT_GDB, DEFAULT_GDB_VERSION_IN, - * DEFAULT_GDB_FILES and DEFAULT_GDB_OFILES. + * Use the default gdb #defines unless there's a .gdb file. */ -char GDB_override[MAXSTRLEN] = { 0 }; -char GDB_VERSION_IN_override[MAXSTRLEN] = { 0 }; -char GDB_FILES_override[MAXSTRLEN] = { 0 }; -char GDB_OFILES_override[MAXSTRLEN] = { 0 }; -struct supported_gdb_version test_gdb_version = { 0 }; - -int +struct supported_gdb_version * setup_gdb_defaults(void) { FILE *fp; char inbuf[512]; char buf[512]; - char *p1, *p2; - int line, bad, cnt; - char *gdb, *gdb_version_in, *gdb_files, *gdb_ofiles; struct supported_gdb_version *sp; - gdb = gdb_version_in = gdb_files = gdb_ofiles = NULL; - bad = line = 0; - sp = NULL; - /* - * Use the default, allowing for an override in .gdb_config + * Use the default, allowing for an override in .gdb */ - if (!file_exists(".gdb_config")) + if (!file_exists(".gdb")) return store_gdb_defaults(NULL); - if ((fp = fopen(".gdb_config", "r")) == NULL) { - perror(".gdb_config"); + if ((fp = fopen(".gdb", "r")) == NULL) { + perror(".gdb"); return store_gdb_defaults(NULL); } while (fgets(inbuf, 512, fp)) { - line++; strip_linefeeds(inbuf); strip_beginning_whitespace(inbuf); @@ -1209,180 +1110,38 @@ * Simple override. */ if (strcmp(buf, "5.3") == 0) { - if (gdb || gdb_version_in || gdb_files || gdb_ofiles) { - fprintf(stderr, - ".gdb_config[line %d]: mixed supported/test configuration?\n", - line); - bad++; - break; - } fclose(fp); sp = &supported_gdb_versions[GDB_5_3]; - fprintf(stderr, ".gdb_config configuration: %s\n\n", sp->GDB_VERSION_IN); + fprintf(stderr, ".gdb configuration: %s\n\n", sp->GDB_VERSION_IN); return store_gdb_defaults(sp); } if (strcmp(buf, "6.0") == 0) { - if (gdb || gdb_version_in || gdb_files || gdb_ofiles) { - fprintf(stderr, - ".gdb_config[line %d]: mixed supported/test configuration?\n", - line); - bad++; - break; - } fclose(fp); sp = &supported_gdb_versions[GDB_6_0]; - fprintf(stderr, ".gdb_config configuration: %s\n\n", sp->GDB_VERSION_IN); + fprintf(stderr, ".gdb configuration: %s\n\n", sp->GDB_VERSION_IN); return store_gdb_defaults(sp); } if (strcmp(buf, "6.1") == 0) { - if (gdb || gdb_version_in || gdb_files || gdb_ofiles) { - fprintf(stderr, - ".gdb_config[line %d]: mixed supported/test configuration?\n", - line); - bad++; - break; - } fclose(fp); - fprintf(stderr, ".gdb_config configuration: 6.1\n\n"); sp = &supported_gdb_versions[GDB_6_1]; - fprintf(stderr, ".gdb_config configuration: %s\n", sp->GDB_VERSION_IN); + fprintf(stderr, ".gdb configuration: %s\n", sp->GDB_VERSION_IN); return store_gdb_defaults(sp); } - - /* - * Test case override. - * - * This is the acceptable .gdb_config file format: - * - * GDB "GDB=gdb-6.0" - * GDB_VERSION_IN "6.0" - * GDB_FILES "GDB_FILES=${GDB_6.0_FILES}" - * GDB_OFILES "GDB_OFILES=${GDB_6.0_OFILES}" - */ - - if ((strncmp(buf, "GDB ", 4) == 0) || - (strncmp(buf, "GDB ", 4) == 0) || - (strncmp(buf, "GDB=", 4) == 0)) { - if (strlen(GDB_override)) { - fprintf(stderr, - ".gdb_config[line %d]: GDB already configured: \"%s\"\n", - line, GDB_override); - bad++; - break; - } - p1 = index(buf, '\"'); - p2 = rindex(buf, '\"'); - cnt = count_chars(buf, '\"'); - if ((cnt != 2) || !p1 || !p2 || (p1 == p2) || (p2 == (p1+1))) - goto malformed; - *p2 = '\0'; - gdb = p1+1; - if (count_chars(gdb, ' ') || count_chars(gdb, '\t')) - goto malformed; - strcpy(GDB_override, gdb); - } - else if ((strncmp(buf, "GDB_VERSION_IN ", 15) == 0) || - (strncmp(buf, "GDB_VERSION_IN ", 15) == 0) || - (strncmp(buf, "GDB_VERSION_IN=", 15) == 0)) { - if (strlen(GDB_VERSION_IN_override)) { - fprintf(stderr, - ".gdb_config[line %d]: GDB_VERSION_IN already configured: \"%s\"\n", - line, GDB_VERSION_IN_override); - bad++; - break; - } - p1 = index(buf, '\"'); - p2 = rindex(buf, '\"'); - cnt = count_chars(buf, '\"'); - if ((cnt != 2) || !p1 || !p2 || (p1 == p2) || (p2 == (p1+1))) - goto malformed; - *(p2) = '\0'; - gdb_version_in = p1+1; - if (count_chars(gdb_version_in, ' ') || - count_chars(gdb_version_in, '\t')) - goto malformed; - strcpy(GDB_VERSION_IN_override, gdb_version_in); - } - else if ((strncmp(buf, "GDB_FILES ", 10) == 0) || - (strncmp(buf, "GDB_FILES ", 10) == 0) || - (strncmp(buf, "GDB_FILES=", 10) == 0)) { - if (strlen(GDB_FILES_override)) { - fprintf(stderr, - ".gdb_config[line %d]: GDB_FILES already configured: \"%s\"?\n", - line, GDB_FILES_override); - bad++; - break; - } - p1 = index(buf, '\"'); - p2 = rindex(buf, '\"'); - cnt = count_chars(buf, '\"'); - if ((cnt != 2) || !p1 || !p2 || (p1 == p2) || (p2 == (p1+1))) - goto malformed; - *(p2) = '\0'; - gdb_files = p1+1; - if (count_chars(gdb_files, ' ') || count_chars(gdb_files, '\t')) - goto malformed; - strcpy(GDB_FILES_override, gdb_files); - } - else if ((strncmp(buf, "GDB_OFILES ", 11) == 0) || - (strncmp(buf, "GDB_OFILES ", 11) == 0) || - (strncmp(buf, "GDB_OFILES=", 11) == 0)) { - if (strlen(GDB_OFILES_override)) { - fprintf(stderr, - ".gdb_config[line %d]: GDB_OFILES already configured: \"%s\"\n", - line, GDB_OFILES_override); - bad++; - break; - } - p1 = index(buf, '\"'); - p2 = rindex(buf, '\"'); - cnt = count_chars(buf, '\"'); - if ((cnt != 2) || !p1 || !p2 || (p1 == p2) || (p2 == (p1+1))) - goto malformed; - *(p2) = '\0'; - gdb_ofiles = p1+1; - if (count_chars(gdb_ofiles, ' ') || count_chars(gdb_ofiles, '\t')) - goto malformed; - strcpy(GDB_OFILES_override, gdb_ofiles); - } - else { - if (buf[0] == '#') - continue; - goto malformed; + if (strcmp(buf, "7.0") == 0) { + fclose(fp); + sp = &supported_gdb_versions[GDB_7_0]; + fprintf(stderr, ".gdb configuration: %s\n", sp->GDB_VERSION_IN); + return store_gdb_defaults(sp); } } fclose(fp); - if (bad || !gdb || !gdb_version_in || !gdb_files || !gdb_ofiles) { - fprintf(stderr, ".gdb_config: rejected -- using default gdb\n\n"); - sp = NULL; - } else { - fprintf(stderr, ".gdb_config test configuration:\n"); - fprintf(stderr, " GDB=\"%s\"\n", GDB_override); - fprintf(stderr, " GDB_VERSION_IN=\"%s\"\n", GDB_VERSION_IN_override); - fprintf(stderr, " GDB_FILES=\"%s\"\n", GDB_FILES_override); - fprintf(stderr, " GDB_OFILES=\"%s\"\n\n", GDB_OFILES_override); - - test_gdb_version.GDB = GDB_override; - test_gdb_version.GDB_VERSION_IN = GDB_VERSION_IN_override; - test_gdb_version.GDB_FILES = GDB_FILES_override; - test_gdb_version.GDB_OFILES = GDB_OFILES_override; - sp = &test_gdb_version; - } - - return store_gdb_defaults(sp); - -malformed: - fclose(fp); - fprintf(stderr, ".gdb_config[line %d]: malformed line:\n%s\n", - line, inbuf); - fprintf(stderr, ".gdb_config: rejected!\n\n"); - - return store_gdb_defaults(NULL); + fprintf(stderr, ".gdb: rejected -- using default gdb\n\n"); + return store_gdb_defaults(NULL); } -int +struct supported_gdb_version * store_gdb_defaults(struct supported_gdb_version *sp) { if (!sp) @@ -1390,41 +1149,5 @@ else fprintf(stderr, "WARNING: \"make clean\" may be required before rebuilding\n\n"); - GDB_X86 = sp->GDB; - GDB_ALPHA = sp->GDB; - GDB_PPC = sp->GDB; - GDB_IA64 = sp->GDB; - GDB_S390 = sp->GDB; - GDB_S390X = sp->GDB; - GDB_PPC64 = sp->GDB; - GDB_X86_64 = sp->GDB; - - GDB_X86_VERSION_IN = sp->GDB_VERSION_IN; - GDB_ALPHA_VERSION_IN = sp->GDB_VERSION_IN; - GDB_PPC_VERSION_IN = sp->GDB_VERSION_IN; - GDB_IA64_VERSION_IN = sp->GDB_VERSION_IN; - GDB_S390_VERSION_IN = sp->GDB_VERSION_IN; - GDB_S390X_VERSION_IN = sp->GDB_VERSION_IN; - GDB_PPC64_VERSION_IN = sp->GDB_VERSION_IN; - GDB_X86_64_VERSION_IN = sp->GDB_VERSION_IN; - - GDB_FILES_X86 = sp->GDB_FILES; - GDB_FILES_ALPHA = sp->GDB_FILES; - GDB_FILES_PPC = sp->GDB_FILES; - GDB_FILES_IA64 = sp->GDB_FILES; - GDB_FILES_S390 = sp->GDB_FILES; - GDB_FILES_S390X = sp->GDB_FILES; - GDB_FILES_PPC64 = sp->GDB_FILES; - GDB_FILES_X86_64 = sp->GDB_FILES; - - GDB_OFILES_X86 = sp->GDB_OFILES; - GDB_OFILES_ALPHA = sp->GDB_OFILES; - GDB_OFILES_PPC = sp->GDB_OFILES; - GDB_OFILES_IA64 = sp->GDB_OFILES; - GDB_OFILES_S390 = sp->GDB_OFILES; - GDB_OFILES_S390X = sp->GDB_OFILES; - GDB_OFILES_PPC64 = sp->GDB_OFILES; - GDB_OFILES_X86_64 = sp->GDB_OFILES; - - return TRUE; + return sp; } --- crash-4.1.0/alpha.c 2009-11-20 14:38:03.000000000 -0500 +++ crash-4.1.1/alpha.c 2009-10-27 11:48:12.000000000 -0400 @@ -791,13 +791,13 @@ } use_gdb: -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) { static int gdb_frame_offset_warnings = 10; if (gdb_frame_offset_warnings-- > 0) error(WARNING, - "GNU_ALPHA_FRAME_OFFSET functionality not ported to gdb-6.1\n"); + "GNU_ALPHA_FRAME_OFFSET functionality not ported to gdb\n"); } #endif req->command = GNU_ALPHA_FRAME_OFFSET; --- crash-4.1.0/x86.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/x86.c 2009-11-03 10:48:22.000000000 -0500 @@ -290,7 +290,7 @@ if (!name) { if (IS_MODULE_VADDR(callpc) && - module_symbol(callpc, NULL, NULL, buf1, output_radix)) { + module_symbol(callpc, NULL, NULL, buf1, *gdb_output_radix)) { sprintf(buf2, "(%s)", buf1); name = buf2; } --- crash-4.1.0/x86_64.c 2009-11-20 14:38:03.000000000 -0500 +++ crash-4.1.1/x86_64.c 2009-11-13 10:38:04.000000000 -0500 @@ -41,7 +41,7 @@ #define EFRAME_SEARCH (0x8) static int x86_64_print_eframe_location(ulong, int, FILE *); static void x86_64_back_trace_cmd(struct bt_info *); -static ulong x86_64_in_exception_stack(struct bt_info *); +static ulong x86_64_in_exception_stack(struct bt_info *, int *); static ulong x86_64_in_irqstack(struct bt_info *); static void x86_64_low_budget_back_trace_cmd(struct bt_info *); static void x86_64_dwarf_back_trace_cmd(struct bt_info *); @@ -593,16 +593,24 @@ fprintf(fp, "\n"); fprintf(fp, " vsyscall_page: %lx\n", ms->vsyscall_page); - fprintf(fp, " stkinfo: esize: %d%sisize: %d\n", - ms->stkinfo.esize, - machdep->flags & NO_TSS ? " (NO TSS) " : " ", + fprintf(fp, " stkinfo: isize: %d\n", ms->stkinfo.isize); - fprintf(fp, " ebase[%s][7]:", - arg ? "NR_CPUS" : "cpus"); + fprintf(fp, " esize[%d]: %d,%d,%d,%d,%d,%d,%d%s\n", + MAX_EXCEPTION_STACKS, + ms->stkinfo.esize[0], + ms->stkinfo.esize[1], + ms->stkinfo.esize[2], + ms->stkinfo.esize[3], + ms->stkinfo.esize[4], + ms->stkinfo.esize[5], + ms->stkinfo.esize[6], + machdep->flags & NO_TSS ? " (NO TSS) " : " "); + fprintf(fp, " ebase[%s][%d]:", + arg ? "NR_CPUS" : "cpus", MAX_EXCEPTION_STACKS); cpus = arg ? NR_CPUS : kt->cpus; for (c = 0; c < cpus; c++) { fprintf(fp, "\n %s[%d]: ", c < 10 ? " " : "", c); - for (i = 0; i < 7; i++) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { fprintf(fp, "%016lx ", ms->stkinfo.ebase[c][i]); if (i == 3) fprintf(fp, "\n "); @@ -791,10 +799,11 @@ ms = machdep->machspec; for (i = cpus = 0; i < NR_CPUS; i++) { - readmem(symbol_value("per_cpu__cpu_number") + - kt->__per_cpu_offset[i], - KVADDR, &cpunumber, sizeof(int), - "cpu number (per_cpu)", FAULT_ON_ERROR); + if (!readmem(symbol_value("per_cpu__cpu_number") + + kt->__per_cpu_offset[i], + KVADDR, &cpunumber, sizeof(int), + "cpu number (per_cpu)", QUIET|RETURN_ON_ERROR)) + break; if (cpunumber != cpus) break; @@ -837,13 +846,24 @@ verify_spinlock(); } +static char * +x86_64_exception_stacks[MAX_EXCEPTION_STACKS] = { + "STACKFAULT", + "DOUBLEFAULT", + "NMI", + "DEBUG", + "MCE", + "(unknown)", + "(unknown)" +}; + /* * Gather the ist addresses for each CPU. */ static void x86_64_ist_init(void) { - int c, i, cpus; + int c, i, cpus, esize; ulong vaddr, offset; ulong init_tss; struct machine_specific *ms; @@ -857,8 +877,8 @@ vaddr = init_tss + (c * SIZE(tss_struct)) + OFFSET(tss_struct_ist); readmem(vaddr, KVADDR, &ms->stkinfo.ebase[c][0], - sizeof(ulong) * 7, "tss_struct ist array", - FAULT_ON_ERROR); + sizeof(ulong) * MAX_EXCEPTION_STACKS, + "tss_struct ist array", FAULT_ON_ERROR); if (ms->stkinfo.ebase[c][0] == 0) break; } @@ -875,12 +895,38 @@ vaddr += OFFSET(tss_struct_ist); readmem(vaddr, KVADDR, &ms->stkinfo.ebase[c][0], - sizeof(ulong) * 7, "tss_struct ist array", - FAULT_ON_ERROR); + sizeof(ulong) * MAX_EXCEPTION_STACKS, + "tss_struct ist array", FAULT_ON_ERROR); if (ms->stkinfo.ebase[c][0] == 0) break; } + + if (symbol_exists("per_cpu__orig_ist")) { + for (c = 0; c < kt->cpus; c++) { + ulong estacks[MAX_EXCEPTION_STACKS]; + if ((kt->flags & SMP) && (kt->flags & PER_CPU_OFF)) { + if (kt->__per_cpu_offset[c] == 0) + break; + vaddr = symbol_value("per_cpu__orig_ist") + + kt->__per_cpu_offset[c]; + } else + vaddr = symbol_value("per_cpu__orig_ist"); + + readmem(vaddr, KVADDR, &estacks[0], + sizeof(ulong) * MAX_EXCEPTION_STACKS, + "orig_ist array", FAULT_ON_ERROR); + + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { + if (ms->stkinfo.ebase[c][i] != estacks[i]) + error(WARNING, + "cpu %d %s stack: init_tss: %lx orig_ist: %lx\n", c, + x86_64_exception_stacks[i], + ms->stkinfo.ebase[c][i], estacks[i]); + ms->stkinfo.ebase[c][i] = estacks[i]; + } + } + } } else if (!symbol_exists("boot_exception_stacks")) { machdep->flags |= NO_TSS; @@ -891,20 +937,24 @@ } if (ms->stkinfo.ebase[0][0] && ms->stkinfo.ebase[0][1]) - ms->stkinfo.esize = ms->stkinfo.ebase[0][1] - - ms->stkinfo.ebase[0][0]; + esize = ms->stkinfo.ebase[0][1] - ms->stkinfo.ebase[0][0]; else - ms->stkinfo.esize = 4096; /* safe a bet as process stk size */ + esize = 4096; /* * Knowing the size, now adjust the top-of-stack addresses back down * to the base stack address. */ for (c = 0; c < kt->cpus; c++) { - for (i = 0; i < 7; i++) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { if (ms->stkinfo.ebase[c][i] == 0) break; - ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize; + if ((THIS_KERNEL_VERSION >= LINUX(2,6,18)) && + (i == DEBUG_STACK)) + ms->stkinfo.esize[i] = esize*2; + else + ms->stkinfo.esize[i] = esize; + ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i]; } } @@ -953,12 +1003,12 @@ if (!readmem(ms->stkinfo.ebase[c][NMI_STACK], KVADDR, ms->irqstack, - ms->stkinfo.esize, + ms->stkinfo.esize[NMI_STACK], "NMI exception stack contents", RETURN_ON_ERROR|QUIET)) continue; - for (i = clues = 0; i < (ms->stkinfo.esize)/sizeof(ulong); i++){ + for (i = clues = 0; i < (ms->stkinfo.esize[NMI_STACK])/sizeof(ulong); i++){ up = (ulong *)(&ms->irqstack[i*sizeof(ulong)]); if (!is_kernel_text(*up) || @@ -977,7 +1027,7 @@ } if (STREQ(spt->name, "crash_nmi_callback")) { - up = (ulong *)(&ms->irqstack[ms->stkinfo.esize]); + up = (ulong *)(&ms->irqstack[ms->stkinfo.esize[NMI_STACK]]); up -= 2; ms->crash_nmi_rsp[c] = *up; } @@ -2008,16 +2058,6 @@ return (page_present); } -static char * -x86_64_exception_stacks[7] = { - "STACKFAULT", - "DOUBLEFAULT", - "NMI", - "DEBUG", - "MCE", - "(unknown)", - "(unknown)" -}; /* * Look for likely exception frames in a stack. @@ -2025,7 +2065,7 @@ static int x86_64_eframe_search(struct bt_info *bt) { - int i, c, cnt; + int i, c, cnt, estack_index; ulong estack, irqstack, stacksize; ulong *up; struct machine_specific *ms; @@ -2049,7 +2089,7 @@ } for (c = 0; c < kt->cpus; c++) { - for (i = 0; i < 7; i++) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { if (ms->stkinfo.ebase[c][i] == 0) break; bt->hp->esp = ms->stkinfo.ebase[c][i]; @@ -2068,10 +2108,10 @@ if (bt->hp && bt->hp->esp) { ms = machdep->machspec; bt->stkptr = bt->hp->esp; - if ((estack = x86_64_in_exception_stack(bt))) { - stacksize = ms->stkinfo.esize; + if ((estack = x86_64_in_exception_stack(bt, &estack_index))) { + stacksize = ms->stkinfo.esize[estack_index]; bt->stackbase = estack; - bt->stacktop = estack + ms->stkinfo.esize; + bt->stacktop = estack + ms->stkinfo.esize[estack_index]; bt->stackbuf = ms->irqstack; alter_stackbuf(bt); } else if ((irqstack = x86_64_in_irqstack(bt))) { @@ -2398,7 +2438,7 @@ * exception stacks. */ static ulong -x86_64_in_exception_stack(struct bt_info *bt) +x86_64_in_exception_stack(struct bt_info *bt, int *estack_index) { int c, i; ulong rsp; @@ -2410,13 +2450,15 @@ estack = 0; for (c = 0; !estack && (c < kt->cpus); c++) { - for (i = 0; i < 7; i++) { + for (i = 0; i < MAX_EXCEPTION_STACKS; i++) { if (ms->stkinfo.ebase[c][i] == 0) break; if ((rsp >= ms->stkinfo.ebase[c][i]) && (rsp < (ms->stkinfo.ebase[c][i] + - ms->stkinfo.esize))) { + ms->stkinfo.esize[i]))) { estack = ms->stkinfo.ebase[c][i]; + if (estack_index) + *estack_index = i; if (CRASHDEBUG(1) && (c != bt->tc->processor)) error(INFO, "task cpu: %d exception stack cpu: %d\n", @@ -2475,7 +2517,7 @@ static void x86_64_low_budget_back_trace_cmd(struct bt_info *bt_in) { - int i, level, done, framesize; + int i, level, done, framesize, estack_index; ulong rsp, offset, stacktop; ulong *up; long cs; @@ -2537,7 +2579,7 @@ } - if ((estack = x86_64_in_exception_stack(bt))) { + if ((estack = x86_64_in_exception_stack(bt, &estack_index))) { in_exception_stack: bt->flags |= BT_EXCEPTION_STACK; /* @@ -2545,7 +2587,7 @@ * stack, so switch to the indicated exception stack. */ bt->stackbase = estack; - bt->stacktop = estack + ms->stkinfo.esize; + bt->stacktop = estack + ms->stkinfo.esize[estack_index]; bt->stackbuf = ms->irqstack; if (!readmem(bt->stackbase, KVADDR, bt->stackbuf, @@ -2618,7 +2660,8 @@ SIZE(pt_regs), bt, ofp); if (!BT_REFERENCE_CHECK(bt)) - fprintf(fp, "--- ---\n"); + fprintf(fp, "--- <%s exception stack> ---\n", + x86_64_exception_stacks[estack_index]); /* * stack = (unsigned long *) estack_end[-2]; @@ -2728,7 +2771,7 @@ } else irq_eframe = 0; - if (!done && (estack = x86_64_in_exception_stack(bt))) + if (!done && (estack = x86_64_in_exception_stack(bt, &estack_index))) goto in_exception_stack; if (!done && (bt->flags & (BT_EXCEPTION_STACK|BT_IRQSTACK))) { @@ -2922,7 +2965,7 @@ static void x86_64_dwarf_back_trace_cmd(struct bt_info *bt_in) { - int i, level, done; + int i, level, done, estack_index; ulong rsp, offset, stacktop; ulong *up; long cs; @@ -2985,7 +3028,7 @@ } - if ((estack = x86_64_in_exception_stack(bt))) { + if ((estack = x86_64_in_exception_stack(bt, &estack_index))) { in_exception_stack: bt->flags |= BT_EXCEPTION_STACK; /* @@ -2993,7 +3036,7 @@ * stack, so switch to the indicated exception stack. */ bt->stackbase = estack; - bt->stacktop = estack + ms->stkinfo.esize; + bt->stacktop = estack + ms->stkinfo.esize[estack_index]; bt->stackbuf = ms->irqstack; if (!readmem(bt->stackbase, KVADDR, bt->stackbuf, @@ -3118,7 +3161,7 @@ } else irq_eframe = 0; - if (!done && (estack = x86_64_in_exception_stack(bt))) + if (!done && (estack = x86_64_in_exception_stack(bt, &estack_index))) goto in_exception_stack; if (!done && (bt->flags & (BT_EXCEPTION_STACK|BT_IRQSTACK))) { @@ -3474,7 +3517,7 @@ if ((sp = value_search(rip, &offset))) { fprintf(ofp, "%s", sp->name); if (offset) - fprintf(ofp, (output_radix == 16) ? + fprintf(ofp, (*gdb_output_radix == 16) ? "+0x%lx" : "+%ld", offset); bt->eframe_ip = rip; } else @@ -3638,7 +3681,7 @@ if ((cs == 0x10) && kvaddr) { if (is_kernel_text(rip) && IS_KVADDR(rsp) && - x86_64_in_exception_stack(bt)) + x86_64_in_exception_stack(bt, NULL)) return TRUE; } @@ -3899,11 +3942,11 @@ * Check the exception stacks. */ case 1: - if (++estack == 7) + if (++estack == MAX_EXCEPTION_STACKS) break; bt->stackbase = ms->stkinfo.ebase[bt->tc->processor][estack]; bt->stacktop = ms->stkinfo.ebase[bt->tc->processor][estack] + - ms->stkinfo.esize; + ms->stkinfo.esize[estack]; console("x86_64_get_dumpfile_stack_frame: searching %s estack at %lx\n", x86_64_exception_stacks[estack], bt->stackbase); if (!(bt->stackbase)) @@ -4199,10 +4242,13 @@ return 1; for (i = cpus = 0; i < NR_CPUS; i++) { - readmem(symbol_value("per_cpu__cpu_number") + - kt->__per_cpu_offset[i], KVADDR, - &cpunumber, sizeof(int), - "cpu number (per_cpu)", FAULT_ON_ERROR); + if (kt->__per_cpu_offset[i] == 0) + break; + if (!readmem(symbol_value("per_cpu__cpu_number") + + kt->__per_cpu_offset[i], KVADDR, + &cpunumber, sizeof(int), + "cpu number (per_cpu)", QUIET|RETURN_ON_ERROR)) + break; if (cpunumber != cpus) break; cpus++; @@ -4338,18 +4384,23 @@ static void x86_64_display_cpu_data(void) { - int cpu, cpus, boot_cpu, _cpu_pda; + int cpu, cpus, boot_cpu, _cpu_pda, per_cpu; ulong cpu_data; ulong cpu_pda, cpu_pda_addr; boot_cpu = _cpu_pda = FALSE; cpu_data = cpu_pda = 0; cpus = 0; + per_cpu = FALSE; if (symbol_exists("cpu_data")) { cpu_data = symbol_value("cpu_data"); cpus = kt->cpus; boot_cpu = FALSE; + } else if (symbol_exists("per_cpu__cpu_info")) { + cpus = kt->cpus; + boot_cpu = FALSE; + per_cpu = TRUE; } else if (symbol_exists("boot_cpu_data")) { cpu_data = symbol_value("boot_cpu_data"); boot_cpu = TRUE; @@ -4369,19 +4420,26 @@ else fprintf(fp, "%sCPU %d:\n", cpu ? "\n" : "", cpu); + if (per_cpu) + cpu_data = symbol_value("per_cpu__cpu_info") + + kt->__per_cpu_offset[cpu]; + dump_struct("cpuinfo_x86", cpu_data, 0); - fprintf(fp, "\n"); if (_cpu_pda) { readmem(cpu_pda, KVADDR, &cpu_pda_addr, sizeof(unsigned long), "_cpu_pda addr", FAULT_ON_ERROR); + fprintf(fp, "\n"); dump_struct("x8664_pda", cpu_pda_addr, 0); cpu_pda += sizeof(void *); - } else { + } else if (VALID_STRUCT(x8664_pda)) { + fprintf(fp, "\n"); dump_struct("x8664_pda", cpu_pda, 0); cpu_pda += SIZE(x8664_pda); } - cpu_data += SIZE(cpuinfo_x86); + + if (!per_cpu) + cpu_data += SIZE(cpuinfo_x86); } } @@ -5669,7 +5727,7 @@ if ((sp = value_search(up[16], &offset))) { fprintf(fp, "%s", sp->name); if (offset) - fprintf(fp, (output_radix == 16) ? + fprintf(fp, (*gdb_output_radix == 16) ? "+0x%lx" : "+%ld", offset); } else fprintf(fp, "unknown or invalid address"); --- crash-4.1.0/symbols.c 2009-11-20 14:38:03.000000000 -0500 +++ crash-4.1.1/symbols.c 2009-11-19 11:27:00.000000000 -0500 @@ -44,7 +44,10 @@ static void check_insmod_builtin(struct load_module *, int, ulong *); static int is_insmod_builtin(struct load_module *, struct syment *); struct load_module; -static int add_symbol_file(struct load_module *lm); +static int add_symbol_file(struct load_module *); +#ifdef GDB_7_0 +static int add_symbol_file_kallsyms(struct load_module *, struct gnu_request *); +#endif static void find_mod_etext(struct load_module *); static long rodata_search(ulong *, ulong); static int ascii_long(ulong word); @@ -415,7 +418,7 @@ while ((count = read(fd, buffer, sizeof(buffer))) > 0) #if defined(GDB_5_3) file_crc = calc_crc32(file_crc, buffer, count); -#elif defined(GDB_6_0) || defined(GDB_6_1) +#elif defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) file_crc = gnu_debuglink_crc32(file_crc, (unsigned char *)buffer, count); #else @@ -952,7 +955,7 @@ for ( ; sp <= sp_end; sp++) { if (symbol_name_count(sp->name) > 1) - error(WARNING, "%s: duplicate symbol name: %s\n", + error(NOTE, "%s: duplicate symbol name: %s\n", lm->mod_name, sp->name); } } @@ -2303,6 +2306,14 @@ fprintf(fp, "%sUSE_OLD_ADD_SYM", others++ ? "|" : ""); if (st->flags & PERCPU_SYMS) fprintf(fp, "%sPERCPU_SYMS", others++ ? "|" : ""); + if (st->flags & MODSECT_V1) + fprintf(fp, "%sMODSECT_V1", others++ ? "|" : ""); + if (st->flags & MODSECT_V2) + fprintf(fp, "%sMODSECT_V2", others++ ? "|" : ""); + if (st->flags & MODSECT_V3) + fprintf(fp, "%sMODSECT_V3", others++ ? "|" : ""); + if (st->flags & MODSECT_UNKNOWN) + fprintf(fp, "%sMODSECT_UNKNOWN", others++ ? "|" : ""); fprintf(fp, ")\n"); fprintf(fp, " bfd: %lx\n", (ulong)st->bfd); @@ -2418,6 +2429,8 @@ fprintf(fp, "%sMOD_KALLSYMS", others++ ? "|" : ""); if (lm->mod_flags & MOD_INITRD) fprintf(fp, "%sMOD_INITRD", others++ ? "|" : ""); + if (lm->mod_flags & MOD_NOPATCH) + fprintf(fp, "%sMOD_NOPATCH", others++ ? "|" : ""); fprintf(fp, ")\n"); fprintf(fp, " mod_symtable: %lx\n", @@ -2837,7 +2850,7 @@ static int is_bfd_format(char *filename) { -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) struct bfd *bfd; #else struct _bfd *bfd; @@ -2859,7 +2872,7 @@ static int is_binary_stripped(char *filename) { -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) struct bfd *bfd; #else struct _bfd *bfd; @@ -2986,7 +2999,7 @@ show_symbol(sp, offset, show_flags); } else if (module_symbol(value, &sp, - NULL, buf, output_radix)) { + NULL, buf, *gdb_output_radix)) { name = buf; if (prev && sp && @@ -3151,7 +3164,7 @@ buf[0] = NULLCHAR; - if (module_symbol(vaddr, NULL, &lm, NULL, output_radix)) { + if (module_symbol(vaddr, NULL, &lm, NULL, *gdb_output_radix)) { if (lm->mod_flags & MOD_LOAD_SYMS) { for (i = (lm->mod_sections-1); i >= 0; i--) { start = lm->mod_base + @@ -3399,7 +3412,7 @@ return TRUE; } - if (module_symbol(value, NULL, NULL, NULL, output_radix)) + if (module_symbol(value, NULL, NULL, NULL, *gdb_output_radix)) return TRUE; if (machdep->value_to_symbol(value, NULL)) @@ -3431,7 +3444,7 @@ return FALSE; if (!radix) - radix = output_radix; + radix = *gdb_output_radix; if ((radix != 10) && (radix != 16)) radix = 16; @@ -3538,6 +3551,11 @@ (value == spnext->value)) sp = spnext; } + if (sp->name[0] == '.') { + spnext = sp+1; + if (spnext->value == value) + sp = spnext; + } if (offset) *offset = 0; return((struct syment *)sp); @@ -3647,7 +3665,7 @@ buf[0] = NULLCHAR; if (!radix) - radix = output_radix; + radix = *gdb_output_radix; if ((radix != 10) && (radix != 16)) radix = 16; @@ -3659,7 +3677,7 @@ sprintf(buf, "%s", sp->name); } - if (module_symbol(value, NULL, NULL, locbuf, output_radix)) { + if (module_symbol(value, NULL, NULL, locbuf, *gdb_output_radix)) { if (sp) { if (STRNEQ(locbuf, "_MODULE_START_")) shift_string_left(locbuf, @@ -4350,16 +4368,16 @@ error(FATAL, "invalid structure name: %s\n", s); if (radix) { - restore_radix = output_radix; - output_radix = radix; - output_format = (output_radix == 10) ? 0 : 'x'; + restore_radix = *gdb_output_radix; + *gdb_output_radix = radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } print_struct(s, addr); if (radix) { - output_radix = restore_radix; - output_format = (output_radix == 10) ? 0 : 'x'; + *gdb_output_radix = restore_radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } } @@ -4397,9 +4415,9 @@ } if (radix) { - restore_radix = output_radix; - output_radix = radix; - output_format = (output_radix == 10) ? 0 : 'x'; + restore_radix = *gdb_output_radix; + *gdb_output_radix = radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } open_tmpfile(); @@ -4408,8 +4426,8 @@ close_tmpfile(); if (radix) { - output_radix = restore_radix; - output_format = (output_radix == 10) ? 0 : 'x'; + *gdb_output_radix = restore_radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } FREEBUF(buf); @@ -4431,16 +4449,16 @@ error(FATAL, "invalid union name: %s\n", s); if (radix) { - restore_radix = output_radix; - output_radix = radix; - output_format = (output_radix == 10) ? 0 : 'x'; + restore_radix = *gdb_output_radix; + *gdb_output_radix = radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } print_union(s, addr); if (radix) { - output_radix = restore_radix; - output_format = (output_radix == 10) ? 0 : 'x'; + *gdb_output_radix = restore_radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } } @@ -4790,7 +4808,7 @@ } if (!dm->member) { - switch (output_radix) + switch (*gdb_output_radix) { default: case 10: @@ -5128,16 +5146,16 @@ switch(c) { case 'd': - restore_radix = output_radix; - output_radix = 10; - output_format = (output_radix == 10) ? 0 : 'x'; + restore_radix = *gdb_output_radix; + *gdb_output_radix = 10; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; break; case 'h': case 'x': - restore_radix = output_radix; - output_radix = 16; - output_format = (output_radix == 10) ? 0 : 'x'; + restore_radix = *gdb_output_radix; + *gdb_output_radix = 16; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; break; case 'u': @@ -5158,7 +5176,7 @@ return; sprintf(buf2, "%s = ", args[optind]); leader = strlen(buf2); - if (module_symbol(sp->value, NULL, NULL, NULL, output_radix)) + if (module_symbol(sp->value, NULL, NULL, NULL, *gdb_output_radix)) do_load_module_filter = TRUE; } else if (st->flags & LOAD_MODULE_SYMS) do_load_module_filter = TRUE; @@ -5199,8 +5217,8 @@ close_tmpfile(); if (restore_radix) { - output_radix = restore_radix; - output_format = (output_radix == 10) ? 0 : 'x'; + *gdb_output_radix = restore_radix; + *gdb_output_format = (*gdb_output_radix == 10) ? 0 : 'x'; } if (!success) @@ -5691,7 +5709,7 @@ dm->flags |= IN_STRUCT; end_of_block = STRNEQ(inbuf, " } "); - switch (output_radix) + switch (*gdb_output_radix) { default: case 10: @@ -5750,7 +5768,7 @@ goto do_empty_offset; if (end_of_block && dm->member) { - sprintf(buf1, output_radix == 10 ? + sprintf(buf1, *gdb_output_radix == 10 ? " [%ld]" : " [0x%lx]", offset); sprintf(fmt, "%c%ds", '%', len+1); fprintf(ofp, fmt, " "); @@ -5768,7 +5786,7 @@ dm->flags &= ~(IN_UNION|IN_STRUCT); } - sprintf(buf1, output_radix == 10 ? " [%ld]" : " [0x%lx]", offset); + sprintf(buf1, *gdb_output_radix == 10 ? " [%ld]" : " [0x%lx]", offset); sprintf(fmt, "%c%ds", '%', len); fprintf(ofp, fmt, buf1); fprintf(ofp, &inbuf[3]); @@ -6414,6 +6432,27 @@ fprintf(fp, " module_strtab: %ld\n", OFFSET(module_strtab)); + fprintf(fp, " module_sect_attrs: %ld\n", + OFFSET(module_sect_attrs)); + fprintf(fp, " module_sect_attrs_attrs: %ld\n", + OFFSET(module_sect_attrs_attrs)); + fprintf(fp, " module_sect_attrs_nsections: %ld\n", + OFFSET(module_sect_attrs_nsections)); + fprintf(fp, " module_sect_attr_mattr: %ld\n", + OFFSET(module_sect_attr_mattr)); + fprintf(fp, " module_sect_attr_name: %ld\n", + OFFSET(module_sect_attr_name)); + fprintf(fp, " module_sect_attr_address: %ld\n", + OFFSET(module_sect_attr_address)); + fprintf(fp, " attribute_owner: %ld\n", + OFFSET(attribute_owner)); + fprintf(fp, " module_sect_attr_attr: %ld\n", + OFFSET(module_sect_attr_attr)); + fprintf(fp, " module_sections_attrs: %ld\n", + OFFSET(module_sections_attrs)); + fprintf(fp, " module_attribute_attr: %ld\n", + OFFSET(module_attribute_attr)); + fprintf(fp, " module_kallsyms_start: %ld\n", OFFSET(module_kallsyms_start)); fprintf(fp, " kallsyms_header_sections: %ld\n", @@ -7307,6 +7346,7 @@ SIZE(super_block)); fprintf(fp, " irqdesc: %ld\n", SIZE(irqdesc)); fprintf(fp, " module: %ld\n", SIZE(module)); + fprintf(fp, " module_sect_attr: %ld\n", SIZE(module_sect_attr)); fprintf(fp, " list_head: %ld\n", SIZE(list_head)); fprintf(fp, " hlist_head: %ld\n", SIZE(hlist_head)); fprintf(fp, " hlist_node: %ld\n", SIZE(hlist_node)); @@ -8008,7 +8048,7 @@ lm->mod_section_data[i].offset = sec_start - lm->mod_base; lm->mod_section_data[i].flags |= SEC_FOUND; - if (CRASHDEBUG(1)) { + if (CRASHDEBUG(2)) { fprintf(fp, "update sec offset sym %s @ %lx val %lx section %s\n", s1->name, s1->value, syminfo.value, secname); } @@ -8143,7 +8183,7 @@ return TRUE; } - if (CRASHDEBUG(1)) + if (CRASHDEBUG(2)) fprintf(fp, "load_module_symbols: %s %s %lx %lx\n", modref, namelist, base_addr, kt->flags); @@ -8182,7 +8222,7 @@ else if (symcount == 0) error(FATAL, "no symbols in object file: %s\n", namelist); - if (CRASHDEBUG(1)) { + if (CRASHDEBUG(2)) { fprintf(fp, "%ld symbols found in obj file %s\n", symcount, namelist); } @@ -8203,7 +8243,7 @@ add_symbols: result = add_symbol_file(st->current); - if (CRASHDEBUG(1)) + if (CRASHDEBUG(2)) check_for_dups(st->current); st->current = NULL; @@ -8222,6 +8262,14 @@ int i, len; char *secname; + req = &request; + BZERO(req, sizeof(struct gnu_request)); + +#ifdef GDB_7_0 + if ((lm->mod_flags & MOD_KALLSYMS) && + add_symbol_file_kallsyms(lm, req)) + return TRUE; +#endif for (i = len = 0; i < lm->mod_sections; i++) { secname = lm->mod_section_data[i].name; @@ -8233,8 +8281,6 @@ } } - req = &request; - BZERO(req, sizeof(struct gnu_request)); req->command = GNU_ADD_SYMBOL_FILE; req->addr = (ulong)lm; req->buf = GETBUF(len+BUFSIZE); @@ -8244,13 +8290,241 @@ st->flags |= ADD_SYMBOL_FILE; gdb_interface(req); st->flags &= ~ADD_SYMBOL_FILE; + FREEBUF(req->buf); + sprintf(buf, "set complaints 0"); + gdb_pass_through(buf, NULL, 0); + + return(!(req->flags & GNU_COMMAND_FAILED)); +} + +#ifdef GDB_7_0 +/* + * Gather the module section data from the in-kernel data structures. + */ +static int +add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req) +{ + int len, buflen, done, nsections, retval; + ulong vaddr, array_entry, attribute, owner, name, address; + long name_type; + char buf[BUFSIZE]; + char section_name[BUFSIZE]; + ulong section_vaddr; + + if (!(st->flags & (MODSECT_V1|MODSECT_V2|MODSECT_V3|MODSECT_UNKNOWN))) { + STRUCT_SIZE_INIT(module_sect_attr, "module_sect_attr"); + MEMBER_OFFSET_INIT(module_sect_attrs, + "module", "sect_attrs"); + MEMBER_OFFSET_INIT(module_sect_attrs_attrs, + "module_sect_attrs", "attrs"); + MEMBER_OFFSET_INIT(module_sect_attrs_nsections, + "module_sect_attrs", "nsections"); + MEMBER_OFFSET_INIT(module_sect_attr_mattr, + "module_sect_attr", "mattr"); + MEMBER_OFFSET_INIT(module_sect_attr_name, + "module_sect_attr", "name"); + MEMBER_OFFSET_INIT(module_sect_attr_address, + "module_sect_attr", "address"); + MEMBER_OFFSET_INIT(module_attribute_attr, + "module_attribute", "attr"); + MEMBER_OFFSET_INIT(module_sect_attr_attr, + "module_sect_attr", "attr"); + MEMBER_OFFSET_INIT(module_sections_attrs, + "module_sections", "attrs"); + MEMBER_OFFSET_INIT(attribute_owner, + "attribute", "owner"); + + if (VALID_MEMBER(module_sect_attrs_attrs) && + VALID_MEMBER(module_sect_attr_mattr) && + VALID_MEMBER(module_attribute_attr) && + VALID_MEMBER(module_sect_attrs_nsections)) + st->flags |= MODSECT_V3; + else if (VALID_MEMBER(module_sect_attrs_attrs) && + VALID_MEMBER(module_sect_attr_mattr) && + VALID_MEMBER(module_attribute_attr)) + st->flags |= MODSECT_V2; + else if (VALID_MEMBER(module_sect_attr_attr) && + VALID_MEMBER(module_sections_attrs)) + st->flags |= MODSECT_V1; + else + st->flags |= MODSECT_UNKNOWN; + + if ((st->flags & MODSECT_UNKNOWN) || + !VALID_STRUCT(module_sect_attr) || + INVALID_MEMBER(attribute_owner) || + INVALID_MEMBER(module_sect_attrs) || + INVALID_MEMBER(module_sect_attr_name) || + INVALID_MEMBER(module_sect_attr_address)) { + if (CRASHDEBUG(1)) + error(WARNING, + "module section data structures " + "unrecognized or changed\n"); + return FALSE; + } + } else if (st->flags & MODSECT_UNKNOWN) + return FALSE; + + if (!readmem(lm->module_struct + OFFSET(module_sect_attrs), + KVADDR, &vaddr, sizeof(void *), "module.sect_attrs", + RETURN_ON_ERROR|QUIET)) + return FALSE; + + array_entry = attribute = 0; + + switch (st->flags & (MODSECT_V1|MODSECT_V2|MODSECT_V3)) + { + case MODSECT_V1: + array_entry = vaddr + OFFSET(module_sections_attrs); + nsections = UNUSED; + break; + case MODSECT_V2: + array_entry = vaddr + OFFSET(module_sect_attrs_attrs); + nsections = UNUSED; + break; + case MODSECT_V3: + array_entry = vaddr + OFFSET(module_sect_attrs_attrs); + if (!readmem(vaddr + OFFSET(module_sect_attrs_nsections), + KVADDR, &nsections, sizeof(int), + "module_sect_attrs.nsections", RETURN_ON_ERROR|QUIET)) + return FALSE; + if (CRASHDEBUG(2)) + fprintf(fp, "nsections: %d\n", nsections); + break; + } + + if (CRASHDEBUG(2)) + fprintf(fp, "%s:\n", lm->mod_namelist); + + name_type = MEMBER_TYPE("module_sect_attr", "name"); + req->buf = GETBUF(buflen = 1024); + retval = FALSE; + + for (done = FALSE; !done; array_entry += SIZE(module_sect_attr)) { + + switch (st->flags & (MODSECT_V1|MODSECT_V2|MODSECT_V3)) + { + case MODSECT_V1: + attribute = array_entry + OFFSET(module_sect_attr_attr); + break; + case MODSECT_V2: + case MODSECT_V3: + attribute = array_entry + OFFSET(module_sect_attr_mattr) + + OFFSET(module_attribute_attr); + break; + } + + owner = attribute + OFFSET(attribute_owner); + address = array_entry + OFFSET(module_sect_attr_address); + switch (name_type) + { + case TYPE_CODE_ARRAY: + name = array_entry + OFFSET(module_sect_attr_name); + break; + case TYPE_CODE_PTR: + if (!readmem(array_entry + OFFSET(module_sect_attr_name), + KVADDR, &name, sizeof(void *), + "module_sect_attr.name", RETURN_ON_ERROR|QUIET)) { + done = TRUE; + retval = FALSE; + continue; + } + break; + default: + done = TRUE; + retval = FALSE; + } + + if (CRASHDEBUG(2)) { + fprintf(fp, "attribute: %lx ", attribute); + fprintf(fp, " owner: %lx ", owner); + fprintf(fp, " name: %lx ", name); + fprintf(fp, " address: %lx\n", address); + } + + if (nsections == UNUSED) { + if (!readmem(owner, KVADDR, &vaddr, sizeof(void *), + "attribute.owner", RETURN_ON_ERROR|QUIET)) { + done = TRUE; + continue; + } + + if (lm->module_struct != vaddr) { + done = TRUE; + continue; + } + } + + BZERO(section_name, BUFSIZE); + if (!read_string(name, section_name, 32)) { + done = TRUE; + retval = FALSE; + continue; + } + + if (!readmem(address, KVADDR, §ion_vaddr, sizeof(void *), + "module_sect_attr.address", RETURN_ON_ERROR|QUIET)) { + done = TRUE; + retval = FALSE; + continue; + } + + if (CRASHDEBUG(1)) + fprintf(fp, "%lx %s\n", section_vaddr, section_name); + + len = strlen(req->buf); + + if (STREQ(section_name, ".text")) { + sprintf(buf, "add-symbol-file %s 0x%lx", + lm->mod_namelist, section_vaddr); + while ((len + strlen(buf)) >= buflen) { + RESIZEBUF(req->buf, buflen, buflen * 2); + buflen *= 2; + } + shift_string_right(req->buf, strlen(buf)); + strncpy(req->buf, buf, strlen(buf)); + retval = TRUE; + } else { + sprintf(buf, " -s %s 0x%lx", section_name, section_vaddr); + while ((len + strlen(buf)) >= buflen) { + RESIZEBUF(req->buf, buflen, buflen * 2); + buflen *= 2; + } + strcat(req->buf, buf); + } + + if (nsections != UNUSED) { + if (--nsections == 0) + done = TRUE; + } + } + + if (retval == FALSE) { + if (CRASHDEBUG(1)) + fprintf(fp, "%s: add_symbol_file_kallsyms failed\n", + lm->mod_namelist); + FREEBUF(req->buf); + req->buf = NULL; + return FALSE; + } + lm->mod_flags |= MOD_NOPATCH; + req->command = GNU_ADD_SYMBOL_FILE; + req->addr = (ulong)lm; + if (!CRASHDEBUG(1)) + req->fp = pc->nullfp; + + st->flags |= ADD_SYMBOL_FILE; + gdb_interface(req); + st->flags &= ~ADD_SYMBOL_FILE; + + FREEBUF(req->buf); sprintf(buf, "set complaints 0"); gdb_pass_through(buf, NULL, 0); return(!(req->flags & GNU_COMMAND_FAILED)); } +#endif /* @@ -8481,7 +8755,7 @@ namespace_ctl(NAMESPACE_INSTALL, &lm->mod_load_namespace, sp, name); - if (CRASHDEBUG(1)) + if (CRASHDEBUG(2)) fprintf(fp, "installing %c %08lx %s\n", syminfo.type, sp->value, name); @@ -8507,13 +8781,13 @@ if (STREQ(spx->name, nameptr)) { found = TRUE; if (spx->value == sp->value) { - if (CRASHDEBUG(1)) + if (CRASHDEBUG(2)) fprintf(fp, "%s: %s matches!\n", lm->mod_name, nameptr); } else { - if (CRASHDEBUG(1)) + if (CRASHDEBUG(2)) fprintf(fp, "[%s] %s: %lx != extern'd value: %lx\n", lm->mod_name, @@ -8524,7 +8798,7 @@ } } if (!found) { - if (CRASHDEBUG(1)) + if (CRASHDEBUG(2)) fprintf(fp, "append ext %s (%lx)\n", spx->name, spx->value); /* append it here... */ @@ -8591,7 +8865,7 @@ unlink_module(lm); lm->mod_symtable = lm->mod_ext_symtable; lm->mod_symend = lm->mod_ext_symend; - lm->mod_flags &= ~(MOD_LOAD_SYMS|MOD_REMOTE); + lm->mod_flags &= ~(MOD_LOAD_SYMS|MOD_REMOTE|MOD_NOPATCH); lm->mod_flags |= MOD_EXT_SYMS; lm->mod_load_symtable = NULL; lm->mod_load_symend = NULL; @@ -8626,7 +8900,7 @@ unlink_module(lm); lm->mod_symtable = lm->mod_ext_symtable; lm->mod_symend = lm->mod_ext_symend; - lm->mod_flags &= ~(MOD_LOAD_SYMS|MOD_REMOTE); + lm->mod_flags &= ~(MOD_LOAD_SYMS|MOD_REMOTE|MOD_NOPATCH); lm->mod_flags |= MOD_EXT_SYMS; lm->mod_load_symtable = NULL; lm->mod_load_symend = NULL; --- crash-4.1.0/cmdline.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/cmdline.c 2009-11-03 10:48:22.000000000 -0500 @@ -47,7 +47,7 @@ static struct alias_data alias_head = { 0 }; void -get_command_line(void) +process_command_line(void) { /* * Restore normal environment, clearing out any excess baggage @@ -1439,6 +1439,9 @@ argcnt = parse_line(buf, args); allocate_alias(ALIAS_BUILTIN); + strcpy(buf, "alias lsmod mod"); + argcnt = parse_line(buf, args); + allocate_alias(ALIAS_BUILTIN); } /* --- crash-4.1.0/netdump.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/netdump.c 2009-10-29 11:45:34.000000000 -0400 @@ -303,7 +303,8 @@ dump_Elf32_Phdr(nd->load32 + i, ELFSTORE+i); offset32 = nd->notes32->p_offset; for (tot = 0; tot < nd->notes32->p_filesz; tot += len) { - len = dump_Elf32_Nhdr(offset32, ELFSTORE); + if (!(len = dump_Elf32_Nhdr(offset32, ELFSTORE))) + break; offset32 += len; } break; @@ -331,7 +332,8 @@ dump_Elf64_Phdr(nd->load64 + i, ELFSTORE+i); offset64 = nd->notes64->p_offset; for (tot = 0; tot < nd->notes64->p_filesz; tot += len) { - len = dump_Elf64_Nhdr(offset64, ELFSTORE); + if (!(len = dump_Elf64_Nhdr(offset64, ELFSTORE))) + break; offset64 += len; } break; @@ -978,7 +980,8 @@ dump_Elf32_Phdr(nd->load32 + i, ELFREAD); offset32 = nd->notes32->p_offset; for (tot = 0; tot < nd->notes32->p_filesz; tot += len) { - len = dump_Elf32_Nhdr(offset32, ELFREAD); + if (!(len = dump_Elf32_Nhdr(offset32, ELFREAD))) + break; offset32 += len; } break; @@ -991,7 +994,8 @@ dump_Elf64_Phdr(nd->load64 + i, ELFREAD); offset64 = nd->notes64->p_offset; for (tot = 0; tot < nd->notes64->p_filesz; tot += len) { - len = dump_Elf64_Nhdr(offset64, ELFREAD); + if (!(len = dump_Elf64_Nhdr(offset64, ELFREAD))) + break; offset64 += len; } break; @@ -1564,14 +1568,39 @@ char *ptr; ulong *uptr; int xen_core, vmcoreinfo; + uint64_t remaining, notesize; note = (Elf32_Nhdr *)((char *)nd->elf32 + offset); - netdump_print("Elf32_Nhdr:\n"); - netdump_print(" n_namesz: %ld ", note->n_namesz); BZERO(buf, BUFSIZE); xen_core = vmcoreinfo = FALSE; ptr = (char *)note + sizeof(Elf32_Nhdr); + + if (ptr > (nd->elf_header + nd->header_size)) { + if (CRASHDEBUG(1)) + error(WARNING, + "Elf32_Nhdr pointer: %lx ELF header end: %lx\n", + (char *)note, nd->elf_header + nd->header_size); + remaining = 0; + } else + remaining = (uint64_t)((nd->elf_header + nd->header_size) - ptr); + + notesize = (uint64_t)note->n_namesz + (uint64_t)note->n_descsz; + + if ((note->n_namesz == 0) || !remaining || (notesize > remaining)) { + error(WARNING, + "possibly corrupt Elf32_Nhdr: " + "n_namesz: %ld n_descsz: %ld n_type: %lx\n%s", + note->n_namesz, note->n_descsz, note->n_type, + note->n_namesz || note->n_descsz || !remaining ? + "\n" : ""); + if (note->n_namesz || note->n_descsz || !remaining) + return 0; + } + + netdump_print("Elf32_Nhdr:\n"); + netdump_print(" n_namesz: %ld ", note->n_namesz); + BCOPY(ptr, buf, note->n_namesz); netdump_print("(\"%s\")\n", buf); @@ -1758,14 +1787,39 @@ int *iptr; ulong *up; int xen_core, vmcoreinfo; + uint64_t remaining, notesize; note = (Elf64_Nhdr *)((char *)nd->elf64 + offset); - netdump_print("Elf64_Nhdr:\n"); - netdump_print(" n_namesz: %ld ", note->n_namesz); BZERO(buf, BUFSIZE); ptr = (char *)note + sizeof(Elf64_Nhdr); xen_core = vmcoreinfo = FALSE; + + if (ptr > (nd->elf_header + nd->header_size)) { + if (CRASHDEBUG(1)) + error(WARNING, + "Elf64_Nhdr pointer: %lx ELF header end: %lx\n\n", + (char *)note, nd->elf_header + nd->header_size); + remaining = 0; + } else + remaining = (uint64_t)((nd->elf_header + nd->header_size) - ptr); + + notesize = (uint64_t)note->n_namesz + (uint64_t)note->n_descsz; + + if ((note->n_namesz == 0) || !remaining || (notesize > remaining)) { + error(WARNING, + "possibly corrupt Elf64_Nhdr: " + "n_namesz: %ld n_descsz: %ld n_type: %lx\n%s", + note->n_namesz, note->n_descsz, note->n_type, + note->n_namesz || note->n_descsz || !remaining ? + "\n" : ""); + if (note->n_namesz || note->n_descsz || !remaining) + return 0; + } + + netdump_print("Elf64_Nhdr:\n"); + netdump_print(" n_namesz: %ld ", note->n_namesz); + BCOPY(ptr, buf, note->n_namesz); netdump_print("(\"%s\")\n", buf); --- crash-4.1.0/xen_hyper.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/xen_hyper.c 2009-10-26 16:00:35.000000000 -0400 @@ -11,7 +11,8 @@ * * Xencrash is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation (version 2 of the License). + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * Xencrash is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of --- crash-4.1.0/xen_hyper_command.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/xen_hyper_command.c 2009-10-26 16:00:35.000000000 -0400 @@ -11,7 +11,8 @@ * * Xencrash is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation (version 2 of the License). + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * Xencrash is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of --- crash-4.1.0/xen_hyper_global_data.c 2009-11-20 14:38:03.000000000 -0500 +++ crash-4.1.1/xen_hyper_global_data.c 2009-10-26 16:00:35.000000000 -0400 @@ -11,7 +11,8 @@ * * Xencrash is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation (version 2 of the License). + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * Xencrash is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of --- crash-4.1.0/xen_hyper_dump_tables.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/xen_hyper_dump_tables.c 2009-10-26 16:00:35.000000000 -0400 @@ -11,7 +11,8 @@ * * Xencrash is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation (version 2 of the License). + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * Xencrash is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of --- crash-4.1.0/defs.h 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/defs.h 2009-11-20 11:36:45.000000000 -0500 @@ -1482,6 +1482,16 @@ long kobj_map_probes; long task_struct_prio; long zone_watermark; + long module_sect_attrs; + long module_sect_attrs_attrs; + long module_sect_attrs_nsections; + long module_sect_attr_mattr; + long module_sect_attr_name; + long module_sect_attr_address; + long module_attribute_attr; + long attribute_owner; + long module_sect_attr_attr; + long module_sections_attrs; }; struct size_table { /* stash of commonly-used sizes */ @@ -1591,6 +1601,7 @@ long probe; long kobj_map; long page_flags; + long module_sect_attr; }; struct array_table { @@ -1890,7 +1901,7 @@ struct symbol_table_data { ulong flags; -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) struct bfd *bfd; #else struct _bfd *bfd; @@ -1934,6 +1945,10 @@ #define ADD_SYMBOL_FILE (0x200) #define USE_OLD_ADD_SYM (0x400) #define PERCPU_SYMS (0x800) +#define MODSECT_UNKNOWN (0x1000) +#define MODSECT_V1 (0x2000) +#define MODSECT_V2 (0x4000) +#define MODSECT_V3 (0x8000) #endif /* !GDB_COMMON */ @@ -1948,11 +1963,12 @@ #define MOD_REMOTE (0x4) #define MOD_KALLSYMS (0x8) #define MOD_INITRD (0x10) +#define MOD_NOPATCH (0x20) #define SEC_FOUND (0x10000) struct mod_section_data { -#if defined(GDB_6_1) +#if defined(GDB_6_1) || defined(GDB_7_0) struct bfd_section *section; #else struct sec *section; @@ -2953,6 +2969,7 @@ #define GNU_VERSION (13) #define GNU_PATCH_SYMBOL_VALUES (14) #define GNU_GET_SYMBOL_TYPE (15) +#define GNU_USER_PRINT_OPTION (16) #define GNU_DEBUG_COMMAND (100) /* * GNU flags @@ -2994,6 +3011,9 @@ TYPE_CODE_STRUCT, /* C struct or Pascal record */ TYPE_CODE_UNION, /* C union or Pascal variant part */ TYPE_CODE_ENUM, /* Enumeration type */ +#ifdef GDB_7_0 + TYPE_CODE_FLAGS, /* Bit flags type */ +#endif TYPE_CODE_FUNC, /* Function type */ TYPE_CODE_INT, /* Integer type */ @@ -3197,7 +3217,7 @@ void deallocate_alias(char *); void cmdline_init(void); void exec_input_file(void); -void get_command_line(void); +void process_command_line(void); void dump_history(void); void resolve_rc_cmd(char *, int); void dump_alias_data(void); @@ -3294,8 +3314,10 @@ void free_all_bufs(void); char *getbuf(long); void freebuf(char *); +char *resizebuf(char *, long, long); #define GETBUF(X) getbuf((long)(X)) #define FREEBUF(X) freebuf((char *)(X)) +#define RESIZEBUF(X,Y,Z) (X) = resizebuf((char *)(X), (long)(Y), (long)(Z)); void sigsetup(int, void *, struct sigaction *, struct sigaction *); #define SIGACTION(s, h, a, o) sigsetup(s, h, a, o) char *convert_time(ulonglong, char *); @@ -3336,7 +3358,7 @@ int module_symbol(ulong, struct syment **, struct load_module **, char *, ulong); #define IS_MODULE_VADDR(X) \ - (module_symbol((ulong)(X), NULL, NULL, NULL, output_radix)) + (module_symbol((ulong)(X), NULL, NULL, NULL, *gdb_output_radix)) char *closest_symbol(ulong); ulong closest_symbol_value(ulong); #define SAME_FUNCTION(X,Y) (closest_symbol_value(X) == closest_symbol_value(Y)) @@ -3345,7 +3367,7 @@ #define SHOW_SECTION (0x2) #define SHOW_HEX_OFFS (0x4) #define SHOW_DEC_OFFS (0x8) -#define SHOW_RADIX() (output_radix == 16 ? SHOW_HEX_OFFS : SHOW_DEC_OFFS) +#define SHOW_RADIX() (*gdb_output_radix == 16 ? SHOW_HEX_OFFS : SHOW_DEC_OFFS) int symbol_query(char *, char *, struct syment **); struct syment *next_symbol(char *, struct syment *); struct syment *prev_symbol(char *, struct syment *); @@ -3864,15 +3886,17 @@ long ss; }; +#define MAX_EXCEPTION_STACKS 7 +#define NMI_STACK 2 /* ebase[] index to NMI exception stack */ +#define DEBUG_STACK 3 /* ebase[] index to DEBUG exception stack */ + struct x86_64_stkinfo { - ulong ebase[NR_CPUS][7]; - int esize; + ulong ebase[NR_CPUS][MAX_EXCEPTION_STACKS]; + int esize[MAX_EXCEPTION_STACKS]; ulong ibase[NR_CPUS]; int isize; }; -#define NMI_STACK 2 /* ebase[] offset to NMI exception stack */ - struct machine_specific { ulong userspace_top; ulong page_offset; @@ -4567,19 +4591,37 @@ void dump_gnu_request(struct gnu_request *, int); int gdb_CRASHDEBUG(ulong); void dump_gdb_data(void); -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) void update_gdb_hooks(void); #endif void gdb_readnow_warning(void); +extern int *gdb_output_format; +extern unsigned int *gdb_print_max; +extern int *gdb_prettyprint_structs; +extern int *gdb_prettyprint_arrays; +extern int *gdb_repeat_count_threshold; +extern int *gdb_stop_print_at_null; +extern unsigned int *gdb_output_radix; /* * gdb/top.c */ +#if defined(GDB_7_0) +extern void (*deprecated_command_loop_hook)(void); +#else extern void (*command_loop_hook)(void); extern void (*error_hook)(void); +#endif extern void execute_command (char *, int); /* + * gdb/exceptions.c + */ +#if defined(GDB_7_0) +extern void (*error_hook)(void); +#endif + +/* * gdb/symtab.c */ extern void gdb_command_funnel(struct gnu_request *); @@ -4587,7 +4629,7 @@ /* * gdb/symfile.c */ -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) struct objfile; extern void (*target_new_objfile_hook)(struct objfile *); #endif @@ -4596,12 +4638,16 @@ * gdb/valprint.c */ extern unsigned output_radix; +#if defined(GDB_7_0) +extern void *get_user_print_option_address(char *); +#else extern int output_format; extern int prettyprint_structs; extern int prettyprint_arrays; extern int repeat_count_threshold; extern unsigned int print_max; extern int stop_print_at_null; +#endif /* * gdb/utils.c @@ -4616,14 +4662,14 @@ /* * gdb/disasm.c */ -#if !defined(GDB_6_0) && !defined(GDB_6_1) +#if !defined(GDB_6_0) && !defined(GDB_6_1) && !defined(GDB_7_0) extern int gdb_disassemble_from_exec; #endif /* * readline/readline.c */ -#if defined(GDB_6_0) || defined(GDB_6_1) +#if defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) extern char *readline(const char *); #else extern char *readline(char *); @@ -4641,7 +4687,7 @@ #if defined(GDB_5_3) extern int gdb_main_entry(int, char **); extern unsigned long calc_crc32(unsigned long, unsigned char *, size_t); -#elif defined(GDB_6_0) || defined(GDB_6_1) +#elif defined(GDB_6_0) || defined(GDB_6_1) || defined(GDB_7_0) extern int gdb_main_entry(int, char **); extern unsigned long gnu_debuglink_crc32 (unsigned long, unsigned char *, size_t); #else --- crash-4.1.0/xen_hyper_defs.h 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/xen_hyper_defs.h 2009-10-26 16:00:35.000000000 -0400 @@ -11,7 +11,8 @@ * * Xencrash is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation (version 2 of the License). + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * Xencrash is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of --- crash-4.1.0/Makefile 2009-11-20 14:38:12.000000000 -0500 +++ crash-4.1.1/Makefile 2009-11-20 14:38:12.000000000 -0500 @@ -33,13 +33,12 @@ endif # -# GDB, GDB_FILES and GDB_OFILES will be configured automatically by configure +# GDB, GDB_FILES, GDB_OFILES and GDB_PATCH_FILES will be configured automatically by configure # GDB= GDB_FILES= GDB_OFILES= - -GDB_PATCH_FILES=gdb-6.1.patch +GDB_PATCH_FILES= # # Default installation directory @@ -207,6 +206,9 @@ ${GDB}/gdb/ui-file.o ${GDB}/gdb/utils.o ${GDB}/gdb/dwarf2read.o \ ${GDB}/gdb/ppc-linux-tdep.o +GDB_7.0_FILES= +GDB_7.0_OFILES= + # # GDB_FLAGS is passed up from the gdb Makefile. # @@ -227,7 +229,8 @@ CRASH_CFLAGS=-g -D${TARGET} ${TARGET_CFLAGS} ${CFLAGS} -TAR_FILES=${SOURCE_FILES} Makefile COPYING README .rh_rpm_package crash.8 \ +GPL_FILES= +TAR_FILES=${SOURCE_FILES} Makefile ${GPL_FILES} README .rh_rpm_package crash.8 \ ${EXTENSION_SOURCE_FILES} CSCOPE_FILES=${SOURCE_FILES} @@ -251,7 +254,8 @@ @echo "${LDFLAGS} -lz -ldl -rdynamic" > ${GDB}/gdb/mergelibs @echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj @if [ ! -f ${GDB}/config.status ]; then \ - (cd ${GDB}; ./configure --with-separate-debug-dir=/usr/lib/debug; \ + (cd ${GDB}; ./configure --with-separate-debug-dir=/usr/lib/debug \ + --with-bugurl="" --with-expat=no --with-python=no; \ make --no-print-directory;) \ else (cd ${GDB}/gdb; make --no-print-directory;); fi @if [ ! -f ${GDB}/gdb/libgdb.a ]; then \ @@ -260,7 +264,7 @@ gdb_unzip: @rm -f gdb.files - @for FILE in ${GDB_FILES}; do\ + @for FILE in ${GDB_FILES} dummy; do\ echo $$FILE >> gdb.files; done @tar --exclude-from gdb.files -xvzmf ${GDB}.tar.gz @make --no-print-directory gdb_patch @@ -283,7 +287,11 @@ @rm -f configure @cc ${CONF_FLAGS} -o configure configure.c ${WARNING_ERROR} ${WARNING_OPTIONS} -clean: +clean: make_configure + @./configure -q -b + @make --no-print-directory do_clean + +do_clean: rm -f ${OBJECT_FILES} ${DAEMON_OBJECT_FILES} ${PROGRAM} ${PROGRAM}lib.a ${GDB_OFILES} @(cd extensions; make --no-print-directory -i clean) @@ -491,7 +499,7 @@ show_files: @if [ -f ${PROGRAM} ]; then \ ./${PROGRAM} --no_scroll --no_crashrc -h README > README; fi - @echo ${SOURCE_FILES} Makefile ${GDB_FILES} ${GDB_PATCH_FILES} COPYING README \ + @echo ${SOURCE_FILES} Makefile ${GDB_FILES} ${GDB_PATCH_FILES} ${GPL_FILES} README \ .rh_rpm_package crash.8 ${EXTENSION_SOURCE_FILES} ctags: @@ -533,7 +541,7 @@ @rm -f ${PROGRAM}-${VERSION}.tar.gz @rm -f ${PROGRAM}-${VERSION}-${RELEASE}.src.rpm @chown root ./RELDIR/${PROGRAM}-${VERSION} - @tar cf - ${SOURCE_FILES} Makefile ${GDB_FILES} ${GDB_PATCH_FILES} COPYING \ + @tar cf - ${SOURCE_FILES} Makefile ${GDB_FILES} ${GDB_PATCH_FILES} ${GPL_FILES} \ .rh_rpm_package crash.8 ${EXTENSION_SOURCE_FILES} | (cd ./RELDIR/${PROGRAM}-${VERSION}; tar xf -) @cp ${GDB}.tar.gz ./RELDIR/${PROGRAM}-${VERSION} @./${PROGRAM} --no_scroll --no_crashrc -h README > ./RELDIR/${PROGRAM}-${VERSION}/README @@ -587,4 +595,4 @@ @make --no-print-directory do_extensions do_extensions: - @(cd extensions; make -i TARGET=$(TARGET) TARGET_CFLAGS=$(TARGET_CFLAGS)) + @(cd extensions; make -i TARGET=$(TARGET) TARGET_CFLAGS=$(TARGET_CFLAGS) GDB=$(GDB) GDB_FLAGS=$(GDB_FLAGS)) --- crash-4.1.0/extensions/sial.c 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/extensions/sial.c 2009-11-20 10:25:23.000000000 -0500 @@ -1,5 +1,5 @@ /* - * $Id: sial.c,v 1.8 2009/04/30 20:04:02 anderson Exp $ + * $Id: sial.c,v 1.9 2009/11/20 15:25:23 anderson Exp $ * * This file is part of lcrash, an analysis tool for Linux memory dumps. * @@ -16,7 +16,7 @@ * information. */ -#include "gdb-6.1/gdb/defs.h" +#include "gdb/defs.h" #include "target.h" #include "symtab.h" #include "gdbtypes.h" @@ -148,10 +148,18 @@ int v=0; sial_dbg_named(DBG_TYPE, name, 2, "Looking for type %d name [%s] in struct domain...", ctype, name); +#ifdef GDB_6_1 sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL); +#else + sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0); +#endif if(!sym) { sial_dbg_named(DBG_TYPE, name, 2, "Not found.\nLooking for type %d name [%s] in var domain...", ctype, name); +#ifdef GDB_6_1 sym = lookup_symbol(name, 0, VAR_DOMAIN, 0, (struct symtab **) NULL); +#else + sym = lookup_symbol(name, 0, VAR_DOMAIN, 0); +#endif if(sym) { sial_dbg_named(DBG_TYPE, name, 2, "found class=%d\n", sym->aclass); if(sym->aclass == LOC_TYPEDEF) v=1; @@ -227,8 +235,11 @@ // check out for stub types and pull in the definition instead if(TYPE_STUB(type) && TYPE_TAG_NAME(type)) { - +#ifdef GDB_6_1 struct symbol *sym=lookup_symbol(TYPE_TAG_NAME(type), 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL); +#else + struct symbol *sym=lookup_symbol(TYPE_TAG_NAME(type), 0, STRUCT_DOMAIN, 0); +#endif if(sym) { type=sym->type; } @@ -444,7 +455,11 @@ { struct symbol *sym; +#ifdef GDB_6_1 sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL); +#else + sym = lookup_symbol(name, 0, STRUCT_DOMAIN, 0); +#endif if (sym && TYPE_CODE(sym->type)==TYPE_CODE_ENUM) { ENUM_S *et=0; struct type *type=sym->type; --- crash-4.1.0/extensions/sial.mk 2009-11-20 14:38:04.000000000 -0500 +++ crash-4.1.1/extensions/sial.mk 2009-11-20 10:06:23.000000000 -0500 @@ -15,7 +15,7 @@ cd libsial && make sial.so: ../defs.h sial.c lib-sial - gcc -g -I.. -Ilibsial -I../gdb-6.1/bfd -I../gdb-6.1/include -I../gdb-6.1/gdb -I../gdb-6.1/gdb/config -nostartfiles -shared -rdynamic -o sial.so sial.c -fPIC $(TARGET_FLAGS) -Llibsial -lsial + gcc -g -I.. -Ilibsial -I../$(GDB)/bfd -I../$(GDB)/include -I../$(GDB)/gdb -I../$(GDB)/gdb/config -I../$(GDB)/gdb/common -I../$(GDB) -nostartfiles -shared -rdynamic -o sial.so sial.c -fPIC $(TARGET_FLAGS) $(GDB_FLAGS) -Llibsial -lsial clean: cd libsial && make clean