• R/O
  • HTTP
  • SSH
  • HTTPS

提交列表

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


users/palves/cxx-eliminate-cleanups
RSS
Rev. 时间 作者
3d4ed53 users/palves/cxx-eliminate-cleanups 2016-11-17 12:10:00 Pedro Alves

Eliminate make_cleanup_ui_file_delete

And now that ui_file_as_string is in, let's eliminate it. :-)

Makes ui_file a real C++ hierarchy. mem_fileopen is replaced with a
new string_file class that is treated as a value class created on the
stack. This alone eliminates most make_cleanup_ui_file_delete calls,
and, simplifies code a whole lot (diffstat shows almost 1k loc
dropped.)

string_file has a string() method that gives you a direct reference to
the internal std::string. This is what replaces old (well, new)
ui_file_as_string, which used to alway return a new copy of the same
data the stream had inside.. With direct access via a writable
reference, we can instead move the string out of the string_stream.

Note I needed a tweak on scoped_restore. That one should probably be
split out to a separate patch.

This exposed the need to make use of gnulib namespace support.
Otherwise, making use of read/write/printf/puts/etc symbol names will
clash on systems where gnulib replaces those functions, due to
'#define foo rpl_foo'.

05c10af 2016-11-17 12:10:00 Pedro Alves

Eliminate gdb/common/gdb_sys_time.h

No longer necessary.

81ffd1b 2016-11-17 12:08:18 Pedro Alves

Use gnulib's C++ namespace support

In the default "C" mode, gnulib's replacements are called rpl_foo, and
then gnulib creates defines that rewire the replaced symbols, like:

#define printf rpl_printf
#define open rpl_open
#define close rpl_close
...

This is a bad idea in C++. It prevents use of such symbols as class
methods, in other namespaces, etc.. C++'s standard libraries #undef's
C macro-like functions for the same reason (it's required by the C++
standard, I believe). So redefining these symbols as macros likely
causes conflicts with C++ system headers. See example of example that
here <https://sourceware.org/ml/gdb-patches/2016-11/msg00156.html>,
though in that case the culprit was Python.

gnulib has an way to address this, by putting the replacements in some
namespace instead, and avoiding use of macros to create the
replacements. See:
https://www.gnu.org/software/gnulib/manual/html_node/A-C_002b_002b-namespace-for-gnulib.html

This patch makes GDB use that feature. The namespace is enabled in
common-defs.h, with:

--- c/gdb/common/common-defs.h
+++ w/gdb/common/common-defs.h
@@ -20,6 +20,8 @@
#ifndef COMMON_DEFS_H
#define COMMON_DEFS_H

+#define GNULIB_NAMESPACE gnulib

The rest of the patch is just using "gnulib::" where necessary. Any
spot needing adjustment is found by the compiler, with:

.../src/gdb/cli/cli-dump.c: In function ‘void restore_binary_file(const char*, callback_data*)’:
.../src/gdb/cli/cli-dump.c:554:13: error: call to ‘fread’ declared with attribute warning: The symbol ::fread refers to the system function. Use gnulib::fread instead. [-Werror]
if (fread (buf.get (), 1, len, file) != len)
^
cc1plus: all warnings being treated as errors

We can choose any namespace name. "gnulib" just looks natural to me.
Maybe picking a 3-letter namespace, like "glb" [1] would make it
easier to switch some symbol to the std namespace later on, without
requiring reindenting multi-line statements/expressions. OTOH, being
explicit is probably clearer. So dunno.

This may look a bit ugly at first. (that's how it looked to me). But
it grows on you over time. :-) For one, it makes is much more obvious
where the replacements are being used. And, it's likely that as we
C++fy more code, many of these gnulib:: references disappear behind
higher-level abstractions. So nowadays I see this explicitness as a
good thing, actually.

6fd203a 2016-11-17 12:08:18 Pedro Alves

For flex: define YY_FATAL_ERROR, rename fprintf -> parser_fprintf

Switching GDB to make use of gnulib's C++ namespace support mode
revealed these direct uses of fprintf in the Ada lexer:

In file included from ..../src/gdb/ada-exp.y:731:0:
ada-lex.c: In function ‘void yy_fatal_error(const char*)’:
ada-lex.c:2358:41: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
(void) fprintf( stderr, "%s\n", msg );
^

yy_fatal_error looks like this:

static void yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}

