Skip to contentSkip to conversation

gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

PATCH New Thomas Petazzoni 5 participants 7 messages Aug 3, 2017 – Sep 5, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

This adds a patch to gdb 7.12 and gdb 8.x, which fixes the build on noMMU platforms. It is not needed for older versions of gdb, since it's related to the switch of gdb to C++ in the 7.12 release.

Fixes:

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

---
 ...-linux-ptrace.c-add-missing-gdb_byte-cast.patch | 41 ++++++++++++++++++++++
 ...-linux-ptrace.c-add-missing-gdb_byte-cast.patch | 41 ++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 package/gdb/7.12.1/0006-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch
 create mode 100644 package/gdb/8.0/0004-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch
package/gdb/7.12.1/0006-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch new file +41 -0
new file mode 100644
index 0000000..4eb72e4
@@ -0,0 +1,41 @@
+From 09a2c3e0164545324a1ddee70f5c9fdee71e2079 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sun, 18 Jun 2017 23:09:43 +0200
+Subject: [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast
+
+On noMMU platforms, the following code gets compiled:
+
+  child_stack = xmalloc (STACK_SIZE * 4);
+
+Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
+the lack of cast is valid in C, it is not in C++, causing the
+following build failure:
+
+../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
+../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
+       child_stack = xmalloc (STACK_SIZE * 4);
+
+Therefore, this commit adds the appropriate cast.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+[Upstream commit: ffce45d2243e5f52f411e314fc4e1a69f431a81f]
+---
+ gdb/nat/linux-ptrace.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
+index 3447e07..33833e2 100644
+--- a/gdb/nat/linux-ptrace.c
++++ b/gdb/nat/linux-ptrace.c
+@@ -270,7 +270,7 @@ linux_fork_to_function (gdb_byte *child_stack, int (*function) (void *))
+ #define STACK_SIZE 4096
+ 
+     if (child_stack == NULL)
+-      child_stack = xmalloc (STACK_SIZE * 4);
++      child_stack = (gdb_byte*) xmalloc (STACK_SIZE * 4);
+ 
+     /* Use CLONE_VM instead of fork, to support uClinux (no MMU).  */
+ #ifdef __ia64__
+-- 
+2.9.4
+
package/gdb/8.0/0004-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.9.4
#1 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

Hi Thomas,

Le 03/08/2017 ? 09:15, Thomas Petazzoni a ?crit :

Quoted 6 lines

This adds a patch to gdb 7.12 and gdb 8.x, which fixes the build on noMMU platforms. It is not needed for older versions of gdb, since it's related to the switch of gdb to C++ in the 7.12 release.

Fixes:

Quoted 7 lines

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

What's the arch/config are you using?
It's seems no toolchain able to build gdb on noMMU case are present in the autobuilder.

Best regards,
Romain

Quoted 104 lines
---
 ...-linux-ptrace.c-add-missing-gdb_byte-cast.patch | 41 ++++++++++++++++++++++
 ...-linux-ptrace.c-add-missing-gdb_byte-cast.patch | 41 ++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 package/gdb/7.12.1/0006-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch
 create mode 100644 package/gdb/8.0/0004-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch
package/gdb/7.12.1/0006-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch new file +41 -0
new file mode 100644
index 0000000..4eb72e4
@@ -0,0 +1,41 @@
+From 09a2c3e0164545324a1ddee70f5c9fdee71e2079 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sun, 18 Jun 2017 23:09:43 +0200
+Subject: [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast
+
+On noMMU platforms, the following code gets compiled:
+
+  child_stack = xmalloc (STACK_SIZE * 4);
+
+Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
+the lack of cast is valid in C, it is not in C++, causing the
+following build failure:
+
+../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
+../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
+       child_stack = xmalloc (STACK_SIZE * 4);
+
+Therefore, this commit adds the appropriate cast.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+[Upstream commit: ffce45d2243e5f52f411e314fc4e1a69f431a81f]
+---
+ gdb/nat/linux-ptrace.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
+index 3447e07..33833e2 100644
+--- a/gdb/nat/linux-ptrace.c
++++ b/gdb/nat/linux-ptrace.c
+@@ -270,7 +270,7 @@ linux_fork_to_function (gdb_byte *child_stack, int (*function) (void *))
+ #define STACK_SIZE 4096
+ 
+     if (child_stack == NULL)
+-      child_stack = xmalloc (STACK_SIZE * 4);
++      child_stack = (gdb_byte*) xmalloc (STACK_SIZE * 4);
+ 
+     /* Use CLONE_VM instead of fork, to support uClinux (no MMU).  */
+ #ifdef __ia64__
+-- 
+2.9.4
+
package/gdb/8.0/0004-nat-linux-ptrace.c-add-missing-gdb_byte-cast.patch new file +41 -0
new file mode 100644
index 0000000..4eb72e4
@@ -0,0 +1,41 @@
+From 09a2c3e0164545324a1ddee70f5c9fdee71e2079 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sun, 18 Jun 2017 23:09:43 +0200
+Subject: [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast
+
+On noMMU platforms, the following code gets compiled:
+
+  child_stack = xmalloc (STACK_SIZE * 4);
+
+Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
+the lack of cast is valid in C, it is not in C++, causing the
+following build failure:
+
+../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
+../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
+       child_stack = xmalloc (STACK_SIZE * 4);
+
+Therefore, this commit adds the appropriate cast.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+[Upstream commit: ffce45d2243e5f52f411e314fc4e1a69f431a81f]
+---
+ gdb/nat/linux-ptrace.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
+index 3447e07..33833e2 100644
+--- a/gdb/nat/linux-ptrace.c
++++ b/gdb/nat/linux-ptrace.c
+@@ -270,7 +270,7 @@ linux_fork_to_function (gdb_byte *child_stack, int (*function) (void *))
+ #define STACK_SIZE 4096
+ 
+     if (child_stack == NULL)
+-      child_stack = xmalloc (STACK_SIZE * 4);
++      child_stack = (gdb_byte*) xmalloc (STACK_SIZE * 4);
+ 
+     /* Use CLONE_VM instead of fork, to support uClinux (no MMU).  */
+ #ifdef __ia64__
+-- 
+2.9.4
+
#2 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

Hello,

Quoted 9 lines · Romain Naour
Quoted 7 lines

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

What's the arch/config are you using?

This was happening on m68k Coldfire, if i remember correctly.

Quoted 2 lines

It's seems no toolchain able to build gdb on noMMU case are present in the autobuilder.

We have a m68k Coldfire configuration in the autobuilders. However, the pre-built toolchain is built without BR2_PTHREAD_DEBUG, and therefore the target gdb is never built because it depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

Hi Thomas,

Le 05/08/2017 ? 14:23, Thomas Petazzoni a ?crit :

Quoted 16 lines

Hello,

Quoted 9 lines · Romain Naour
Quoted 7 lines

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

What's the arch/config are you using?

This was happening on m68k Coldfire, if i remember correctly.

Quoted 7 lines
Quoted 2 lines

It's seems no toolchain able to build gdb on noMMU case are present in the autobuilder.

We have a m68k Coldfire configuration in the autobuilders. However, the pre-built toolchain is built without BR2_PTHREAD_DEBUG, and therefore the target gdb is never built because it depends on BR2_TOOLCHAIN_HAS_THREADS_DEBUG.

I got an error with gdbserver 8.0 with a m68k toolchain build today on master.

In file included from build-gnulib-gdbserver/import/stdint.h:556:0,

                 from ../common/common-defs.h:55,
                 from ../common/buffer.c:20:
/home/naourr/toolchains/nommu/host/m68k-buildroot-uclinux-uclibc/include/c++/6.4.0/cwchar:58:5:
erreur : conflicting declaration ? typedef struct rpl_mbstate_t rpl_mbstate_t ?
   } mbstate_t;
     ^
build-gnulib-gdbserver/import/wchar.h:486:13: note : previous declaration as
? typedef int rpl_mbstate_t ?
 typedef int rpl_mbstate_t;
             ^~~~~~~~~~~~~

The toolchain used the following defconfig:
BR2_m68k=y
BR2_m68k_cf5208=y
BR2_PTHREAD_DEBUG=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y

gdbserver now require wchar support ?

Also I had to apply [1] to avoid the link issue when thread_db.h is included.

[1] http://patchwork.ozlabs.org/patch/798191/

Best regards,
Romain

Quoted 5 lines

Best regards,

Thomas

#4 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

In reply to Thomas Petazzoni
Quoted 8 lines · Thomas Petazzoni

This adds a patch to gdb 7.12 and gdb 8.x, which fixes the build on noMMU platforms. It is not needed for older versions of gdb, since it's related to the switch of gdb to C++ in the 7.12 release.

Fixes:

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

Quoted 7 lines
       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

Since this is an upstream patch, and the additional issue reported by Romain is
something different, I applied to master, thanks.

BTW, in another thread Thomas P. requested that a build fix which doesn't have
an accompanying autobuild failure should have a defconfig to reproduce :-).

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#5 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

Hello,

Quoted 10 lines · Arnout Vandecappelle
Quoted 10 lines

Fixes:

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

Quoted 7 lines
Quoted 1 line

Since this is an upstream patch, and the additional issue reported by Romain is
something different, I applied to master, thanks.

BTW, in another thread Thomas P. requested that a build fix which doesn't have
an accompanying autobuild failure should have a defconfig to reproduce :-).

Right, will do next time. You should have dropped my patch, I could have done a respin with a defconfig included in the commit log.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#6 lore raw

PATCH 1/1 gdb: add fix for gdb 7.12 and gdb 8.0 build on noMMU platforms

In reply to Thomas Petazzoni
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

This adds a patch to gdb 7.12 and gdb 8.x, which fixes the build on noMMU platforms. It is not needed for older versions of gdb, since it's related to the switch of gdb to C++ in the 7.12 release.

Fixes:

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]

Quoted 7 lines
       child_stack = xmalloc (STACK_SIZE * 4);

The patch has already been merged upstream, as of commit ffce45d2243e5f52f411e314fc4e1a69f431a81f, and will therefore be part of future gdb releases.

Committed to 2017.02.x after dropping the gdb-8.x patch, thanks.

Signature · 1 line
Bye, Peter Korsgaard