This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/17676] New: gdb cannot print the address a pointer is pointing to returned by malloc
- From: "daniel.parkinson1 at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 03 Dec 2014 17:36:46 +0000
- Subject: [Bug gdb/17676] New: gdb cannot print the address a pointer is pointing to returned by malloc
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17676
Bug ID: 17676
Summary: gdb cannot print the address a pointer is pointing to
returned by malloc
Product: gdb
Version: 7.7
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: daniel.parkinson1 at gmail dot com
Overview
After making a call to malloc to assign a memory address to a pointer that is a
parameter of the function, gdb will print 0x0 as the address pointed to.
Steps to reproduce
Compiling the following code...
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
void create_stack(int *other_name_stack);
int *stack;
int main(void) {
create_stack(stack);
return 0;
}
void create_stack(int *other_name_stack) {
other_name_stack = malloc(sizeof(int)*10);
if(other_name_stack == NULL)
printf("Malloc failed: %s\n", strerror(errno));
printf("%p\n", (void *)other_name_stack);
}
Command: gcc -O0 -Wall -g teststack.c -o teststack
Command: gdb ./teststack
break create_stack
n
p other_name_stack
Actual results.
p other_name_stack will always return 0x0, but the if statement will never
return true.
Expected results
I would expect to be able to see the memory address returned by malloc.
Build Date & Hardware
Linux jim-vm-ubuntu 3.16.0-031600-generic #201408031935 SMP Sun Aug 3 23:56:17
UTC 2014 i686 i686 i686 GNU/Linux
Additional Info
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
--
You are receiving this mail because:
You are on the CC list for the bug.