We can define YY_FATAL_ERROR to override that default implementation.
However, the default implementation is still unconditionally compiled
in, so we need to handle that fprintf somehow. Thinking that there
might be other calls introduced in other flex version or other lexers,
I chose to replace fprintf calls with sed, like we already do with
malloc/free/etc.

gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* Makefile.in (.l.c): Also rename fprintf to parser_fprintf.
* yy-remap.h (YY_FATAL_ERROR): Define.

71d6ca3 2016-11-17 12:08:18 Pedro Alves

gdb/c-exp.y: fprintf -> parser_fprintf

Switching GDB to make use of gnulib's C++ namespace support mode
revealed these direct uses of fprintf in the C parser, where
parser_fprintf should be used to handle rewiring to gdb_stderr:

..../src/gdb/c-exp.y: In function ‘void c_print_token(FILE*, int, YYSTYPE)’:
..../src/gdb/c-exp.y:3220:45: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
pulongest (value.typed_val_int.val));
^
..../src/gdb/c-exp.y:3231:62: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
fprintf (file, "tsval<type=%d, %s>", value.tsval.type, copy);
^
..../src/gdb/c-exp.y:3237:57: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
fprintf (file, "sval<%s>", copy_name (value.sval));
^
..../src/gdb/c-exp.y:3243:39: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
copy_name (value.tsym.stoken));
^
..../src/gdb/c-exp.y:3254:39: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
value.ssym.is_a_field_of_this);
^
..../src/gdb/c-exp.y:3258:70: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror]
fprintf (file, "bval<%s>", host_address_to_string (value.bval));
^

gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* c-exp.y (c_print_token): Use parser_fprintf instead of fprintf.

00a902b 2016-11-17 12:08:18 Pedro Alves

gdb/ctf.c: Get rid of mkdir redefinition

Making GDB use gnulib's C++ namespace support shows this build error
on mingw:

../../src/gdb/ctf.c: In function 'void ctf_start(trace_file_writer*, const char*)':
../../src/gdb/ctf.c:309:46: error: no match for call to '(const gnulib::_gl_mkdir_wrapper) (const char*&)'
#define mkdir(pathname, mode) mkdir (pathname)
^
../../src/gdb/ctf.c:327:15: note: in expansion of macro 'mkdir'
if (gnulib::mkdir (dirname, hmode) && errno != EEXIST)
^
../../src/gdb/ctf.c:309:46: note: candidate: gnulib::_gl_mkdir_wrapper::type {aka int (*)(const char*, short unsigned int)} <conversion>
#define mkdir(pathname, mode) mkdir (pathname)
^
../../src/gdb/ctf.c:327:15: note: in expansion of macro 'mkdir'
if (gnulib::mkdir (dirname, hmode) && errno != EEXIST)
^
../../src/gdb/ctf.c:309:46: note: candidate expects 3 arguments, 2 provided
#define mkdir(pathname, mode) mkdir (pathname)
^
../../src/gdb/ctf.c:327:15: note: in expansion of macro 'mkdir'
if (gnulib::mkdir (dirname, hmode) && errno != EEXIST)
^

The problem is the mkdir define. We can just remove it, since
gnulib's replacement already takes care of this prototype difference
detail.

3b9af7e 2016-11-17 11:40:30 Pedro Alves

Use C++11 std::chrono

The best intro I know of to std::chrono is the standard proposal for
the standard itself:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm

std::chrono is really great. You should read that.

This patch:

- Avoids problems with gnulib's C++ namespace support and the timeval
passed to gnulib::gettimeofday being incompatible with libiberty's
timeval_sub/timeval_add.

gettimeofday (&prompt_ended, NULL);
timeval_sub (&prompt_delta, &prompt_ended, &prompt_started);
timeval_add (&prompt_for_continue_wait_time,
&prompt_for_continue_wait_time, &prompt_delta);

That's currently handled by simply not using gnulib's gettimeofday
(common/gdb_sys_time.h), but that won't work with gnulib's C++
namespace support, because that adds warnings for uses of
::gettimeofday, which are hard errors with -Werror.

- gettimeofday is not monotonic, so we shouldn't be using it for
performance tracking, anyway... Or put another way, for anything
other than displaying a date/time to the user.

~~~
The time returned by gettimeofday() is affected by
discontinuous jumps in the system time (e.g., if the system
administrator manually changes the system time). If you need a
monotonically increasing clock, see clock_gettime(2).
~~~

