home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / gdb / bug / 1351 < prev    next >
Encoding:
Text File  |  1993-01-06  |  29.5 KB  |  923 lines

  1. Newsgroups: gnu.gdb.bug
  2. Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!asc.slb.com!wkd
  3. From: wkd@asc.slb.com (W. K. Duttweiler)
  4. Subject: GDB-4.7 bug fixes
  5. Message-ID: <9301051624.AA10004.wkd@cedrick.asc.slb.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 5 Jan 1993 04:24:32 GMT
  10. Approved: bug-gdb@prep.ai.mit.edu
  11. Lines: 910
  12.  
  13. I have made some changes to GDB-4.7, configured for rs6000-ibm-aix, in
  14. order to provide better support for mixed C/C++ programs using xlc/xlC
  15. and for better support for shared libraries. I did not test these
  16. changes on any other platform, but most are restricted to
  17. xcoff-specific code anyway.
  18.  
  19. -wkd
  20.  
  21. William K. Duttweiler                   Schlumberger Austin Systems Center
  22. (512) 331-3000                          PO Box 200015
  23. wkd@asc.slb.com                         Austin, TX  78720-0015
  24.  
  25. Bugs fixed:
  26.  
  27. 1) xlC generates odd stabs for enums, which caused GDB to crash. Its
  28. stabs for CLASSES are completely different than G++, and these were
  29. being ignored completely. A new routine was added to partially support
  30. these stabs. xlC also uses different "trampoline code" to do
  31. inter-module calls. The routine which recognizes such code was
  32. modified to support this, so that 'step' works properly.
  33.  
  34. 2) The .bi/.ei classes were not working properly because the begining
  35. symbol value refers to the first line number entry, but NOT the
  36. function entry which precedes the first line number. This caused ALL
  37. inline functions from include files to start at line 1.
  38.  
  39. 3) "const" and "volatile" qualifiers would create "disconnected"
  40. types. Since the 'this' ptr in C++ member functions is "const", the
  41. debugger was losing the actual struct being pointed at. This was
  42. fixed.
  43.  
  44. 4) The function vmap_symtab() in xcoffexec.c was reorganized to make
  45. the remapping loop simpler. It also was fixed to get the remapping
  46. offset right. The debugger was screwing up any exitsing breakpoints
  47. when you loaded symbols for a new shared library.
  48.  
  49. 5) Shared libraries can get remapped to different addresses every time
  50. you run a program, so the symbols need to be remapped each time, not
  51. just once. IBM's own DBX fails in this respect.
  52.  
  53. The following files were changed:
  54.  
  55. gdb-4.7/gdb/stabsread.c
  56. gdb-4.7/gdb/xcoffread.c
  57. gdb-4.7/gdb/rs6000-tdep.c
  58. gdb-4.7/gdb/xcoffexec.c
  59. gdb-4.7/gdb/tm-rs6000.h
  60.  
  61. Here are the diffs:
  62.  
  63. cedrick[wkd](63)% ls
  64. rs6000-tdep.c    stabsread.c    tm-rs6000.h    xcoffexec.c    xcoffread.c
  65. cedrick[wkd](64)% setenv SRC ~/gnu/gdb-4.7/gdb
  66. cedrick[wkd](65)% foreach file (*)
  67. ? diff -btwc $file $SRC/$file
  68. ? end
  69. *** rs6000-tdep.c    Mon Oct  5 19:41:50 1992
  70. --- /home/ubt21/wkd/gnu/gdb-4.7/gdb/rs6000-tdep.c    Thu Dec 17 15:04:00 1992
  71. ***************
  72. *** 882,887 ****
  73. --- 882,888 ----
  74.   CORE_ADDR pc;
  75.   {
  76.     register unsigned int ii, op;
  77. +   int new_pc_ptr = read_register(11);   /* ptr to new PC if in tramp code */
  78.   
  79.     static unsigned trampoline_code[] = {
  80.           0x800b0000,                     /*     l   r0,0x0(r11)  */
  81. ***************
  82. *** 894,906 ****
  83.           0
  84.     };
  85.   
  86.     for (ii=0; trampoline_code[ii]; ++ii) {
  87.       op  = read_memory_integer (pc + (ii*4), 4);
  88.       if (op != trampoline_code [ii])
  89.         return NULL;
  90.     }
  91. !   ii = read_register (11);              /* r11 holds destination addr   */
  92. !   pc = read_memory_integer (ii, 4);     /* (r11) value                  */
  93.     return pc;
  94.   }
  95.   
  96. --- 895,944 ----
  97.           0
  98.     };
  99.   
  100. +   /*
  101. +   ** xlC lays down its own inline trampoline code, instead of loading in
  102. +   ** the glink.o stuff. It uses r12 instead of r11, and loads it from the
  103. +   ** TOC ptr as the first instruction of the following code...
  104. +   */
  105. +   static unsigned xlC_tramp_code[] = {
  106. +       0,                                /* dummy               */
  107. +       0x90410014,                       /*      st r2,0x14(r1) */
  108. +       0x800c0000,                       /*       l r0,0(r12)   */
  109. +       0x804c0004,                       /*       l r2,4(r12)   */
  110. +       0x7c0903a6,                       /*   mtctr r0          */
  111. +       0x4e800420,                       /*    bctr             */
  112. +       0
  113. +   };
  114. +   static unsigned load_r2_from_r12 = 0x81820000;
  115. + #define OFFSET_MASK (0xfff)
  116. +   int offset = 0;
  117. +       
  118.     for (ii=0; trampoline_code[ii]; ++ii) {
  119.       op  = read_memory_integer (pc + (ii*4), 4);
  120.       if (op != trampoline_code [ii])
  121. +     {
  122. +         /*
  123. +         ** Not the standard trampoline code... check if it is the C++
  124. +         ** version... The first instruction is a "l r12,OFF(r2)". We need
  125. +         ** to verify this AND get the offset.
  126. +         */
  127. +         op = read_memory_integer(pc, 4);
  128. +         offset = op & OFFSET_MASK;      /* get offset */
  129. +         op &= ~OFFSET_MASK;             /* clear offset */
  130. +         if (op != load_r2_from_r12)
  131.               return NULL;
  132. +         for (ii=1; xlC_tramp_code[ii]; ++ii) {
  133. +             op  = read_memory_integer (pc + (ii*4), 4);
  134. +             if (op != xlC_tramp_code [ii])
  135. +                 return NULL;
  136.           }
  137. !         ii = read_register(2);          /* get r2 */
  138. !         new_pc_ptr = read_memory_integer(ii + offset, 4);
  139. !         break;
  140. !     }
  141. !   }
  142. !   pc = read_memory_integer (new_pc_ptr, 4); /* read value*/
  143.     return pc;
  144.   }
  145.   
  146. ***************
  147. *** 1101,1112 ****
  148.   #define LOADINFOLEN     10
  149.   
  150.   /* FIXME Warning -- loadinfotextindex is used for a nefarious purpose by
  151. !    tm-rs6000.h.  */
  152.   
  153.   static  struct loadinfo *loadinfo = NULL;
  154.   static  int     loadinfolen = 0;
  155.   static  int     loadinfotocindex = 0;
  156. ! int     loadinfotextindex = 0;
  157.   
  158.   
  159.   void
  160. --- 1139,1150 ----
  161.   #define LOADINFOLEN     10
  162.   
  163.   /* FIXME Warning -- loadinfotextindex is used for a nefarious purpose by
  164. !    tm-rs6000.h. [wkd] Fixed... */
  165.   
  166.   static  struct loadinfo *loadinfo = NULL;
  167.   static  int     loadinfolen = 0;
  168.   static  int     loadinfotocindex = 0;
  169. ! static  int     loadinfotextindex = 0;
  170.   
  171.   
  172.   void
  173. *** stabsread.c    Wed Oct  7 19:31:18 1992
  174. --- /home/ubt21/wkd/gnu/gdb-4.7/gdb/stabsread.c    Tue Jan  5 09:00:44 1993
  175. ***************
  176. *** 68,73 ****
  177. --- 68,76 ----
  178.   read_struct_type PARAMS ((char **, struct type *, struct objfile *));
  179.   
  180.   static struct type *
  181. + read_xlC_class_type PARAMS ((char **, struct type *, struct objfile *));
  182. + static struct type *
  183.   read_array_type PARAMS ((char **, struct type *, struct objfile *));
  184.   
  185.   static struct type **
  186. ***************
  187. *** 984,989 ****
  188. --- 987,993 ----
  189.             /* Set the type code according to the following letter.  */
  190.             switch ((*pp)[0])
  191.               {
  192. +             case 'Y':                   /* RS6000 xlC class */
  193.               case 's':
  194.                 code = TYPE_CODE_STRUCT;
  195.                 prefix = "struct ";
  196. ***************
  197. *** 1130,1141 ****
  198.   
  199.       case 'k':                           /* Const qualifier on some type (Sun) */
  200.         type = read_type (pp, objfile);
  201. !       /* FIXME! For now, we ignore const and volatile qualifiers.  */
  202.         break;
  203.   
  204.       case 'B':                           /* Volatile qual on some type (Sun) */
  205.         type = read_type (pp, objfile);
  206. !       /* FIXME! For now, we ignore const and volatile qualifiers.  */
  207.         break;
  208.   
  209.   /* FIXME -- we should be doing smash_to_XXX types here.  */
  210. --- 1134,1147 ----
  211.   
  212.       case 'k':                           /* Const qualifier on some type (Sun) */
  213.         type = read_type (pp, objfile);
  214. !       if (typenums[0] != -1)
  215. !           *dbx_lookup_type(typenums) = type; /* point at referenced type */
  216.         break;
  217.   
  218.       case 'B':                           /* Volatile qual on some type (Sun) */
  219.         type = read_type (pp, objfile);
  220. !       if (typenums[0] != -1)
  221. !           *dbx_lookup_type(typenums) = type; /* point at referenced type */
  222.         break;
  223.   
  224.   /* FIXME -- we should be doing smash_to_XXX types here.  */
  225. ***************
  226. *** 1218,1223 ****
  227. --- 1224,1237 ----
  228.         type = read_struct_type (pp, type, objfile);
  229.         break;
  230.   
  231. +     case 'Y':                           /* RS6000 xlC class type */
  232. +       type = dbx_alloc_type (typenums, objfile);
  233. +       if (!TYPE_NAME (type))
  234. +         TYPE_NAME (type) = type_synonym_name;
  235. +       type_synonym_name = 0;
  236. +       type = read_xlC_class_type (pp, type, objfile);
  237. +       break;
  238.       case 'u':                           /* Union type */
  239.         type = dbx_alloc_type (typenums, objfile);
  240.         if (!TYPE_NAME (type))
  241. ***************
  242. *** 1995,2000 ****
  243. --- 2009,2319 ----
  244.     return type;
  245.   }
  246.   
  247. + /*
  248. + ** Read the description of a class type as defined by the IBM xlC C++
  249. + ** compiler. For now, we *ONLY* honor the data members and baseclasses.
  250. + ** xlC uses 'u' for public, 'i' for private, and 'o' for protected, so we
  251. + ** can try to get the visibility right. The method types are
  252. + ** indecipherable to me at this time [wkd/12/11/92].
  253. + **
  254. + ** This code was cloned from read_struct_type and them modified.
  255. + */
  256. + static struct type *
  257. + read_xlC_class_type (pp, type, objfile)
  258. +      char **pp;
  259. +      register struct type *type;
  260. +      struct objfile *objfile;
  261. + {
  262. +   struct nextfield
  263. +     {
  264. +       struct nextfield *next;
  265. +       int visibility;                   /* 0=public, 1=protected, 2=public */
  266. +       struct field field;
  267. +     };
  268. +   struct next_fnfield
  269. +     {
  270. +       struct next_fnfield *next;
  271. +       struct fn_field fn_field;
  272. +     };
  273. +   struct next_fnfieldlist
  274. +     {
  275. +       struct next_fnfieldlist *next;
  276. +       struct fn_fieldlist fn_fieldlist;
  277. +     };
  278. +   register struct nextfield *list = 0;
  279. +   struct nextfield *new;
  280. +   register char *p;
  281. +   int nfields = 0;
  282. +   int non_public_fields = 0;
  283. +   register int n;
  284. +   int typenums[2];
  285. +   int n_baseclasses = 0;
  286. +   register struct next_fnfieldlist *mainlist = 0;
  287. +   int nfn_fields = 0;
  288. +   TYPE_CODE (type) = TYPE_CODE_STRUCT;
  289. +   INIT_CPLUS_SPECIFIC(type);
  290. +   TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
  291. +   /* First comes the total size in bytes.  */
  292. +   TYPE_LENGTH (type) = read_number (pp, 0);
  293. +   /*
  294. +   ** Following the size field, we always see 'c' or 's', which means
  295. +   ** class or struct (I think). We can ignore this character, since all
  296. +   ** the members of a struct get right public visibility modifier. Next,
  297. +   ** an optional 'V', which means ... (I have no idea).
  298. +   */
  299. +   ++*pp;                                /* skip 'c' or 's' */
  300. +   if (**pp == 'V')
  301. +       ++*pp;                            /* skip this too */
  302. +   /*
  303. +   ** Next comes the list of baseclasses. This list is comma-separated
  304. +   ** elements of the form u0:4 (<visibility><offset>:<type>). The list is
  305. +   ** terminated by a '('. There is no leading count of the number of
  306. +   ** baseclasses as in G++.
  307. +   */
  308. +   while (**pp != '(')
  309. +   {
  310. +       int offset;
  311. +       struct type *baseclass;
  312. +       int via_public;
  313. +       if (**pp == '\\')
  314. +           *pp = next_symbol_text ();
  315. +       ALLOCATE_CPLUS_STRUCT_TYPE(type);
  316. +       switch (**pp)
  317. +       {
  318. +       case 'i':
  319. +       case 'o':
  320. +           via_public = 0;
  321. +           non_public_fields++;
  322. +           break;
  323. +       case 'u':
  324. +           via_public = 2;
  325. +           break;
  326. +       default:
  327. +           /* Bad visibility format.  */
  328. +           return error_type (pp);
  329. +       }
  330. +       ++*pp;
  331. +       /*
  332. +       ** Offset of the portion of the object corresponding to this
  333. +       ** baseclass.  Always zero in the absence of multiple inheritance.
  334. +       */
  335. +       offset = read_number (pp, ':');
  336. +       /*
  337. +       ** Don't call read_type to get the type from the type number
  338. +       ** because the '(' terminator will puzzle it...
  339. +       */
  340. +       typenums[0] = 0;
  341. +       typenums[1] = read_number(pp, 0);
  342. +       baseclass = dbx_alloc_type(typenums, objfile);
  343. +       n_baseclasses++;                  /* count it */
  344. +       if (**pp == ',')
  345. +           ++*pp;
  346. +       /* Make this baseclass visible for structure-printing purposes.  */
  347. +       new = (struct nextfield *) alloca (sizeof (struct nextfield));
  348. +       memset (new, 0, sizeof (struct nextfield));
  349. +       new->next = list;
  350. +       list = new;
  351. +       list->visibility = via_public;
  352. +       list->field.type = baseclass;
  353. +       list->field.name = type_name_no_tag (baseclass);
  354. +       list->field.bitpos = offset;
  355. +       list->field.bitsize = 0;  /* this should be an unpacked field! */
  356. +       nfields++;
  357. +   }
  358. +   TYPE_N_BASECLASSES (type) = n_baseclasses;
  359. +   {
  360. +       int num_bytes = B_BYTES (n_baseclasses);
  361. +       char *pointer;
  362. +         
  363. +       pointer = (char *) TYPE_ALLOC (type, num_bytes);
  364. +       TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
  365. +   }
  366. +   B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), n_baseclasses);
  367. +   /*
  368. +   ** **pp == '(' at this point...
  369. +   **
  370. +   ** Now come the fields, as VIS:NAME:TYPE,BITPOS,BITSIZ; At the end, we
  371. +   ** see a semicolon instead of a field. The VIS field can include a one
  372. +   ** character modifier before the actual visibility character. 'c' means
  373. +   ** constant. I'm gonna ignore them for now.
  374. +   **
  375. +   ** Oh,... a field can also be a friend class reference, which is
  376. +   ** indicated by '(TYPE;' I'm gonna ignore these, too.
  377. +   **
  378. +   ** Also, the first field may be a vtable pointer, and it is always
  379. +   ** something like 'cup9__....:__vfp:'. We will skip the stuff up to the
  380. +   ** real identifier (the __vfp). (Cause I don't know what it all means).
  381. +   **
  382. +   ** xlC generates method fields by adding a '[' after the visibility
  383. +   ** character, followed by an additional code before the first ':'. I
  384. +   ** think the codes are 'c' for constructor, 'f' for function, and 'd'
  385. +   ** for destructor. But, we are gonna ignore all methods anyway, and
  386. +   ** simply scan to the ';' at the end of the field.
  387. +   */
  388. +   ++*pp;                                /* skip '(' */
  389. +   while (**pp != ';')
  390. +   {
  391. +       /* Check for and handle cretinous dbx symbol name continuation!  */
  392. +       if (**pp == '\\') *pp = next_symbol_text ();
  393. +       p = *pp;
  394. +       /*
  395. +       ** Check for friend class field and skip to semicolon if so...
  396. +       */
  397. +       if (*p == '(')
  398. +       {
  399. +           while (*p != ';') p++;
  400. +           *pp = p + 1;
  401. +           continue;
  402. +       }
  403. +       /*
  404. +       ** Get the visibility character... check the next character for '['
  405. +       ** and simply skip to first semi-colon if it matches. 
  406. +       **
  407. +       ** Oh,... virtual functions have a vtable index following the
  408. +       ** visibility character, preceding the '['. So, if the next
  409. +       ** character is numeric, the field must be a function.
  410. +       */
  411. +       while ((*p != 'i') && (*p != 'o') && (*p != 'u')) p++;
  412. +       if ((p[1] == '[') || ((p[1] >= '0') && (p[1] <= '9')))
  413. +       {
  414. +           while (*p != ';') p++;
  415. +           *pp = p + 1;                  /* skip field terminator */
  416. +           continue;                     /* back to enclosing while loop */
  417. +       }
  418. +       /*
  419. +       ** Get space to record the next field's data.
  420. +       */
  421. +       new = (struct nextfield *) alloca (sizeof (struct nextfield));
  422. +       memset (new, 0, sizeof (struct nextfield));
  423. +       new->next = list;
  424. +       list = new;
  425. +       switch (*p++)
  426. +       {
  427. +       case 'i':
  428. +           list->visibility = 0; /* private */
  429. +           non_public_fields++;
  430. +           break;
  431. +           
  432. +       case 'o':
  433. +           list->visibility = 1; /* protected */
  434. +           non_public_fields++;
  435. +           break;
  436. +           
  437. +       case 'u':
  438. +           list->visibility = 2; /* public */
  439. +           break;
  440. +       }
  441. +       while (*p != ':') p++;            /* this will skip funky vtable */
  442. +                                         /* goop */
  443. +       p++;                              /* skip ':' */
  444. +       *pp = p;                          /* remember Name ptr... */
  445. +       while (*p != ':') p++;            /* find name terminator */
  446. +       list->field.name =                /* copy name */
  447. +           obsavestring (*pp, p - *pp,
  448. +                         &objfile -> type_obstack);
  449. +       *pp = p + 1;                      /* point at type now */
  450. +       list->field.type = read_type (pp, objfile);
  451. +       ++*pp;;                           /* Skip the comma.  */
  452. +       list->field.bitpos = read_number (pp, ',');
  453. +       list->field.bitsize = read_number (pp, ';');
  454. +       {
  455. +           /*
  456. +           ** Detect an unpacked field and mark it as such.  dbx gives a
  457. +           ** bit size for all fields.  Note that forward refs cannot be
  458. +           ** packed, and treat enums as if they had the width of ints.
  459. +           */
  460. +           if (TYPE_CODE (list->field.type) != TYPE_CODE_INT
  461. +               && TYPE_CODE (list->field.type) != TYPE_CODE_ENUM)
  462. +               list->field.bitsize = 0;
  463. +           if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type)
  464. +                || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM
  465. +                    && (list->field.bitsize
  466. +                        == 8 * TYPE_LENGTH (lookup_fundamental_type (objfile, FT_INTEGER)))
  467. +                    )
  468. +                )
  469. +               &&
  470. +               list->field.bitpos % 8 == 0)
  471. +               list->field.bitsize = 0;
  472. +           nfields++;
  473. +       }
  474. +   }
  475. +   /* Now create the vector of fields, and record how big it is.
  476. +      We need this info to record proper virtual function table information
  477. +      for this class's virtual functions.  */
  478. +   TYPE_NFIELDS (type) = nfields;
  479. +   TYPE_FIELDS (type) = (struct field *)
  480. +     TYPE_ALLOC (type, sizeof (struct field) * nfields);
  481. +   memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
  482. +   if (non_public_fields)
  483. +     {
  484. +       ALLOCATE_CPLUS_STRUCT_TYPE (type);
  485. +       TYPE_FIELD_PRIVATE_BITS (type) = (B_TYPE *)
  486. +         TYPE_ALLOC (type, B_BYTES (nfields));
  487. +       B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
  488. +       TYPE_FIELD_PROTECTED_BITS (type) = (B_TYPE *)
  489. +         TYPE_ALLOC (type, B_BYTES (nfields));
  490. +       B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
  491. +     }
  492. +   /* Copy the saved-up fields into the field vector.  */
  493. +   for (n = nfields; list; list = list->next)
  494. +     {
  495. +       n -= 1;
  496. +       TYPE_FIELD (type, n) = list->field;
  497. +       if (list->visibility == 0)
  498. +         SET_TYPE_FIELD_PRIVATE (type, n);
  499. +       else if (list->visibility == 1)
  500. +         SET_TYPE_FIELD_PROTECTED (type, n);
  501. +     }
  502. +   {
  503. +     int i;
  504. +     for (i = 0; i < TYPE_N_BASECLASSES (type); ++i)
  505. +       {
  506. +         if (TYPE_CODE (TYPE_BASECLASS (type, i)) == TYPE_CODE_UNDEF)
  507. +           /* @@ Memory leak on objfile->type_obstack?  */
  508. +           return error_type (pp);
  509. +         TYPE_NFN_FIELDS_TOTAL (type) +=
  510. +           TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, i));
  511. +       }
  512. +   }
  513. +   return type;
  514. + }
  515.   /* Read a definition of an array type,
  516.      and create and return a suitable type object.
  517.      Also creates a range type which represents the bounds of that
  518. ***************
  519. *** 2120,2125 ****
  520. --- 2439,2457 ----
  521.         if (**pp == '\\') *pp = next_symbol_text ();
  522.   
  523.         p = *pp;
  524. + #if 1
  525. +       /*
  526. +       ** [wkd/12/10/92] the ibm xlC C++ compiler puts a -1: after the 'e'
  527. +       ** for enums seen in C++ files. Skip the stupid -1: before skipping
  528. +       ** to the next colon.
  529. +       */
  530. +       if ((p[0] == '-') && (p[1] == '1') && (p[2] == ':'))
  531. +       {
  532. +           p += 3;
  533. +           *pp = p;                      /* dont let the -1: get into the */
  534. +                                         /* first enum constant name string */
  535. +       }
  536. + #endif
  537.         while (*p != ':') p++;
  538.         name = obsavestring (*pp, p - *pp, &objfile -> symbol_obstack);
  539.         *pp = p + 1;
  540. *** tm-rs6000.h    Fri Sep 18 03:09:18 1992
  541. --- /home/ubt21/wkd/gnu/gdb-4.7/gdb/tm-rs6000.h    Tue Dec 15 12:33:27 1992
  542. ***************
  543. *** 18,24 ****
  544.   along with this program; if not, write to the Free Software
  545.   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  546.   
  547. - extern int      symtab_relocated;
  548.   
  549.   /* Minimum possible text address in AIX */
  550.   
  551. --- 18,23 ----
  552. ***************
  553. *** 29,35 ****
  554.      if symbol table relocation wasn't done yet. */
  555.   
  556.   #define CORE_NEEDS_RELOCATION(PC)       \
  557. !   if (!symtab_relocated && !inferior_pid && (PC) >  TEXT_SEGMENT_BASE)  \
  558.       (PC) -= ( TEXT_SEGMENT_BASE + text_adjustment (exec_bfd));
  559.   
  560.   /* Load segment of a given pc value. */
  561. --- 28,34 ----
  562.      if symbol table relocation wasn't done yet. */
  563.   
  564.   #define CORE_NEEDS_RELOCATION(PC)       \
  565. !   if (!inferior_pid && (PC) >  TEXT_SEGMENT_BASE)       \
  566.       (PC) -= ( TEXT_SEGMENT_BASE + text_adjustment (exec_bfd));
  567.   
  568.   /* Load segment of a given pc value. */
  569. ***************
  570. *** 119,126 ****
  571.   /* When a child process is just starting, we sneak in and relocate
  572.      the symbol table (and other stuff) after the dynamic linker has
  573.      figured out where they go. But we want to do this relocation just
  574. !    once. */
  575.   
  576.   extern int loadinfotextindex;
  577.   
  578.   #define SOLIB_CREATE_INFERIOR_HOOK(PID) \
  579. --- 118,127 ----
  580.   /* When a child process is just starting, we sneak in and relocate
  581.      the symbol table (and other stuff) after the dynamic linker has
  582.      figured out where they go. But we want to do this relocation just
  583. !    once. [wkd] What a crock! We want to do this EVERY time, since they can
  584. !    get remapped to different addresses */
  585.   
  586. + #if 0
  587.   extern int loadinfotextindex;
  588.   
  589.   #define SOLIB_CREATE_INFERIOR_HOOK(PID) \
  590. ***************
  591. *** 128,133 ****
  592. --- 129,138 ----
  593.       if (loadinfotextindex == 0) \
  594.           xcoff_relocate_symtab (PID);    \
  595.     } while (0)
  596. + #else
  597. + #define SOLIB_CREATE_INFERIOR_HOOK(PID) xcoff_relocate_symtab(PID)
  598. + #endif
  599.           
  600.   
  601.   /* Number of trap signals we need to skip over, once the inferior process
  602. *** xcoffexec.c    Wed Oct  7 19:31:53 1992
  603. --- /home/ubt21/wkd/gnu/gdb-4.7/gdb/xcoffexec.c    Tue Dec 15 13:29:47 1992
  604. ***************
  605. *** 355,365 ****
  606.   }
  607.   
  608.   
  609. - /* true, if symbol table and minimal symbol table are relocated. */
  610. - int symtab_relocated = 0;
  611.   /*  vmap_symtab -       handle symbol translation on vmapping */
  612.   
  613.   vmap_symtab(vp, old_start, vip)
  614. --- 355,360 ----
  615. ***************
  616. *** 371,404 ****
  617.     register struct objfile *objfile;
  618.     register struct minimal_symbol *msymbol;
  619.     
  620.     /*
  621. !    * for each symbol table generated from the vp->bfd
  622.      */
  623.     ALL_OBJFILES (objfile)
  624.       {
  625. !       for (s = objfile -> symtabs; s != NULL; s = s -> next) {
  626. !         
  627. !         /* skip over if this is not relocatable and doesn't have a line table */
  628. !         if (s->nonreloc && !LINETABLE (s))
  629.             continue;
  630. !         
  631. !         /* matching the symbol table's BFD and the *vp's BFD is hairy.
  632. !            exec_file creates a seperate BFD for possibly the
  633. !            same file as symbol_file.FIXME ALL THIS MUST BE RECTIFIED. */
  634. !         
  635. !         if (objfile->obfd == vp->bfd) {
  636.             /* if they match, we luck out. */
  637.             ;
  638. !         } else if (vp->member[0]) {
  639. !           /* no match, and member present, not this one. */
  640.             continue;
  641. !         } else {
  642.             struct stat si;
  643.             FILE *io;
  644.             
  645. -           /*
  646. -            * no match, and no member. need to be sure.
  647. -            */
  648.             io = bfd_cache_lookup(objfile->obfd);
  649.             if (!io)
  650.               fatal("cannot find BFD's iostream for sym");
  651. --- 366,403 ----
  652.     register struct objfile *objfile;
  653.     register struct minimal_symbol *msymbol;
  654.     
  655. +   /* true, if symbol table and minimal symbol table are relocated. */
  656. +   int symtab_relocated = 0;
  657.     /*
  658. !   ** for each symbol table generated from the vp->bfd
  659. !   ** Matching the symbol table's BFD and the *vp's BFD is hairy.
  660. !   ** exec_file creates a seperate BFD for possibly the
  661. !   ** same file as symbol_file. 
  662. !   **
  663. !   ** We can ignore any objfile with no symbols. We can match any objfile
  664. !   ** whose BFD is an exact match. We can match ones which refer to the
  665. !   ** same file. Note that if 'vip' is NULL, then ONLY an exact BFD match
  666. !   ** will work.
  667. !   **
  668. !   ** Match BFDs BEFORE looping on symtabs...
  669.     */
  670.     ALL_OBJFILES (objfile)
  671.       {
  672. !         if (!objfile->symtabs)
  673.               continue;
  674. !         else if (objfile->obfd == vp->bfd)
  675.             /* if they match, we luck out. */
  676.             ;
  677. !         else if (!vip)
  678.               continue;
  679. !         else
  680. !         {
  681.             struct stat si;
  682.             FILE *io;
  683.             
  684.             io = bfd_cache_lookup(objfile->obfd);
  685.             if (!io)
  686.               fatal("cannot find BFD's iostream for sym");
  687. ***************
  688. *** 408,425 ****
  689.             if (fstat(fileno(io), &si) < 0)
  690.               fatal("cannot fstat BFD for sym");
  691.             
  692. !           if (vip && (si.st_dev != vip->st_dev
  693. !               || si.st_ino != vip->st_ino))
  694.               continue;
  695.           }
  696.           
  697.           if (vp->tstart != old_start) {
  698. !           /* Once we find a relocation base address for one of the symtabs
  699. !              in this objfile, it will be the same for all symtabs in this
  700. !              objfile. Clean this algorithm. FIXME. */
  701. !           for (; s; s = s->next)
  702.               if (!s->nonreloc || LINETABLE(s))
  703.                   vmap_symtab_1(s, vp, old_start);
  704.   
  705. --- 407,423 ----
  706.             if (fstat(fileno(io), &si) < 0)
  707.               fatal("cannot fstat BFD for sym");
  708.             
  709. !           if (si.st_dev != vip->st_dev || si.st_ino != vip->st_ino)
  710.               continue;
  711.           }
  712.           
  713. +         /*
  714. +         ** Got a match on BFD... process all the symbols that are
  715. +         ** relocatable and have line tables...
  716. +         */
  717.           if (vp->tstart != old_start) {
  718. !           symtab_relocated = 1;
  719. !           for (s = objfile->symtabs; s; s = s->next)
  720.               if (!s->nonreloc || LINETABLE(s))
  721.                   vmap_symtab_1(s, vp, old_start);
  722.   
  723. ***************
  724. *** 433,439 ****
  725.             ALL_MSYMBOLS (objfile, msymbol)
  726.   #else
  727.             for (msymbol = objfile->msymbols;
  728. !                 msymbol->name || msymbol->address; (msymbol)++)
  729.   #endif
  730.                 if (msymbol->address < TEXT_SEGMENT_BASE)
  731.                   msymbol -> address += vp->tstart - old_start;
  732. --- 431,437 ----
  733.             ALL_MSYMBOLS (objfile, msymbol)
  734.   #else
  735.             for (msymbol = objfile->msymbols;
  736. !                 msymbol && (msymbol->name || msymbol->address); (msymbol)++)
  737.   #endif
  738.                 if (msymbol->address < TEXT_SEGMENT_BASE)
  739.                   msymbol -> address += vp->tstart - old_start;
  740. ***************
  741. *** 441,454 ****
  742.              break;
  743.           }
  744.         }
  745. -     }
  746.   
  747. !   if (vp->tstart != old_start) {
  748.       /* breakpoints need to be relocated as well. */
  749. !     fixup_breakpoints (0, TEXT_SEGMENT_BASE, vp->tstart - old_start);
  750.     }
  751.     
  752. -   symtab_relocated = 1;
  753.   }
  754.   
  755.   
  756. --- 439,451 ----
  757.              break;
  758.           }
  759.         }
  760.   
  761. !   if (symtab_relocated && vp->tstart != old_start) {
  762.       /* breakpoints need to be relocated as well. */
  763. !       fixup_breakpoints (old_start, vp->tend-vp->tstart+old_start,
  764. !                          vp->tstart - old_start);
  765.     }
  766.     
  767.   }
  768.   
  769.   
  770. *** xcoffread.c    Fri Oct 16 14:16:59 1992
  771. --- /home/ubt21/wkd/gnu/gdb-4.7/gdb/xcoffread.c    Tue Jan  5 08:49:21 1993
  772. ***************
  773. *** 274,279 ****
  774. --- 274,300 ----
  775.   }
  776.   
  777.   
  778. + static void
  779. + exam_syms(
  780. +     struct objfile *objfile)
  781. + {
  782. +     register struct symtab *s;
  783. +     static int flag = 0;
  784. +     static char *debug = 0;
  785. +     if (!flag)
  786. +     {
  787. +         debug = getenv("GDB_DEBUG");
  788. +         flag = 1;
  789. +     }
  790. +     if (!debug || !objfile)
  791. +         return;
  792. +     for (s = objfile -> symtabs; s != NULL; s = s -> next)
  793. +         if (s->filename)
  794. +             printf("0x%x: '%s'\n", s, s->filename);
  795. + }
  796.   /* add a given stab string into given stab vector. */
  797.   
  798.   static void
  799. ***************
  800. *** 482,488 ****
  801.     }
  802.   
  803.     inclTable [inclIndx].name  = cs->c_name;
  804. !   inclTable [inclIndx].begin = cs->c_value;
  805.   }
  806.   
  807.   
  808. --- 503,520 ----
  809.     }
  810.   
  811.     inclTable [inclIndx].name  = cs->c_name;
  812. !   /*
  813. !   ** The xlC (IBM C++) compiler generates lots of .bi/.ei pairs for
  814. !   ** "inline" functions. The cs->c_value entry is the offset to the first
  815. !   ** line number entry in the line table. These entries are organized by
  816. !   ** FUNCTION, so the first entry is always line 1 of a particular
  817. !   ** function. The line entry which PRECEDES this value has a line number
  818. !   ** flag of 0, and the symbol table index of the function. Hence, we
  819. !   ** record the begin entry as the preceding line number entry so that
  820. !   ** "process_linenos" will work properly.
  821. !   */
  822. !   inclTable [inclIndx].begin = cs->c_value - LINESZ;
  823.   }
  824.   
  825.   
  826. ***************
  827. *** 633,642 ****
  828.   
  829.   /*      start_subfile (inclTable[ii].name, (char*)0);  */
  830.           start_subfile (" ?", (char*)0);
  831. -         current_subfile->name = 
  832. -                 obsavestring (inclTable[ii].name, strlen (inclTable[ii].name),
  833. -                               ¤t_objfile->symbol_obstack);
  834.   
  835.           if (lv == lineTb) {
  836.             current_subfile->line_vector = (struct linetable *)
  837.                   xrealloc (lv, (sizeof (struct linetable)
  838. --- 665,682 ----
  839.   
  840.   /*      start_subfile (inclTable[ii].name, (char*)0);  */
  841.           start_subfile (" ?", (char*)0);
  842.   
  843. +         /*
  844. +         ** current_subfile now refers to the one we just built with the
  845. +         ** dummy name. Replace the name with the right name. We need to
  846. +         ** free the duplicated name before replacing it. We must ALSO use
  847. +         ** strdup() to allocate and copy the name into the subfile
  848. +         ** pointer, just as start_subfile() does... we cannot allocate
  849. +         ** this string on the obstack. [wkd/12/10/92]
  850. +         */
  851. +         free((PTR)current_subfile->name);
  852. +         current_subfile->name = strdup(inclTable[ii].name);
  853.           if (lv == lineTb) {
  854.             current_subfile->line_vector = (struct linetable *)
  855.                   xrealloc (lv, (sizeof (struct linetable)
  856. ***************
  857. *** 2299,2304 ****
  858. --- 2339,2346 ----
  859.   
  860.     /* Free debug section. */
  861.     free_debugsection ();
  862. +   exam_syms(objfile);
  863.   
  864.     /* Sort symbols alphabetically within each block.  */
  865.     sort_syms ();
  866. cedrick[wkd](66)% 
  867.  
  868.