home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gdb / bug / 968 < prev    next >
Encoding:
Text File  |  1992-08-12  |  4.4 KB  |  130 lines

  1. Newsgroups: gnu.gdb.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!citron.sw.stratus.com!pfieland
  3. From: pfieland@citron.sw.stratus.com (Peggy Fieland)
  4. Subject: (none)
  5. Message-ID: <9208122033.AA15669@citron.sw.stratus.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Wed, 12 Aug 1992 20:33:04 GMT
  10. Approved: bug-gdb@prep.ai.mit.edu
  11. Lines: 117
  12.  
  13. Gdb-4.6 (also earlier versions) coredumps when command
  14. "ptype mystruct.xx" is issued, where xx is not a member
  15. of structure mystruct.
  16.  
  17. Here is test program:
  18.  
  19. #include <stdio.h>
  20.  
  21. struct ms
  22. {
  23. int i;
  24. int j;
  25. };
  26.  
  27. struct ms mystruct;
  28.  
  29. main()
  30. {
  31. mystruct.i = 5;
  32. mystruct.j = 10;
  33. printf ("%d %d\n", mystruct.i, mystruct.j);
  34.  
  35. }
  36.  
  37. Here is a sample debugging session:
  38. cyclonic-tests% gdb46 struct
  39. GDB is free software and you are welcome to distribute copies of it
  40.  under certain conditions; type "show copying" to see the conditions.
  41. There is absolutely no warranty for GDB; type "show warranty" for details.
  42. GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
  43. (gdb) b main
  44. Breakpoint 1 at 0x229c: file struct.c, line 13.
  45. (gdb) r
  46. Starting program: /tmp_mnt/net/citron/home/citron/pfieland/gdb-4.6/tests/struct
  47.  
  48. Breakpoint 1, main () at struct.c:13
  49. 13      mystruct.i = 5;
  50. (gdb) ptype mystruct.xx
  51. Segmentation fault (core dumped)
  52. cyclonic-tests%
  53.  
  54. cyclonic-tests% There is absolutely no warranty for GDB; type "show warranty" for details.
  55. There: Command not found.
  56. Software Foundation, Inc...
  57. (gdb)type: Command not found.
  58. cyclonic-tests% GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
  59.  b maiGDB: Command not found.
  60. n
  61. cyclonic-tests% (gdb) b main
  62. Badly placed ()'s.
  63. Bcyclonic-tests% Breakpoint 1 at 0x229c: file struct.c, line 13.
  64. db)Breakpoint: Command not found.
  65. cyclonic-tests% (gdb) r
  66. Badly placed ()'s.
  67. Scyclonic-tests% Starting program: /tmp_mnt/net/citron/home/citron/pfieland/gdb-4.6/tests/struct
  68. Starting: Command not found.
  69. acyclonic-tests%
  70. cyclonic-tests% akpoint 1, main () at struct.c:13
  71. Badly placed ()'s.
  72. cyclonic-tests% 13      mystruct.i = 5;
  73. (gd13: Command not found.
  74. cyclonic-tests% (gdb) ptype mystruct.xx
  75. Badly placed ()'s.
  76. Scyclonic-tests% Segmentation fault (core dumped)
  77. Badly placed ()'s.
  78. -cyclonic-tests% tcyclonic-tests%
  79. cyclonic-tests%: Command not found.
  80. cyclonic-tests%
  81. cyclonic-tests% gdb gdb46 core
  82. GDB is free software and you are welcome to distribute copies of it
  83.  under certain conditions; type "show copying" to see the conditions.
  84. There is absolutely no warranty for GDB; type "show warranty" for details.
  85. GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
  86. Warning: core file may not match specified executable file.
  87. Core was generated by `gdb46'.
  88. Program terminated with signal 11, Segmentation fault.
  89. Cannot access memory at address 0x0.
  90. #0  0x3f434 in check_stub_type (type=0x0) at ../../../gdb-4.6/gdb/gdbtypes.c:727
  91. ../../../gdb-4.6/gdb/gdbtypes.c:727: No such file or directory.
  92. (gdb) bt
  93. #0  0x3f434 in check_stub_type (type=0x0) at ../../../gdb-4.6/gdb/gdbtypes.c:727
  94. #1  0x12b34 in allocate_value (type=0x0) at ../../../gdb-4.6/gdb/values.c:77
  95. #2  0x185dc in value_zero (type=0x0, lv=lval_memory) at ../../../gdb-4.6/gdb/valops.c:131
  96. #3  0x16270 in evaluate_subexp (expect_type=0x0, exp=0x153208, pos=0xf7fff94c,
  97.     noside=EVAL_AVOID_SIDE_EFFECTS) at ../../../gdb-4.6/gdb/eval.c:441
  98. #4  0x1569c in evaluate_type (exp=0x153208) at ../../../gdb-4.6/gdb/eval.c:153
  99. #5  0x2580c in whatis_exp (exp=0x14500e "mystruct.xx", show=1) at ../../../gdb-4.6/gdb/printcmd.c:1073
  100. #6  0x259dc in ptype_command (typename=0x14500e "mystruct.xx", from_tty=1)
  101.     at ../../../gdb-4.6/gdb/printcmd.c:1137
  102. #7  0x361c in execute_command (p=0x14500e "mystruct.xx", from_tty=1) at ../../../gdb-4.6/gdb/main.c:915
  103. #8  0x38c0 in command_loop () at ../../../gdb-4.6/gdb/main.c:976
  104. #9  0x33c0 in main (argc=2, argv=0xf7fffcbc) at ../../../gdb-4.6/gdb/main.c:853
  105.  
  106. Here is a fix:
  107. *** /home/tools/gnu/gdb-4.6/gdb/valops.c    Mon Jul  6 13:11:19 1992
  108. --- gdb-4.6/gdb/valops.c    Wed Aug 12 16:22:50 1992
  109. ***************
  110. *** 130,136 ****
  111.   {
  112.     register value val = allocate_value (type);
  113.   
  114. !   memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (type));
  115.     VALUE_LVAL (val) = lv;
  116.   
  117.     return val;
  118. --- 135,144 ----
  119.   {
  120.     register value val = allocate_value (type);
  121.   
  122. ! /* guard to prevent coredumping on dereference of a null type (caused when, say,
  123. !    doing "ptype var.xx" where xx is not in struct var */
  124. !   if (type != NULL)
  125. !      memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (type));
  126.     VALUE_LVAL (val) = lv;
  127.   
  128.     return val;
  129.  
  130.