C++11's std::chrono has a monotonic clock exactly for such purposes
(std::chrono::steady_clock), and in addition is a very nice API to
use, designed to catch problems at compile time, and to offload factor
conversions (minutes <-> seconds <-> microseconds, etc.) to the
library (often at compile time). It also supports the obvious <,>,-,+
operators, making code comparing timestamps or computing time
differences more natural.

Another nice thing with std::chrono is that it's super easy to create
extra clocks that follow the same interface, and leverage all the
std::chrono::duration/ratio niceties. There's an example in the patch
(the new cpu_time_clock.h file), where I've added a couple clocks to
count user/system cpu time.

fa3a130 2016-11-17 09:59:43 Pedro Alves

gdb/ada-lang.c: one malloc -> unique_ptr<[]>

Switching gdb to use gnulib's C++ namespace mode reveals we're calling
malloc instead of xmalloc here:

..../src/gdb/ada-lang.c: In function ‘value* ada_value_primitive_packed_val(value*, const gdb_byte*, long int, int, int, type*)’:
..../src/gdb/ada-lang.c:2592:50: error: call to ‘malloc’ declared with attribute warning: The symbol ::malloc refers to the system function. Use gnulib::malloc instead. [-Werror]
staging = (gdb_byte *) malloc (staging_len);
^

We're unconditionaly using the result afterwards -- so it's not a case
of gracefully handling huge allocations.

Since we want to get rid of all cleanups, fix this by switching to
new[] and unique_ptr<[]> instead, while at it.

Regtested on Fedora 23.

gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* ada-lang.c (ada_value_primitive_packed_val): Use unique_ptr and
new gdb_byte[] instead of malloc and cleanups.

19f1935 2016-11-17 09:23:17 Pedro Alves

gdb/tracepoint.c: Don't use printf_vma

I noticed that bfd's printf_vma prints to stdout directly:

bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)

This is a bad idea in gdb, where we should use
gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.

Eliminate uses of sprintf_vma too while at it.

Tested on Fedora 23, w/ gdbserver.

gdb/ChangeLog:
2016-11-17 Pedro Alves <palves@redhat.com>

* tracepoint.c (collection_list::add_memrange): Add gdbarch
parameter. Use paddress instead of printf_vma. Adjust recursive
calls.
(collection_list::stringify): Use paddress and phex_nz instead of
sprintf_vma. Adjust add_memrange call.
* tracepoint.h (collection_list::add_memrange): Add gdbarch
parameter.

fa98319 2016-11-17 09:00:19 GDB Administrator

Automatic date update in version.in

256ae5d 2016-11-17 03:42:24 Kevin Buettner

Stash frame id of current frame before stashing frame id for previous frame

This patch ensures that the frame id for the current frame is stashed
before that of the previous frame (to the current frame).

First, it should be noted that the frame id for the current frame is
not stashed by get_current_frame(). The current frame's frame id is
lazily computed and stashed via calls to get_frame_id(). However,
it's possible for get_prev_frame() to be called without first stashing
the current frame.

The frame stash is used not only to speed up frame lookups, but
also to detect cycles. When attempting to compute the frame id
for a "previous" frame (in get_prev_frame_if_no_cycle), a cycle
is detected if the computed frame id is already in the stash.

If it should happen that a previous frame id is stashed which should
represent a cycle for the current frame, then an assertion failure
will trigger should get_frame_id() be later called to determine
the frame id for the current frame.

As of late 2016, with the "Tweak meaning of VALUE_FRAME_ID" patch in
place, this actually occurs when running the
gdb.dwarf2/dw2-dup-frame.exp test. While attempting to generate a
backtrace, the python frame filter code is invoked, leading to
frame_info_to_frame_object() (in python/py-frame.c) being called.
That function will potentially call get_prev_frame() before
get_frame_id() is called. The call to get_prev_frame() can eventually
end up in get_prev_frame_if_no_cycle() which, in turn, calls
compute_frame_id(), after which the frame id is stashed for the
previous frame.

If the frame id for the current frame is stashed, the cycle detection
code (which relies on the frame stash) in get_prev_frame_if_no_cycle()
will be triggered for a cycle starting with the current frame. If the
current frame's id is not stashed, the cycle detecting code can't
operate as designed. Instead, when get_frame_id() is called on the
current frame at some later point, the current frame's id will found
to be already in the stash, triggering an assertion failure.

Below is an in depth examination of the failure which lead to this change.
I've shortened pathnames for brevity and readability.

