This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/18436] New: Can't print dynamically allocated global array
- From: "stanton at haas dot berkeley.edu" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 20 May 2015 04:54:51 +0000
- Subject: [Bug gdb/18436] New: Can't print dynamically allocated global array
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=18436
Bug ID: 18436
Summary: Can't print dynamically allocated global array
Product: gdb
Version: 7.9
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: stanton at haas dot berkeley.edu
Target Milestone: ---
If I dynamically allocate memory for an array using malloc, if the pointer is
defined globally, when I ask gdb to print an element of the array I get the
error message
cannot subscript something of type `<data variable, no debug info>'
Here's a very short program that demonstrates the problem. Compile with
gcc -g -c -o main.o main.c
gcc -o main main.o
then, using gdb, step into the middle of the loop and try "print vec[0]". It
works fine if the "double *vec;" line is inside main().
#include <stdio.h>
#include <stdlib.h>
double *vec;
int main(int argc, char *argv[])
{
int i;
vec = (double *) malloc((unsigned) 10*sizeof(double));
for (i=0; i<10; i++) {
vec[i] = i;
printf("Item %d = %15.6g\n", i, vec[i]);
}
free((char*) vec);
return(0);
}
--
You are receiving this mail because:
You are on the CC list for the bug.