Fixes a set of errors like:
../../src/gdb/symfile-debug.c: In function ‘int debug_qf_map_symtabs_matching_filename(objfile*, const char*, const char*, int (*)(symtab*, void*), void*)’:
../../src/gdb/symfile-debug.c:137:39: error: invalid conversion from ‘int (*)(symtab*, void*)’ to ‘const void*’ [-fpermissive]
host_address_to_string (callback),
^
Note this has to work with data and function pointers. In C++11 we
may perhaps do something a bit safer, but we're not there yet, and I
don't think it really matters. For now just always do a simple
C-style cast in host_address_to_string itself. No point in adding a
void * cast to each and every caller.
gdb/ChangeLog:
2015-10-27 Pedro Alves <palves@redhat.com>
* common/print-utils.c (host_address_to_string): Rename to ...
(host_address_to_string_1): ... this.
* common/print-utils.h (host_address_to_string): Reimplement as
wrapper around host_address_to_string_1.
* utils.c (gdb_print_host_address): Rename to ...
(gdb_print_host_address_1): ... this.
* utils.h (gdb_print_host_address): Reimplement as wrapper macro
around host_address_to_string_1.
Years ago, these functions used to return errno/EIO. Later, through a
series of changes that intended to remove native/remote differences,
they ended up returning a target_xfer_status in disguise.
Unlike target_xfer_partial&co, the point of target_read_memory&co is
to either fully succeed or fail. On error, they always return
TARGET_XFER_E_IO. So there's no real point in casting the return of
target_read_memory to a target_xfer_status to pass it to memory_error.
Instead, it results in clearer code to simply decouple
target_read_memory&co's return from target_xfer_status.
This fixes build errors like this in C++ mode:
../../src/gdb/corefile.c: In function ‘void read_stack(CORE_ADDR, gdb_byte*, ssize_t)’:
../../src/gdb/corefile.c:276:34: error: invalid conversion from ‘int’ to ‘target_xfer_status’ [-fpermissive]
memory_error (status, memaddr);
^
../../src/gdb/corefile.c:216:1: error: initializing argument 1 of ‘void memory_error(target_xfer_status, CORE_ADDR)’ [-fpermissive]
gdb/ChangeLog:
2015-10-27 Pedro Alves <palves@redhat.com>
* alpha-tdep.c (alpha_read_insn): Always pass TARGET_XFER_E_IO to
memory_error. Rename local 'status' to 'res'.
* c-lang.c (c_get_string): Always pass TARGET_XFER_E_IO to
memory_error.
* corefile.c (read_stack, read_code, write_memory): Always pass
TARGET_XFER_E_IO to memory_error.
* disasm.c (dis_asm_memory_error): Always pass TARGET_XFER_E_IO to
memory_error. Rename parameter 'status' to 'err'.
(dump_insns): Rename local 'status' to 'err'.
* mips-tdep.c (mips_fetch_instruction): Rename parameter 'statusp'
to 'errp'. Rename local 'status' to 'err'. Always pass
TARGET_XFER_E_IO to memory_error.
(mips_breakpoint_from_pc): Rename local 'status' to 'err'.
* target.c (target_read_memory, target_read_raw_memory)
(target_read_stack, target_read_code, target_write_memory)
(target_write_raw_memory): Return -1 on error instead of
TARGET_XFER_E_IO.
* valprint.c (val_print_string): Rename local 'errcode' to 'err'.
Always pass TARGET_XFER_E_IO to memory_error. Update comment.
The documentation of gdbscm_with_guile says that it returns a statically
allocated string (IOW, a const char *). We can reflect that in its
return value type, and get rid of C++ build errors.
Initially fixes:
/home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c: In function ‘void* gdbscm_disasm_read_memory_worker(void*)’:
/home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c:93:12: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
return "seek error";
gdb/ChangeLog:
* guile/guile-internal.h (gdbscm_with_guile): Change return
types to const char *.
* guile/scm-safe-call.c (gdbscm_with_guile): Likewise.
(struct c_data) <func>: Likewise.
(struct c_data) <result>: Change type to const char *.
(scscm_eval_scheme_string): Change return type to
const char *.
(scscm_source_scheme_script): Likewise.
(gdbscm_safe_eval_string): Change type of result variable to
const char * and remove cast.
(gdbscm_safe_source_script): Likewise.
* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker):
Change return type to const char *.
(gdbscm_disasm_read_memory): Change type of status to
const char *.
openp's return is documented as:
~~~
If a file is found, return the descriptor.
Otherwise, return -1, with errno set for the last name we tried to open. */
~~~
By inspection, I noticed that there are function calls after the ones
that first set errno, and those may clobber errno. It's safer to save
errno when see an open fail, and restore it on exit.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-10-27 Pedro Alves <palves@redhat.com>
* source.c (openp): New local 'last_errno'. Use it to
save/restore errno.
This patch was taken directly from Pedro's branch.
Right now, SET_INT32_FIELD is used to set enum fields. This works in C,
but not C++. Therefore, define the new SET_ENUM_FIELD, which casts the
value to the right enum type.
gdb/ChangeLog:
* ctf.c (SET_ENUM_FIELD): New macro.
(ctf_read_status): Use it.
(ctf_read_tp): Use it.
There is a handful of calls to
scm_dynwind_begin (0);
where the parameter is an enum, scm_t_dynwind_flags. In C++, we have no
choice but to add an explicit cast, since there is no enum value that
represents 0 (no flags set).
gdb/ChangeLog:
* guile/scm-breakpoint.c (gdbscm_set_breakpoint_stop_x): Add
scm_t_dynwind_flags casts.
* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
* guile/scm-ports.c (gdbscm_open_memory): Likewise.
* guile/scm-value.c (gdbscm_value_to_string): Likewise.
This patch was taken directly from Pedro's branch.
ax_simple is used to append an agent expression operator to an agent
expression string. Therefore, it takes an enum agent_op as input.
There is an instance where it's called to append a raw byte, unrelated
to the enum. It makes the build fail in C++ mode.
This patch introduces ax_raw_byte for that purpose and uses it.
gdb/ChangeLog:
* ax.h (ax_raw_byte): New declaration.
* ax-general.c (ax_raw_byte): New function.
(ax_simple): Use ax_raw_byte.
* ax-gdb.c (gen_printf): Likewise.
The assignment requires a cast in C++. We only use this macro for
vectors of chars, so adding (char *) diretly will do for now.
gdb/ChangeLog:
* ada-lang.h (GROW_VECT): Add cast.
Running ./gdb.ada/access_to_packed_array.exp ...
ERROR: tcl error sourcing ./gdb.ada/access_to_packed_array.exp.
ERROR: extra characters after close-quote
while executing
"gdb_test "print pack.a" "\\(0 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\)")"
(file "./gdb.ada/access_to_packed_array.exp" line 29)
invoked from within
"source ./gdb.ada/access_to_packed_array.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source ./gdb.ada/access_to_packed_array.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
Unrelated to the typos I have changed the print expectations s/"x"/" = x"/
as for example expectation "3" should not match " = 43".
2015-10-27 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.ada/access_to_packed_array.exp: Fix typos erroring the testfile.
Fixes some errors in C++ build.
gdb/ChangeLog:
* target.c (memory_xfer_partial): Change type of buf to gdb_byte
pointer.
(simple_search_memory): Cast return of memmem.
gdb/ChangeLog:
PR python/18938
* cli/cli-cmds (source_script_fron_sctream): New arg file_to_open.
All callers updated.
gdb/testsuite/ChangeLog:
* gdb.python/python.exp: Add test for symlink from .py file to .notpy
file.
gdb/ChangeLog:
* nat/linux-nat.h (__SIGRTMIN): Move here from gdbserver/linux-low.c.
gdb/gdbserver/ChangeLog:
* linux-low.c (__SIGRTMIN): Move to nat/linux-nat.h.
gdb/ChangeLog:
* common/gdb_wait.h (W_STOPCODE): Define, moved here from
gdbserver/linux-low.c.
(WSETSTOP): Simplify.
gdb/gdbserver/ChangeLog:
* linux-low.c (W_STOPCODE): Moved to common/gdb_wait.h.
gdb/ChangeLog:
* linux-thread-db.c (find_new_threads_callback): Cast ti.ti_tid to
unsigned long for debug_printf.
(thread_db_pid_to_str): Ditto.
gdb/gdbserver/ChangeLog:
* thread-db.c (find_one_thread): Cast ti.ti_tid to unsigned long
for debug_printf.
(attach_thread, find_new_threads_callback): Ditto.
As pointed out by Pedro, it's clearer to do it this way. We can trust
that scm_mode_bits won't try to modify our string, even though it takes
a non-const char *.
gdb/ChangeLog:
* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Do not pass a
local char array to scm_mode_bits, use a cast instead.
I stumbled upon this while doing some cxx-conversion work. Since the
x-family alloc functions throw on failure, it is useless to test their
result for failure. The else branch of != NULL is basically dead code.
I changed the type of element_block_ptr to struct tui_win_element, which
seems obvious (this is actually what raised the flag, casting the result
of xmalloc to struct tui_win_element* wouldn't work).
gdb/ChangeLog:
* tui/tui-data.c (tui_alloc_content): Don't check xmalloc
result. Change type of element_block_ptr. Change allocation to
use XNEWVEC.
I caught a segmentation fault while running gdb.reverse/sigall-reverse.exp,
in a mingw32 GDB, in this code path. It boils down to the code trying to
strlen () a NULL pointer. I tracked things down and it looks like
record_full_message_wrapper_safe is the only offender.
gdb/ChangeLog:
2015-10-26 Luis Machado <lgustavo@codesourcery.com>
* record-full.c (record_full_message_wrapper_safe): Pass empty string to
catch_errors call instead of NULL.
ioscm_make_gdb_stdio_port passes const char pointers (literal strings) to
scm_mode_bits, which takes a non-const char pointer. Ideally, we would
change scm_mode_bits to take a const char pointer, but it's not part of
an API we control.
Instead, it's easy enough to build the string to pass to scm_mode_bits in
a (non-const) char array and pass that.
gdb/ChangeLog:
* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Pass non-const
char pointer to scm_mode_bits.
By having a local variable of type (const gdb_byte *), we can avoid adding
two casts.
gdb/ChangeLog:
* guile/scm-ports.c (gdbscm_memory_port_write): Declare new
"data" local variable and use it.
We currently pass integers as domain_enums to lookup_symbol. The
most obvious fix is to add casts there.
I first thought of changing the type of the domain variables to
domain_enum. However, because we pass a pointer to them to
gdbscm_parse_function_args, which expects them to be integers (because
of the format string), I don't think it would be correct. If the enum
does not have the same size as an int, gdbscm_parse_function_args could
write past the memory of domain, overwriting something else on the
stack.
gdb/ChangeLog:
* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
domain_enum cast.
(gdbscm_lookup_symbol): Likewise.
The (void *) casts make the build fail in C++ mode and are unnecessary.
gdb/ChangeLog:
* tui/tui-data.c (tui_add_to_source_windows): Remove void *
cast.
(tui_add_content_elements): Likewise.
A cast here is necessary, just as it's necessary in ps_pdwrite just
below. The type of buf can't be changed, since it's fixed in the ps_pd*
API.
gdb/ChangeLog:
* proc-service.c (ps_pdread): Add cast.
This:
valbuf = memcpy (buf, valbuf, len);
causes a build failure in C++, because memcpy returns the value of
"buf" as a void *. Instead of adding a cast, we can just do the
assignment separately.
gdb/ChangeLog:
* sparc64-tdep.c (sparc64_store_arguments): Split assignment of
valbuf.
Remove these (void *) casts, which cause a build failure in C++ mode.
gdb/ChangeLog:
* ia64-tdep.c (ia64_pseudo_register_write): Remove cast.
(ia64_push_dummy_call): Remove cast and change type of "to" to
array of gdb_byte.
This patch fixes the build that was broken by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html
It implements the sw_breakpoint_from_kind operation on these targets and removes
the calls to set_breakpoint_data.
Compiliation tested on win32.
Not tested : nto, spu.
gdb/gdbserver/ChangeLog:
* nto-low.c (nto_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
(initialize_low): Remove set_breakpoint_data call.
* spu-low.c (spu_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Iniitalize.
(initialize_low): Remove set_breakpoint_data call.
* win32-low.c (win32_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
(initialize_low): Remove set_breakpoint_data call.
This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro
so that all targets can easily use it.
This allows the breakpoint_kind_from_pc operation to be left unimplemented in
targets that do not need it.
This is preparation to fix the win32/nto/spu build that was broken by this
patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html
No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}
gdb/gdbserver/ChangeLog:
* linux-low.c (default_breakpoint_kind_from_pc): Move to target.c.
* mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc.
* target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c
* target.h (target_breakpoint_kind_from_pc): New macro.
This patch initialize dsd.insn_count, otherwise, it triggers the assert
below on testings we did recently.
gdb:
2015-10-23 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Set
dsd.insn_count to zero.
This patch fixes a regression introduced by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html
Tests : gdb.trace/trace-break.exp and gdb.trace/trace-mt.exp would fail on x86
with gdbserver-{native,extended}.
Before this patch, the breakpoint kind set by GDB with a Z packet and the one
set in the case of a tracepoint would be inconsistent on targets that did not
implement breakpoint_kind_from_pc. On x86 for example a breakpoint set by GDB
would have a kind of 1 but a breakpoint set by a tracepoint would have a kind of
0.
This created a missmatch when trying to insert a tracepoint and a breakpoint at
the same location. One of the two breakpoints would be removed with debug
message : "Inconsistent breakpoint kind".
This patch fixes the issue by changing the default 0 breakpoint kind to be
the size of the breakpoint according to sw_breakpoint_from_kind.
The default breakpoint kind must be the breakpoint length to keep consistency
between breakpoints set via GDB and the ones set internally by GDBServer.
No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}
gdb/gdbserver/ChangeLog:
* linux-low.c (default_breakpoint_kind_from_pc): New function.
(linux_breakpoint_kind_from_pc): Use default_breakpoint_kind_from_pc for
the default breakpoint kind.
Explation below based on what Joel wrote at:
https://sourceware.org/ml/gdb-patches/2015-10/msg00274.html
The merge async/sync code paths patch broke attaching on Windows.
This is what we observe, after attaching to any process. At first, it
seems like everything worked fine, since the process stops, and we get
the prompt back:
(gdb) att 3156
Attaching to program `C:\[...]\foo.exe', process 3156
[New Thread 3156.0xcd8]
[New Thread 3156.0xfe4]
0x7770000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
(gdb)
However, enter any commands at all, and GDB appears to be hanging.
For instance:
(gdb) set lang ada
[nothing happens]
Despite appearances, GDB is not reading from the prompt. It is
blocked waiting for an event from the inferior. And since our
inferior is stopped, there aren't going to be any events to read.
In chronological order, what happens is that windows_attach calls
do_initial_windows_stuff, which performs the inferior creation,
and repeatedly waits until we get the first SIGTRAP:
while (1)
{
stop_after_trap = 1;
wait_for_inferior ();
tp = inferior_thread ();
if (tp->suspend.stop_signal != GDB_SIGNAL_TRAP)
resume (tp->suspend.stop_signal);
else
break;
}
The call to wait_for_inferior triggers a call to do_target_wait to get
the event, followed by handle_inferior_event to process it. However,
because the first couple of events are "spurious" events, GDB resumes
the execution, and prepares the inferior to wait again:
case TARGET_WAITKIND_SPURIOUS:
[...]
resume (GDB_SIGNAL_0);
prepare_to_wait (ecs);
And prepare_to_wait just does...
ecs->wait_some_more = 1;
if (!target_is_async_p ())
mark_infrun_async_event_handler ();
... which as a result sets the infrun_async_event_handler "ready"
flag to 1.
We get a couple of spurious events before we get the initial SIGTRAP,
at which point we exit the "while (1)" loop above, after which we
reach the end of the attach_command, followed by the normal
end-of-command processing (normal_stop, bp handling, printing the GDB
prompt), back finally to the root of the event loop.
Notice that, at this point, nothing has unset the "ready" flag for the
infrun_async_event_handler. So, when another cycle of
gdb_do_one_event from the event loop, we eventually call
check_async_event_handlers, which finds that the infrun async event
handler is "ready", and therefore calls it's associated "proc"
callback, which does...
inferior_event_handler (INF_REG_EVENT, NULL);
... triggering a blocking call to target_wait, thus hanging forever.
The fix is to use windows_wait and windows_resume directly, similarly
to gdbserver. This will also allow getting rid of 'stop_after_trap'.
gdb/ChangeLog:
2015-10-22 Pedro Alves <palves@redhat.com>
* windows-nat.c (do_initial_windows_stuff): Rewrite loop using
windows_wait and windows_resume directly instead of
wait_for_inferior and resume.
XTREG is used with raw numbers, like:
...
XTREG( 78,312,32, 4, 4,0x02d7,0x0007,-2, 2,0x1000,excsave7, 0,0,0,0,0,0)
XTREG( 79,316, 8, 4, 4,0x02e0,0x0007,-2, 2,0x1000,cpenable, 0,0,0,0,0,0)
XTREG( 80,320,22, 4, 4,0x02e2,0x000b,-2, 2,0x1000,interrupt, 0,0,0,0,0,0)
XTREG( 81,324,22, 4, 4,0x02e2,0x000d,-2, 2,0x1000,intset, 0,0,0,0,0,0)
...
So just add the explicit cast to the macro.
In file included from /home/pedro/gdb/mygit/src/gdb/xtensa-config.c:25:0:
/home/pedro/gdb/mygit/src/gdb/xtensa-tdep.h:289:2: error: invalid conversion from ‘int’ to ‘call_abi_t’ [-fpermissive]
}
^
gdb/ChangeLog:
* xtensa-tdep.h (XTREG): Add casts.
(XTREG_END): Likewise.
Fixes this error:
/home/simark/src/binutils-gdb/gdb/solib-spu.c: In function ‘file_ptr spu_bfd_iovec_pread(bfd*, void*, void*, file_ptr, file_ptr)’:
/home/simark/src/binutils-gdb/gdb/solib-spu.c:299:55: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
ret = target_read_memory (addr + offset, buf, nbytes);
^
In file included from /home/simark/src/binutils-gdb/gdb/target.h:65:0,
from /home/simark/src/binutils-gdb/gdb/exec.h:23,
from /home/simark/src/binutils-gdb/gdb/gdbcore.h:29,
from /home/simark/src/binutils-gdb/gdb/solib-spu.c:23:
/home/simark/src/binutils-gdb/gdb/target/target.h:35:12: note: initializing argument 2 of ‘int target_read_memory(CORE_ADDR, gdb_byte*, ssize_t)’
extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
gdb/ChangeLog:
* solib-spu.c (spu_bfd_iovec_pread): Add (gdb_byte *) cast.
The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
to be a gdb_byte*, as usual. supply_32bit_reg and mips64_fill_gregset
do some more complicated things however, so it's safer just to add the
explicit cast and avoid changing the code too much.
gdb/ChangeLog:
* mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
buf to gdb_byte*.
(supply_32bit_reg): Add cast.
(mips64_fill_gregset): Likewise.