Here's the portion of the log file showing the failure/internal error:

(gdb) break stop_frame
Breakpoint 1 at 0x40059a: file dw2-dup-frame.c, line 22.
(gdb) run
Starting program: testsuite/outputs/gdb.dwarf2/dw2-dup-frame/dw2-dup-frame

Breakpoint 1, stop_frame () at dw2-dup-frame.c:22
22 }
(gdb) bt
gdb/frame.c:544: internal-error: frame_id get_frame_id(frame_info*): Assertion `stashed' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
FAIL: gdb.dwarf2/dw2-dup-frame.exp: backtrace from stop_frame (GDB internal error)

Here's a partial backtrace from the internal error, showing the frames
which I think are relevant, plus several extra to provide context:

#0 internal_error (
file=0x932b98 "gdb/frame.c", line=544,
fmt=0x932b20 "%s: Assertion `%s' failed.")
at gdb/common/errors.c:54
#1 0x000000000072207e in get_frame_id (fi=0xe5a760)
at gdb/frame.c:544
#2 0x00000000004eb50d in frame_info_to_frame_object (frame=0xe5a760)
at gdb/python/py-frame.c:390
#3 0x00000000004ef5be in bootstrap_python_frame_filters (frame=0xe5a760,
frame_low=0, frame_high=-1)
at gdb/python/py-framefilter.c:1453
#4 0x00000000004ef7a9 in gdbpy_apply_frame_filter (
extlang=0x8857e0 <extension_language_python>, frame=0xe5a760, flags=7,
args_type=CLI_SCALAR_VALUES, out=0xf6def0, frame_low=0, frame_high=-1)
at gdb/python/py-framefilter.c:1548
#5 0x00000000005f2c5a in apply_ext_lang_frame_filter (frame=0xe5a760,
flags=7, args_type=CLI_SCALAR_VALUES, out=0xf6def0, frame_low=0,
frame_high=-1)
at gdb/extension.c:572
#6 0x00000000005ea896 in backtrace_command_1 (count_exp=0x0, show_locals=0,
no_filters=0, from_tty=1)
at gdb/stack.c:1834

Examination of the code in frame_info_to_frame_object(), which is in
python/py-frame.c, is key to understanding this problem:

if (get_prev_frame (frame) == NULL
&& get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
&& get_next_frame (frame) != NULL)
{
frame_obj->frame_id = get_frame_id (get_next_frame (frame));
frame_obj->frame_id_is_next = 1;
}
else
{
frame_obj->frame_id = get_frame_id (frame);
frame_obj->frame_id_is_next = 0;
}

I will first note that the frame id for frame has not been computed yet. (This
was verified by placing a breakpoint on compute_frame_id().)

The call to get_prev_frame() causes the the frame id to (eventually) be
computed for the previous frame. Here's a backtrace showing how we
get there:

#0 compute_frame_id (fi=0x10e2810)
at gdb/frame.c:496
#1 0x0000000000724a67 in get_prev_frame_if_no_cycle (this_frame=0xe5a760)
at gdb/frame.c:1871
#2 0x0000000000725136 in get_prev_frame_always_1 (this_frame=0xe5a760)
at gdb/frame.c:2045
#3 0x000000000072516b in get_prev_frame_always (this_frame=0xe5a760)
at gdb/frame.c:2061
#4 0x000000000072570f in get_prev_frame (this_frame=0xe5a760)
at gdb/frame.c:2303
#5 0x00000000004eb471 in frame_info_to_frame_object (frame=0xe5a760)
at gdb/python/py-frame.c:381

For this particular case, we end up in the else clause of the code above
which calls get_frame_id (frame). It's at this point that the frame id
for frame is computed. Again, here's a backtrace:

#0 compute_frame_id (fi=0xe5a760)
at gdb/frame.c:496
#1 0x000000000072203d in get_frame_id (fi=0xe5a760)
at gdb/frame.c:539
#2 0x00000000004eb50d in frame_info_to_frame_object (frame=0xe5a760)
at gdb/python/py-frame.c:390

