* [PATCH 3/7] gdbserver: avoid empty structs when not using GCC
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
@ 2013-06-27 8:44 ` Mircea Gherzan
2013-06-28 16:04 ` Tom Tromey
2013-06-27 8:44 ` [PATCH 2/7] gdbserver, common: convert some variadic macros to C99 Mircea Gherzan
` (5 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 8:44 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
gdbserver/
* notif.h (notif_event): Add a dummy member to avoid compiler
errors when not using GCC.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/gdbserver/notif.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/gdbserver/notif.h b/gdb/gdbserver/notif.h
index 608b763..ed3c714 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -27,6 +27,10 @@
typedef struct notif_event
{
+#ifndef __GNUC__
+ /* C requires that a struct or union has at least one member. */
+ char dummy;
+#endif
} *notif_event_p;
DECLARE_QUEUE_P (notif_event_p);
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH 2/7] gdbserver, common: convert some variadic macros to C99
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
2013-06-27 8:44 ` [PATCH 3/7] gdbserver: avoid empty structs when not using GCC Mircea Gherzan
@ 2013-06-27 8:44 ` Mircea Gherzan
2013-06-28 16:02 ` Tom Tromey
2013-06-27 8:44 ` [PATCH 1/7] gdbserver, common: conditionally include the unistd.h Mircea Gherzan
` (4 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 8:44 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
* common/agent.c (DEBUG_AGENT): convert to __VA_ARGS__.
gdbserver/
* ax.c (ax_debug): Convert to __VA_ARGS__.
(ax_debug_1): Convert to __VA_ARGS__.
* tracepoint.c (trace_debug): Convert to __VA_ARGS__.
(trace_debug_1): Convert to __VA_ARGS__.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/common/agent.c | 8 ++++----
gdb/gdbserver/ax.c | 12 ++++++------
gdb/gdbserver/tracepoint.c | 10 +++++-----
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/gdb/common/agent.c b/gdb/common/agent.c
index bbf5c4c..f0759b5 100644
--- a/gdb/common/agent.c
+++ b/gdb/common/agent.c
@@ -35,13 +35,13 @@
int debug_agent = 0;
#ifdef GDBSERVER
-#define DEBUG_AGENT(fmt, args...) \
+#define DEBUG_AGENT(...) \
if (debug_agent) \
- fprintf (stderr, fmt, ##args);
+ fprintf (stderr, __VA_ARGS__);
#else
-#define DEBUG_AGENT(fmt, args...) \
+#define DEBUG_AGENT(...) \
if (debug_agent) \
- fprintf_unfiltered (gdb_stdlog, fmt, ##args);
+ fprintf_unfiltered (gdb_stdlog, __VA_ARGS__);
#endif
/* Global flag to determine using agent or not. */
diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c
index b6824a2..71145c1 100644
--- a/gdb/gdbserver/ax.c
+++ b/gdb/gdbserver/ax.c
@@ -38,14 +38,14 @@ ax_vdebug (const char *fmt, ...)
va_end (ap);
}
-#define ax_debug_1(level, fmt, args...) \
- do { \
- if (level <= debug_threads) \
- ax_vdebug ((fmt), ##args); \
+#define ax_debug_1(level, ...) \
+ do { \
+ if (level <= debug_threads) \
+ ax_vdebug (__VA_ARGS__); \
} while (0)
-#define ax_debug(FMT, args...) \
- ax_debug_1 (1, FMT, ##args)
+#define ax_debug(...) \
+ ax_debug_1 (1, __VA_ARGS__)
/* This enum must exactly match what is documented in
gdb/doc/agentexpr.texi, including all the numerical values. */
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index c0dea5b..392f84b 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -76,14 +76,14 @@ trace_vdebug (const char *fmt, ...)
va_end (ap);
}
-#define trace_debug_1(level, fmt, args...) \
- do { \
+#define trace_debug_1(level, ...) \
+ do { \
if (level <= debug_threads) \
- trace_vdebug ((fmt), ##args); \
+ trace_vdebug (__VA_ARGS__); \
} while (0)
-#define trace_debug(FMT, args...) \
- trace_debug_1 (1, FMT, ##args)
+#define trace_debug(...) \
+ trace_debug_1 (1, __VA_ARGS__)
#if defined(__GNUC__)
# define ATTR_USED __attribute__((used))
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 2/7] gdbserver, common: convert some variadic macros to C99
2013-06-27 8:44 ` [PATCH 2/7] gdbserver, common: convert some variadic macros to C99 Mircea Gherzan
@ 2013-06-28 16:02 ` Tom Tromey
0 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2013-06-28 16:02 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: palves, jan.kratochvil, gdb-patches
>>>>> "Mircea" == Mircea Gherzan <mircea.gherzan@intel.com> writes:
Mircea> #ifdef GDBSERVER
Mircea> -#define DEBUG_AGENT(fmt, args...) \
Mircea> +#define DEBUG_AGENT(...) \
This is a funny situation.
Officially, GDB is C89, while varargs macros are c99.
However, the existing code here is a GNU extension. Clearly nobody has
ever tried to compile this code with a compiler other than GCC.
I would like us to adopt C99, but I think this requires some community
agreement.
Tom
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/7] gdbserver, common: conditionally include the unistd.h
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
2013-06-27 8:44 ` [PATCH 3/7] gdbserver: avoid empty structs when not using GCC Mircea Gherzan
2013-06-27 8:44 ` [PATCH 2/7] gdbserver, common: convert some variadic macros to C99 Mircea Gherzan
@ 2013-06-27 8:44 ` Mircea Gherzan
2013-06-27 13:29 ` Pedro Alves
2013-06-27 8:44 ` [PATCH 4/7] gdbserver: conditionally include sys/param.h and sys/time.h Mircea Gherzan
` (3 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 8:44 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
* common/agent.c: Conditionally include unistd.h.
gdbserver/
* hostio.c: Conditionally include unistd.h and define PATH_MAX
if unistd.h is not available.
* tracepoint.h: Conditionally include unistd.h.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/common/agent.c | 2 ++
gdb/gdbserver/hostio.c | 7 +++++++
gdb/gdbserver/tracepoint.c | 2 ++
3 files changed, 11 insertions(+)
diff --git a/gdb/common/agent.c b/gdb/common/agent.c
index 99cef4f..bbf5c4c 100644
--- a/gdb/common/agent.c
+++ b/gdb/common/agent.c
@@ -26,7 +26,9 @@
#endif
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include "agent.h"
#include "filestuff.h"
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index df94d31..3cf93db 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -23,7 +23,14 @@
#include <fcntl.h>
#include <limits.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+/* PATH_MAX is defined in unistd.h, which might not be available. */
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
extern int remote_debug;
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 5c0dec7..c0dea5b 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -22,7 +22,9 @@
#include <ctype.h>
#include <fcntl.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <sys/time.h>
#include <stddef.h>
#include <inttypes.h>
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 1/7] gdbserver, common: conditionally include the unistd.h
2013-06-27 8:44 ` [PATCH 1/7] gdbserver, common: conditionally include the unistd.h Mircea Gherzan
@ 2013-06-27 13:29 ` Pedro Alves
2013-06-27 19:19 ` Pedro Alves
0 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2013-06-27 13:29 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: tromey, palves, jan.kratochvil, gdb-patches
On 06/27/2013 09:43 AM, Mircea Gherzan wrote:
> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
>
> * common/agent.c: Conditionally include unistd.h.
>
> gdbserver/
> * hostio.c: Conditionally include unistd.h and define PATH_MAX
> if unistd.h is not available.
> * tracepoint.h: Conditionally include unistd.h.
Hmm, I've discussed this PATH_MAX issue before.
I think we should pull in the unistd and pathmax modules from
gnulib. In hostio.c, we should cap the max path len to the max
of PATH_MAX (if defined, it won't on the Hurd), and the packet buffer
size. Let me post a series for that.
--
Pedro Alves
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/7] gdbserver, common: conditionally include the unistd.h
2013-06-27 13:29 ` Pedro Alves
@ 2013-06-27 19:19 ` Pedro Alves
2013-06-28 15:16 ` Mircea Gherzan
0 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2013-06-27 19:19 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: tromey, jan.kratochvil, gdb-patches
On 06/27/2013 12:32 PM, Pedro Alves wrote:
> On 06/27/2013 09:43 AM, Mircea Gherzan wrote:
>> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
>>
>> * common/agent.c: Conditionally include unistd.h.
>>
>> gdbserver/
>> * hostio.c: Conditionally include unistd.h and define PATH_MAX
>> if unistd.h is not available.
>> * tracepoint.h: Conditionally include unistd.h.
>
> Hmm, I've discussed this PATH_MAX issue before.
> I think we should pull in the unistd and pathmax modules from
> gnulib. In hostio.c, we should cap the max path len to the max
> of PATH_MAX (if defined, it won't on the Hurd), and the packet buffer
> size. Let me post a series for that.
Posted at:
http://sourceware.org/ml/gdb-patches/2013-06/msg00838.html
Could you give it a try?
--
Pedro Alves
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/7] gdbserver, common: conditionally include the unistd.h
2013-06-27 19:19 ` Pedro Alves
@ 2013-06-28 15:16 ` Mircea Gherzan
2013-06-28 18:26 ` Pedro Alves
0 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-28 15:16 UTC (permalink / raw)
To: Pedro Alves; +Cc: tromey, jan.kratochvil, gdb-patches
On 27.06.2013 20:58, Pedro Alves wrote:
> On 06/27/2013 12:32 PM, Pedro Alves wrote:
>> On 06/27/2013 09:43 AM, Mircea Gherzan wrote:
>>> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
>>>
>>> * common/agent.c: Conditionally include unistd.h.
>>>
>>> gdbserver/
>>> * hostio.c: Conditionally include unistd.h and define PATH_MAX
>>> if unistd.h is not available.
>>> * tracepoint.h: Conditionally include unistd.h.
>>
>> Hmm, I've discussed this PATH_MAX issue before.
>> I think we should pull in the unistd and pathmax modules from
>> gnulib. In hostio.c, we should cap the max path len to the max
>> of PATH_MAX (if defined, it won't on the Hurd), and the packet buffer
>> size. Let me post a series for that.
>
> Posted at:
>
> http://sourceware.org/ml/gdb-patches/2013-06/msg00838.html
>
> Could you give it a try?
Work fine in my case, thanks! Please commit it so I can rebase my series
on top of it.
Mircea
--
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/7] gdbserver, common: conditionally include the unistd.h
2013-06-28 15:16 ` Mircea Gherzan
@ 2013-06-28 18:26 ` Pedro Alves
2013-07-01 11:32 ` Pedro Alves
0 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2013-06-28 18:26 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: tromey, jan.kratochvil, gdb-patches
On 06/28/2013 04:11 PM, Mircea Gherzan wrote:
> On 27.06.2013 20:58, Pedro Alves wrote:
>> On 06/27/2013 12:32 PM, Pedro Alves wrote:
>>> On 06/27/2013 09:43 AM, Mircea Gherzan wrote:
>>>> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
>>>>
>>>> * common/agent.c: Conditionally include unistd.h.
>>>>
>>>> gdbserver/
>>>> * hostio.c: Conditionally include unistd.h and define PATH_MAX
>>>> if unistd.h is not available.
>>>> * tracepoint.h: Conditionally include unistd.h.
>>>
>>> Hmm, I've discussed this PATH_MAX issue before.
>>> I think we should pull in the unistd and pathmax modules from
>>> gnulib. In hostio.c, we should cap the max path len to the max
>>> of PATH_MAX (if defined, it won't on the Hurd), and the packet buffer
>>> size. Let me post a series for that.
>>
>> Posted at:
>>
>> http://sourceware.org/ml/gdb-patches/2013-06/msg00838.html
>>
>> Could you give it a try?
>
> Work fine in my case, thanks!
Excellent!
> Please commit it so I can rebase my series on top of it.
I'll apply this Monday. (I'm about to end my day, so I'd prefer not
rushing this in Friday evening, and leave the tree broken for the
weekend in case I don't get to park in front of the computer.)
Meanwhile, you could rebase on the branch I pushed to github, if
you're using git.
--
Pedro Alves
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 4/7] gdbserver: conditionally include sys/param.h and sys/time.h
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
` (2 preceding siblings ...)
2013-06-27 8:44 ` [PATCH 1/7] gdbserver, common: conditionally include the unistd.h Mircea Gherzan
@ 2013-06-27 8:44 ` Mircea Gherzan
2013-06-28 16:34 ` Tom Tromey
2013-06-27 8:44 ` [PATCH 6/7] common: add an alternative implementation for xstrvprintf Mircea Gherzan
` (2 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 8:44 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
gdbserver/
* configure.ac (AC_CHECK_HEADERS): Append sys/param.h and
sys/time.h.
* configure: Rebuild.
* config.in: Rebuild.
* event-loop.c: Use HAVE_SYS_TIME_H.
* tracepoint.c: Use HAVE_SYS_TIME_H.
* remote-utils.c: Use HAVE_SYS_TIME_H.
* win32-low.c: Use HAVE_SYS_PARAM_H.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/gdbserver/config.in | 6 ++++++
gdb/gdbserver/configure | 2 +-
gdb/gdbserver/configure.ac | 2 +-
gdb/gdbserver/event-loop.c | 2 ++
gdb/gdbserver/remote-utils.c | 2 ++
gdb/gdbserver/tracepoint.c | 2 ++
gdb/gdbserver/win32-low.c | 2 ++
7 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index dada2fb..4a5a51d 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -184,6 +184,9 @@
*/
#undef HAVE_SYS_NDIR_H
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
/* Define to 1 if you have the <sys/procfs.h> header file. */
#undef HAVE_SYS_PROCFS_H
@@ -196,6 +199,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index b87fedb..5df8fe3 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -4781,7 +4781,7 @@ $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach
cd "$ac_popdir"
-for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h thread_db.h linux/elf.h stdlib.h unistd.h errno.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h linux/perf_event.h
+for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h thread_db.h linux/elf.h stdlib.h unistd.h errno.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h linux/perf_event.h sys/time.h sys/param.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index b9928d7..8142e91 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -69,7 +69,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
errno.h fcntl.h signal.h sys/file.h malloc.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h dnl
- linux/perf_event.h)
+ linux/perf_event.h sys/time.h sys/param.h)
AC_CHECK_FUNCS(pread pwrite pread64 readlink fdwalk pipe2)
AC_REPLACE_FUNCS(vasprintf vsnprintf)
diff --git a/gdb/gdbserver/event-loop.c b/gdb/gdbserver/event-loop.c
index 9e172a9..579f256 100644
--- a/gdb/gdbserver/event-loop.c
+++ b/gdb/gdbserver/event-loop.c
@@ -23,7 +23,9 @@
#include <sys/types.h>
#include <string.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#ifdef USE_WIN32API
#include <windows.h>
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 3f055cf..51de426 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -50,7 +50,9 @@
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 392f84b..fbb9451 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -25,7 +25,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include <stddef.h>
#include <inttypes.h>
#include <stdint.h>
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index d1caa73..1365efe 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -32,7 +32,9 @@
#include <imagehlp.h>
#include <tlhelp32.h>
#include <psapi.h>
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
#include <process.h>
#ifndef USE_WIN32API
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 4/7] gdbserver: conditionally include sys/param.h and sys/time.h
2013-06-27 8:44 ` [PATCH 4/7] gdbserver: conditionally include sys/param.h and sys/time.h Mircea Gherzan
@ 2013-06-28 16:34 ` Tom Tromey
2013-07-02 14:46 ` Mircea Gherzan
0 siblings, 1 reply; 20+ messages in thread
From: Tom Tromey @ 2013-06-28 16:34 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: palves, jan.kratochvil, gdb-patches
>>>>> "Mircea" == Mircea Gherzan <mircea.gherzan@intel.com> writes:
Mircea> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
Mircea> * configure.ac (AC_CHECK_HEADERS): Append sys/param.h and
Mircea> sys/time.h.
I think the sys/param.h bit is fixed by Pedro's series.
For sys/time.h, what if we import the gnulib module instead?
Tom
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/7] gdbserver: conditionally include sys/param.h and sys/time.h
2013-06-28 16:34 ` Tom Tromey
@ 2013-07-02 14:46 ` Mircea Gherzan
0 siblings, 0 replies; 20+ messages in thread
From: Mircea Gherzan @ 2013-07-02 14:46 UTC (permalink / raw)
To: Tom Tromey; +Cc: palves, jan.kratochvil, gdb-patches
On 28.06.2013 18:04, Tom Tromey wrote:
>>>>>> "Mircea" == Mircea Gherzan <mircea.gherzan@intel.com> writes:
>
> Mircea> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
> Mircea> * configure.ac (AC_CHECK_HEADERS): Append sys/param.h and
> Mircea> sys/time.h.
>
> I think the sys/param.h bit is fixed by Pedro's series.
>
> For sys/time.h, what if we import the gnulib module instead?
It does the job. Please see "[PATCH v2 4/4] gnulib: import the sys_time
and vasprintf modules" that I've sent out yesterday.
Thanks,
--
Mircea Gherzan
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 6/7] common: add an alternative implementation for xstrvprintf
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
` (3 preceding siblings ...)
2013-06-27 8:44 ` [PATCH 4/7] gdbserver: conditionally include sys/param.h and sys/time.h Mircea Gherzan
@ 2013-06-27 8:44 ` Mircea Gherzan
2013-07-29 19:16 ` Tom Tromey
2013-06-27 8:45 ` [PATCH 7/7] gdbserver: add fallback implementation for memmem Mircea Gherzan
2013-06-27 11:32 ` [PATCH 5/7] gdbserver, win32: fix some function typedefs Mircea Gherzan
6 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 8:44 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
The vasprintf(), used by the current implementation, is a GNU extension.
2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
* configure.ac (AC_CHECK_FUNCS): Add vasprintf.
* config.in: Rebuild.
* configure: Rebuild.
* common/common-utils.c (xstrvprintf): Add an alternative
implementation that uses vsnprintf.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/common/common-utils.c | 30 ++++++++++++++++++++++++++++++
gdb/config.in | 3 +++
gdb/configure | 2 +-
gdb/configure.ac | 2 +-
4 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c
index 4204abf..e4f1fda 100644
--- a/gdb/common/common-utils.c
+++ b/gdb/common/common-utils.c
@@ -123,6 +123,8 @@ xstrprintf (const char *format, ...)
return ret;
}
+#ifdef HAVE_VASPRINTF
+
char *
xstrvprintf (const char *format, va_list ap)
{
@@ -138,6 +140,34 @@ xstrvprintf (const char *format, va_list ap)
return ret;
}
+#else
+
+char *
+xstrvprintf (const char *format, va_list ap)
+{
+ char *buf;
+ int size;
+ size_t format_len;
+
+ format_len = strlen (format);
+ buf = xmalloc (format_len + 1);
+ size = vsnprintf (buf, format_len + 1, format, ap);
+
+ if (size > (int)format_len)
+ {
+ /* The original size might not be enough. */
+ buf = xrealloc (buf, size + 1);
+ size = vsnprintf (buf, size + 1, format, ap);
+ }
+
+ if (size < 0)
+ internal_error (__FILE__, __LINE__, _("vsnprintf call failed"));
+
+ return buf;
+}
+
+#endif
+
int
xsnprintf (char *str, size_t size, const char *format, ...)
{
diff --git a/gdb/config.in b/gdb/config.in
index 7cd22e3..78e4534 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -554,6 +554,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK
diff --git a/gdb/configure b/gdb/configure
index 383d634..003e591 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -10178,7 +10178,7 @@ for ac_func in canonicalize_file_name realpath getrusage getuid getgid \
sigaction sigprocmask sigsetmask socketpair syscall \
ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
setrlimit getrlimit posix_madvise waitpid lstat \
- fdwalk pipe2
+ fdwalk pipe2 vasprintf
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 46a97bd..ffd790f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1180,7 +1180,7 @@ AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid getgid \
sigaction sigprocmask sigsetmask socketpair syscall \
ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
setrlimit getrlimit posix_madvise waitpid lstat \
- fdwalk pipe2])
+ fdwalk pipe2 vasprintf])
AM_LANGINFO_CODESET
# Check the return and argument types of ptrace. No canned test for
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 6/7] common: add an alternative implementation for xstrvprintf
2013-06-27 8:44 ` [PATCH 6/7] common: add an alternative implementation for xstrvprintf Mircea Gherzan
@ 2013-07-29 19:16 ` Tom Tromey
0 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2013-07-29 19:16 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: palves, jan.kratochvil, gdb-patches
>>>>> "Mircea" == Mircea Gherzan <mircea.gherzan@intel.com> writes:
Mircea> The vasprintf(), used by the current implementation, is a GNU extension.
Mircea> 2013-06-25 Mircea Gherzan <mircea.gherzan@intel.com>
Mircea> * configure.ac (AC_CHECK_FUNCS): Add vasprintf.
Mircea> * config.in: Rebuild.
Mircea> * configure: Rebuild.
Mircea> * common/common-utils.c (xstrvprintf): Add an alternative
Mircea> implementation that uses vsnprintf.
I suppose this is a problem for gdbserver, but not gdb? Since I would
assume that the latter pulls in the libiberty vasprintf instead.
If it is a problem for gdb, then I think more investigation is needed.
Either way the gdbserver configury needs an update.
I really should resurrect common.m4 ...
Tom
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 7/7] gdbserver: add fallback implementation for memmem
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
` (4 preceding siblings ...)
2013-06-27 8:44 ` [PATCH 6/7] common: add an alternative implementation for xstrvprintf Mircea Gherzan
@ 2013-06-27 8:45 ` Mircea Gherzan
2013-06-27 19:27 ` Pedro Alves
2013-06-27 11:32 ` [PATCH 5/7] gdbserver, win32: fix some function typedefs Mircea Gherzan
6 siblings, 1 reply; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 8:45 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
The memmem() function is a GNU extension.
2013-06-26 Mircea Gherzan <mircea.gherzan@intel.com>
gdbserver/
* configure.ac (AC_CHECK_FUNCS): Add memmem.
* configure: Rebuild.
* config.in: Rebuild.
* server.c (memmem): New function, included only if it's not
already provided by the system.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/gdbserver/config.in | 3 +++
gdb/gdbserver/configure | 2 +-
gdb/gdbserver/configure.ac | 2 +-
gdb/gdbserver/server.c | 23 +++++++++++++++++++++++
4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 4a5a51d..5ed56c3 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -97,6 +97,9 @@
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
+/* Define to 1 if you have the `memmem' function. */
+#undef HAVE_MEMMEM
+
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 5df8fe3..874a899 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -4795,7 +4795,7 @@ fi
done
-for ac_func in pread pwrite pread64 readlink fdwalk pipe2
+for ac_func in pread pwrite pread64 readlink fdwalk pipe2 memmem
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 8142e91..7cbc6ea 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -70,7 +70,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h dnl
linux/perf_event.h sys/time.h sys/param.h)
-AC_CHECK_FUNCS(pread pwrite pread64 readlink fdwalk pipe2)
+AC_CHECK_FUNCS(pread pwrite pread64 readlink fdwalk pipe2 memmem)
AC_REPLACE_FUNCS(vasprintf vsnprintf)
# Check for UST
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 4a1d1dc..99c2229 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -761,6 +761,29 @@ gdb_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
}
}
+#ifndef HAVE_MEMMEM
+
+/* Find the NEEDLE in the HAYSTACK and return its position. */
+
+static void *
+memmem (const void *haystack, size_t haystack_len, const void *needle,
+ size_t needle_len)
+{
+ size_t i;
+ const gdb_byte *p;
+
+ for (i = 0; i <= haystack_len - needle_len; i++)
+ {
+ p = (gdb_byte *)haystack + i;
+ if (memcmp (p, needle, needle_len) == 0)
+ return p;
+ }
+
+ return NULL;
+}
+
+#endif
+
/* Subroutine of handle_search_memory to simplify it. */
static int
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 7/7] gdbserver: add fallback implementation for memmem
2013-06-27 8:45 ` [PATCH 7/7] gdbserver: add fallback implementation for memmem Mircea Gherzan
@ 2013-06-27 19:27 ` Pedro Alves
2013-06-28 15:18 ` Mircea Gherzan
0 siblings, 1 reply; 20+ messages in thread
From: Pedro Alves @ 2013-06-27 19:27 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: tromey, jan.kratochvil, gdb-patches
I'll review the rest of the series later, but ...
On 06/27/2013 09:43 AM, Mircea Gherzan wrote:
> The memmem() function is a GNU extension.
>
> 2013-06-26 Mircea Gherzan <mircea.gherzan@intel.com>
>
> gdbserver/
>
> * configure.ac (AC_CHECK_FUNCS): Add memmem.
> * configure: Rebuild.
> * config.in: Rebuild.
> * server.c (memmem): New function, included only if it's not
> already provided by the system.
We already pull in a fallback memmem from gnulib. You need
to figure out why that isn't working for you.
--
Pedro Alves
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] gdbserver: add fallback implementation for memmem
2013-06-27 19:27 ` Pedro Alves
@ 2013-06-28 15:18 ` Mircea Gherzan
0 siblings, 0 replies; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-28 15:18 UTC (permalink / raw)
To: Pedro Alves; +Cc: tromey, jan.kratochvil, gdb-patches
On 27.06.2013 21:20, Pedro Alves wrote:
> I'll review the rest of the series later, but ...
>
> On 06/27/2013 09:43 AM, Mircea Gherzan wrote:
>> The memmem() function is a GNU extension.
>>
>> 2013-06-26 Mircea Gherzan <mircea.gherzan@intel.com>
>>
>> gdbserver/
>>
>> * configure.ac (AC_CHECK_FUNCS): Add memmem.
>> * configure: Rebuild.
>> * config.in: Rebuild.
>> * server.c (memmem): New function, included only if it's not
>> already provided by the system.
>
> We already pull in a fallback memmem from gnulib. You need
> to figure out why that isn't working for you.
Thanks for pointing this out. Will remove this patch from the series.
Mircea
--
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 5/7] gdbserver, win32: fix some function typedefs
2013-06-27 8:44 [PATCH 0/7] increase the portability of the gdbserver code Mircea Gherzan
` (5 preceding siblings ...)
2013-06-27 8:45 ` [PATCH 7/7] gdbserver: add fallback implementation for memmem Mircea Gherzan
@ 2013-06-27 11:32 ` Mircea Gherzan
6 siblings, 0 replies; 20+ messages in thread
From: Mircea Gherzan @ 2013-06-27 11:32 UTC (permalink / raw)
To: tromey, palves, jan.kratochvil; +Cc: gdb-patches, Mircea Gherzan
2013-05-25 Mircea Gherzan <mircea.gherzan@intel.com>
gdbserver/
* win32-low.c (winapi_DebugActiveProcessStop): Move the WINAPI
attribute inside the parentheses.
(winapi_DebugSetProcessKillOnExit): Ditto.
(winapi_DebugBreakProcess): Ditto.
(winapi_GenerateConsoleCtrlEvent): Ditto.
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
---
gdb/gdbserver/win32-low.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 1365efe..309bd9a 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -93,10 +93,10 @@ const struct target_desc *win32_tdesc;
#define NUM_REGS (the_low_target.num_regs)
-typedef BOOL WINAPI (*winapi_DebugActiveProcessStop) (DWORD dwProcessId);
-typedef BOOL WINAPI (*winapi_DebugSetProcessKillOnExit) (BOOL KillOnExit);
-typedef BOOL WINAPI (*winapi_DebugBreakProcess) (HANDLE);
-typedef BOOL WINAPI (*winapi_GenerateConsoleCtrlEvent) (DWORD, DWORD);
+typedef BOOL (WINAPI *winapi_DebugActiveProcessStop) (DWORD dwProcessId);
+typedef BOOL (WINAPI *winapi_DebugSetProcessKillOnExit) (BOOL KillOnExit);
+typedef BOOL (WINAPI *winapi_DebugBreakProcess) (HANDLE);
+typedef BOOL (WINAPI *winapi_GenerateConsoleCtrlEvent) (DWORD, DWORD);
static void win32_resume (struct thread_resume *resume_info, size_t n);
--
1.7.12.4
^ permalink raw reply [flat|nested] 20+ messages in thread