public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/17676] New: gdb cannot print the address a pointer is pointing to returned by malloc
@ 2014-12-03 17:36 daniel.parkinson1 at gmail dot com
  2024-01-02 17:51 ` [Bug gdb/17676] " ssbssa at sourceware dot org
  0 siblings, 1 reply; 2+ messages in thread
From: daniel.parkinson1 at gmail dot com @ 2014-12-03 17:36 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/17676] gdb cannot print the address a pointer is pointing to returned by malloc
  2014-12-03 17:36 [Bug gdb/17676] New: gdb cannot print the address a pointer is pointing to returned by malloc daniel.parkinson1 at gmail dot com
@ 2024-01-02 17:51 ` ssbssa at sourceware dot org
  0 siblings, 0 replies; 2+ messages in thread
From: ssbssa at sourceware dot org @ 2024-01-02 17:51 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=17676

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org
             Status|NEW                         |RESOLVED
         Resolution|---                         |MOVED

--- Comment #1 from Hannes Domani <ssbssa at sourceware dot org> ---
Seems to have been a debug info problem on gcc side, which I can reproduce when
compiling with gcc-4.6.1, but not with when compiling with gcc-4.9.1 or newer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-02 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-03 17:36 [Bug gdb/17676] New: gdb cannot print the address a pointer is pointing to returned by malloc daniel.parkinson1 at gmail dot com
2024-01-02 17:51 ` [Bug gdb/17676] " ssbssa at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).