The test in question, dw2-dup-frame.exp, deliberately creates a broken
(cyclic) stack. So, in this instance, the frame id for the prev
`frame' will be the same as that for `frame'. But that particular
frame id ended up in the stash during the previous frame operation.
When, just a few lines later, we compute the frame id for `frame', the
id in question is already in the stash, thus triggering the assertion
failure.

I considered two other solutions to solving this problem:

We could prevent get_prev_frame() from being called before
get_frame_id() in frame_info_to_frame_object(). (See above for the
snippet of code where this happens.) A call to get_frame_id (frame)
could be placed ahead of that code snippet above. I have tested this
approach and, while it does work, I can't be certain that
get_prev_frame() isn't called ahead of stashing the current frame
somewhere else in GDB, but in a less obvious way.

Another approach is to stash the current frame's id by calling
get_frame_id() in get_current_frame(). This approach is conceptually
simpler, but when importing a python unwinder, has the unwelcome side
effect of causing the unwinder to be called during import.

A cleaner looking fix would be to place this code after code
corresponding to the "Don't compute the frame id of the current frame
yet..." comment in get_prev_frame_if_no_cycle(). Sadly, this does not
work though; by the time we get to this point, the frame state for the
prev frame has been modified just enough to cause an internal error to
occur when attempting to compute the (current) frame id for inline
frames. (The unexpected failure count increases by roughly 130
failures.) Therefore, I decided to place it as early as possible
in get_prev_frame().

gdb/ChangeLog:

* frame.c (get_prev_frame): Stash frame id for current frame
prior to computing frame id for previous frame.

33cc7d3 2016-11-17 03:38:44 Kevin Buettner

Make gdb.PendingFrame.read_register handle "user" registers.

The C function, pending_framepy_read_register(), which implements
the python interface gdb.PendingFrame.read_register does not handle
the so called "user" registers like "pc". An assertion error is
triggered due to the user registers having numbers larger than or
equal to gdbarch_num_regs(gdbarch).

With the VALUE_FRAME_ID tweak in place, the call to
get_frame_register_value() can simply be replaced by a call to
value_of_register(), which handles both real registers as well as the
user registers.

gdb/ChangeLog:

* python/py-unwind.c (pending_framepy_read_register): Use
value_of_register() instead of get_frame_register_value().

41b56fe 2016-11-17 03:38:19 Kevin Buettner

Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID

The VALUE_FRAME_ID macro provides access to a member in struct value
that's used to hold the frame id that's used when determining a
register's value or when assigning to a register. The underlying
member has a long and obscure name. I won't refer to it here, but
will simply refer to VALUE_FRAME_ID as if it's the struct value member
instead of being a convenient macro.

At the moment, without this patch in place, VALUE_FRAME_ID is set in
value_of_register_lazy() and several other locations to hold the frame
id of the frame passed to those functions.

VALUE_FRAME_ID is used in the lval_register case of
value_fetch_lazy(). To fetch the register's value, it calls
get_frame_register_value() which, in turn, calls
frame_unwind_register_value() with frame->next.

A python based unwinder may wish to determine the value of a register
or evaluate an expression containing a register. When it does this,
value_fetch_lazy() will be called under some circumstances. It will
attempt to determine the frame id associated with the frame passed to
it. In so doing, it will end up back in the frame sniffer of the very
same python unwinder that's attempting to learn the value of a
register as part of the sniffing operation. This recursion is not
desirable.

As noted above, when value_fetch_lazy() wants to fetch a register's
value, it does so (indirectly) by unwinding from frame->next.

With this in mind, a solution suggests itself: Change VALUE_FRAME_ID
to hold the frame id associated with the next frame. Then, when it
comes time to obtain the value associated with the register, we can
simply unwind from the frame corresponding to the frame id stored in
VALUE_FRAME_ID. This neatly avoids the python unwinder recursion
problem by changing when the "next" operation occurs. Instead of the
"next" operation occuring when the register value is fetched, it
occurs earlier on when assigning a frame id to VALUE_FRAME_ID.
(Thanks to Pedro for this suggestion.)

This patch implements this idea.

It builds on the patch "Distinguish sentinel frame from null frame".
Without that work in place, it's necessary to check for null_id at
several places and then obtain the sentinel frame.

It also renames most occurences of VALUE_FRAME_ID to
VALUE_NEXT_FRAME_ID to reflect the new meaning of this field.

There are several uses of VALUE_FRAME_ID which were not changed. In
each case, the original meaning of VALUE_FRAME_ID is required to get
correct results. In all but one of these uses, either
put_frame_register_bytes() or get_frame_register_bytes() is being
called with the frame value obtained from VALUE_FRAME_ID. Both of
these functions perform some unwinding by performing a "->next"
operation on the frame passed to it. If we were to use the new
VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next"
operations, which is not what we want.

The VALUE_FRAME_ID macro has been redefined in terms of
VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id,
providing this id as the value of the macro.

gdb/ChangeLog:

* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
comment. Create new VALUE_FRAME_ID which is defined in terms of
VALUE_NEXT_FRAME_ID.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
* dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c,
valarith.c, valops.c, value.c: Adjust nearly all occurences of
VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those
which did not change.
* value.c (struct value): Rename frame_id field to next_frame_id.
Update comment.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
(value_fetch_lazy): Call frame_unwind_register_value()
instead of get_frame_register_value().
* frame.c (get_prev_frame_id_by_id): New function.
* frame.h (get_prev_frame_id_by_id): Declare.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make
VALUE_NEXT_FRAME_ID refer to the next frame.
* findvar.c (value_of_register_lazy): Likewise.
(default_value_from_register): Likewise.
(value_from_register): Likewise.
* frame_unwind.c (frame_unwind_got_optimized): Likewise.
* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
* value.h (VALUE_FRAME_ID): Update comment describing this macro.

df433d3 2016-11-17 03:37:11 Kevin Buettner

Distinguish sentinel frame from null frame.

This patch replaces the `current_frame' static global in frame.c with
`sentinel_frame'. It also makes the sentinel frame id unique and
different from the null frame.

By itself, there is not much point to this patch, but it makes
the code cleaner for the VALUE_FRAME_ID changes in another patch.
Since we now allow "navigation" to the sentinel frame, it removes
the necessity of adding special cases to other parts of GDB.

Note that a new function, get_next_frame_sentinel_okay, is introduced
in this patch. It will be used by the VALUE_FRAME_ID changes that
I've made.

Thanks to Pedro Alves for this suggestion.

gdb/ChangeLog:

* frame.h (enum frame_id_stack_status): Add FID_STACK_SENTINEL.
(struct frame_id): Increase number of bits required for storing
stack status to 3 from 2.
(sentinel_frame_id): New declaration.
(get_next_frame_sentinel_okay): Declare.
(frame_find_by_id_sentinel_okay): Declare.
* frame.c (current_frame): Rename this static global to...
(sentinel_frame): ...this static global, which has also been
moved an earlier location in the file.
(fprint_frame_id): Add case for sentinel frame id.
(get_frame_id): Return early for sentinel frame.
(sentinel_frame_id): Define.
(frame_find_by_id): Add case for sentinel_frame_id.
(create_sentinel_frame): Use sentinel_frame_id for this_id.value
instead of null_frame_id.
(get_current_frame): Add local declaration for `current_frame'.
Remove local declaration for `sentinel_frame.'
(get_next_frame_sentinel_okay): New function.
(reinit_frame_cache): Use `sentinel_frame' in place of
`current_frame'.

1a2f3d7 2016-11-17 03:37:11 Kevin Buettner

Extend test gdb.python/py-recurse-unwind.exp

This patch modifies the unwinder (sniffer) defined in
py-recurse-unwind.py so that, depending upon the value of one of its
class variables, it will take different paths through the code,
testing different functionality.

The original test attempted to obtain the value of an undefined
symbol.

This somewhat expanded test checks to see if 'pc' can be read via
gdb.PendingFrame.read_register() and also via gdb.parse_and_eval().

gdb/testsuite/ChangeLog:

* gdb.python/py-recurse-unwind.c (main): Add loop.
* gdb.python/py-recurse-unwind.py (TestUnwinder): Add calls
to read_register() and gdb.parse_and_eval(). Make each code
call a separate case that can be individually tested.
* gdb.python/py-recurse-unwind.exp (cont_and_backtrace): New
proc. Call cont_and_backtrace for each of the code paths that
we want to test in the unwinder.

4cb771f 2016-11-16 19:41:46 Senthil Kumar Selvaraj

Fix PR20789 - relaxation with negative valued diff relocs

Fix issues with diff relocs that have a negative value
i.e. sym2 - sym1 where sym2 is lesser than sym1.

The assembler generates a diff reloc with symbol as start of section
and addend as sym2 offset, and encodes assembly time difference at
the reloc offset.

The existing relaxation logic adjusts addends if the relaxed insn lies
between symbol and addend. That doesn't work for diff relocs where
sym2 is less than sym1 *and* the relaxed insn happens to be between
sym2 and sym1.

Fix the problems by

1. Using signed handling of the difference value (bfd_signed_vma instead
of bfd_vma, bfd_{get,set}_signed_xxx instead of bfd_{get,set}_xxx).

2. Not assuming sym2 is bigger than sym1. It instead computes the actual
addresses and sets the lower and higher addresses as start and end
addresses respectively and then sees if insn is between start and end.

3. Creating a new function elf32_avr_adjust_reloc_if_spans_insn to
centralize reloc adjustment, and ensuring diff relocs get adjusted
correctly even if their sym + addend doesn't overlap a relaxed insn.

It also removes a redundant variable did_pad. It is never set if
did_shrink is TRUE, and the code does a early return if did_shrink is
FALSE.

bfd/ChangeLog

2016-11-15 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>

PR ld/20789
* bfd/elf32-avr.c (elf32_avr_adjust_diff_reloc_value): Do signed
manipulation of diff value, and don't assume sym2 is less than sym1.
(elf32_avr_adjust_reloc_if_spans_insn): New function.
(elf32_avr_relax_delete_bytes): Use elf32_avr_adjust_diff_reloc_value,
and remove redundant did_pad.

ld/ChangeLog

2016-11-15 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>

PR ld/20789
* ld/testsuite/ld-avr/pr20789.d: New test.
* ld/testsuite/ld-avr/pr20789.s: New test.

ff7ba33 2016-11-16 09:00:20 GDB Administrator

Automatic date update in version.in

4c62b19 2016-11-16 08:22:37 Pedro Alves

gdb: update gnulib to pull in C++ namespace support fixes

I've been experimenting with making use of gnulib's C++ namespace support:

https://www.gnu.org/software/gnulib/manual/html_node/A-C_002b_002b-namespace-for-gnulib.html

That stumbled on a few gnulib issues, which I've fixed upstream:

[PATCH] Fix gnulib C++ namespace support and std::frexp
https://lists.gnu.org/archive/html/bug-gnulib/2016-11/msg00039.html

[PATCH] Fix real-floating argument functions in C++ mode
https://lists.gnu.org/archive/html/bug-gnulib/2016-11/msg00049.html

[PATCH] Avoid having GNULIB_NAMESPACE::func always inject references to rpl_func
https://lists.gnu.org/archive/html/bug-gnulib/2016-11/msg00040.html

[PATCH] C++: "#define timeval rpl_timeval" -> typedef in GNULIB_NAMESPACE
https://lists.gnu.org/archive/html/bug-gnulib/2016-11/msg00058.html

This merge pulls those in.

gdb/ChangeLog:
2016-11-15 Pedro Alves <palves@redhat.com>

* gnulib/update-gnulib.sh (GNULIB_COMMIT_SHA1): Set to
38237baf99386101934cd93278023aa4ae523ec0.
* gnulib/configure, gnulib/config.in: Regenerate.
* gnulib/import/Makefile.am: Regenerate.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/canonicalize-lgpl.c: Update.
* gnulib/import/extra/snippet/c++defs.h: Update.
* gnulib/import/m4/stdint.m4: Update.
* gnulib/import/m4/stdlib_h.m4: Update.
* gnulib/import/math.in.h: Update.
* gnulib/import/stdlib.in.h: Update.
* gnulib/import/sys_time.in.h: Update.

5cc8c73 2016-11-16 04:54:21 Pedro Alves

Delete gdb::unique_ptr/gdb::move

Now that we require C++11 and all uses of gdb::unique_ptr and
gdb::move are gone, let's remove their definitions...

With my lazy hat on, I repurposed the header for "generally useful
unique_ptr specializations", and left gdb::unique_xmalloc_ptr in
there. Not sure whether we it'd be better move it out of the gdb
namespace or leave it be. I left it because it's less work and avoids
disrupting yet-unmerged patches that use it.

gdb/ChangeLog:
2016-11-15 Pedro Alves <palves@redhat.com>

* common/common-defs.h: Update comment.
* common/gdb_unique_ptr.h: Update header comment and copyright
year.
(gdb::unique_ptr, gdb::move): Delete.

b22e99f 2016-11-16 04:54:21 Pedro Alves

gdb::{unique_ptr,move} -> std::{unique_ptr,move}

Now that we require C++11, use std::unique_ptr and std::move directly.

gdb/ChangeLog:
2016-11-15 Pedro Alves <palves@redhat.com>

* ada-lang.c (create_excep_cond_exprs): Use std::move instead of
gdb::move.
* break-catch-throw.c (handle_gnu_v3_exceptions): Use
std::unique_ptr instead of gdb::unique_ptr.
* breakpoint.c (watch_command_1): Use std::move instead of
gdb::move.
* cli/cli-dump.c (dump_memory_to_file, restore_binary_file): Use
std::unique_ptr instead of gdb::unique_ptr.
* dtrace-probe.c (dtrace_process_dof_probe): Use std::move instead
of gdb::move.
* elfread.c (elf_read_minimal_symbols): Use std::unique_ptr
instead of gdb::unique_ptr.
* mi/mi-main.c (mi_cmd_data_read_memory): Use std::unique_ptr
instead of gdb::unique_ptr.
* parse.c (parse_expression_for_completion): Use std::move instead
of gdb::move.
* printcmd.c (display_command): std::move instead of gdb::move.

b7f38fd 2016-11-16 04:52:03 Andreas Arnez

bitfield-parent-optimized-out: Fix struct definition

The "struct S" type in bitfield-parent-optimized-out.exp is declared to
have a size of 4 bytes but to hold two 4-byte members: an int-based
bitfield and a 4-byte int. Also, both members have the same
data_member_location 2, causing them to overlap and to reach 2 bytes
beyond the structure's boundary.

This is fixed by increasing the structure size to 8 and setting the
first and second member's data_member_location to 0 and 4, respectively.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/bitfield-parent-optimized-out.exp: Fix DWARF code for
the definition of struct S.

93ca393 2016-11-16 00:41:27 Nick Clifton

Fix SPARC relocations generated for the .eh_frame section.

PR gas/20803
* config/tc-sparc.c (cons_fix_new_sparc): Use unaligned relocs in
the .eh_frame section.

32ce946 2016-11-15 09:00:20 GDB Administrator

Automatic date update in version.in

9d734ef 2016-11-15 03:13:03 H.J. Lu

Also check GOT PLT for R_X86_64_PLTOFF64

Since "-z now" replaces PLT with GOT PLT, we should also check GOT PLT
for R_X86_64_PLTOFF64 relocation.

bfd/

PR ld/20800
* elf64-x86-64.c (elf_x86_64_relocate_section): Also check
plt_got.offset for R_X86_64_PLTOFF64.

ld/

PR ld/20800
* testsuite/ld-x86-64/pr20800a.S: New file.
* testsuite/ld-x86-64/pr20800b.S: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/20800 test.

35fd2dd 2016-11-15 01:30:45 Rudy

Generate correct hint value for IDATA6.

PR binutils/20814
* dlltool.c (struct export): Remove hint field.
(make_one_lib_file): Store the ordinal value for IDATA6 not the
hint.
(gen_lib_file): Delete reference to hint field.
(mangle_defs): Delete computation of hint field.

db58b37 2016-11-14 18:15:42 Markus Metzger

btrace: read entire aux buffer

The data_head of a perf event data buffer grows indefinitely. Users are
expected to compute data_head % data_size to find the location inside the perf
event data buffer.

The aux_head of a perf event aux buffer wraps around and always stays within the
perf event aux buffer.

Well, at least that's the behaviour for BTS and PT - where BTS uses the data
buffer and PT the aux buffer.

GDB does not read beyond data_head or aux_head. This is OK for BTS but wrong
for PT. It causes only a portion of the trace to be considered by GDB. In the
extreme case, the buffer may appear (almost) empty.

Thanks to Tim Wiederhake <tim.wiederhake@intel.com> for reporting the anomaly.

Change it to read the entire aux buffer for PT. The buffer is initially zero so
any extra zeroes we read before aux_head wraps around the first time will be
ignored when searching for the first PSB packet in order to synchronize onto the
trace stream.

gdb/
* nat/linux-btrace.c (perf_event_read): Allow data_head < size.
* nat/linux-btrace.c (perf_event_read_all): Do not adjust size.

Change-Id: If4f8049a2080a5f16f336309450b32a3eb1e3ec9

80bb340 2016-11-14 17:59:23 Nick Clifton

lexsup.c (parse_args): Add break at end of default case.

63f2433 2016-11-14 17:44:17 Nick Clifton

Fix typo "Faal through" should be "Fall through".

29df152 2016-11-14 09:00:19 GDB Administrator

Automatic date update in version.in

b612f41 2016-11-13 22:11:44 Anthony Green

add missing ChangeLog entry