• R/O
  • HTTP
  • SSH
  • HTTPS

List of commits

Tags
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/interrupt-while-step-over-v1
RSS
Rev. Hora Autor
3bcc59a users/palves/interrupt-while-step-over-v1 2016-11-09 03:02:17 Pedro Alves

Fix PR18360 - internal error when using "interrupt -a"

If you do "interrupt -a" just while some thread is stepping over a
breakpoint, gdb trips on an internal error.

The test added by this patch manages to trigger this consistently by
spawning a few threads that are constantly tripping on a conditional
breakpoint whose condition always evaluates to false. With current
gdb, you get:

~~~
interrupt -a
.../src/gdb/inline-frame.c:343: internal-error: void skip_inline_frames(ptid_t): Assertion `find_inline_frame_state (ptid) == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=on: iter=0: interrupt -a (GDB internal error)
[...]
.../src/gdb/inline-frame.c:343: internal-error: void skip_inline_frames(ptid_t): Assertion `find_inline_frame_state (ptid) == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=off: iter=0: wait for stops (GDB internal error)
~~~

The assertion triggers because we're processing a stop for a thread
that had already stopped before and thus had already its inline-frame
state filled in.

Calling handle_inferior_event_1 directly within a
"thread_stop_requested" observer is something that I've wanted to get
rid of before, for being fragile. Nowadays, infrun is aware of
threads with pending events, so we can use that instead, and let the
normal fetch_inferior_event -> handle_inferior_event code path handle
the forced stop.

The change to finish_step_over is necessary because sometimes a thread
that was told to PTRACE_SINGLESTEP reports back a SIGSTOP instead of a
SIGTRAP (i.e., we tell it to single-step, and then interrupt it quick
enough that on the kernel side the thread dequeues the SIGTOP before
ever having had a chance of executing the instruction to be stepped).
SIGSTOP gets translated to a GDB_SIGNAL_0. And then finish_step_over
would miss calling clear_step_over_info, and thus miss restarting the
other threads (which in this case of threads with pending events,
means setting their "resumed" flag, so their pending events can be
consumed).

And now that we always restart threads in finish_step_over, we no
longer need to do that in handle_signal_stop.

Tested on x86_64 Fedora 23, native and gdbserver.

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

PR gdb/18360
* infrun.c (start_step_over, do_target_resume, resume)
(restart_threads): Assert we're not resuming a thread that is
meant to be stopped.
(infrun_thread_stop_requested_callback): Delete.
(infrun_thread_stop_requested): If the thread is internally
stopped, queue a pending stop event and clear the thread's
inline-frame state.
(finish_step_over): Clear step over info unconditionally.
(handle_signal_stop): If the user had interrupted the event
thread, consider the stop a random signal.
(handle_signal_stop)<signal arrived while stepping over
breakpoint>: Don't restart threads here.
(stop_waiting): Don't clear step-over info here.

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

PR gdb/18360
* gdb.threads/interrupt-while-step-over.c: New file.
* gdb.threads/interrupt-while-step-over.exp: New file.

7353f24 2016-11-09 01:10:57 Tom Tromey

Fix py-value.exp failure on Python 3

I happened to notice that one test in py-value.exp did not work
properly with Python 3. This patch fixes the problem.

2016-11-08 Tom Tromey <tom@tromey.com>

* gdb.python/py-value.exp (test_value_creation): Make "long" test
depend on Python 2.

30a7bb8 2016-11-09 01:10:57 Tom Tromey

Fix some error-handling bugs in python frame filters

While writing a Python frame filter, I found a few bugs in the current
frame filter code. In particular:

* One spot converts a Python long to a CORE_ADDR using PyLong_AsLong.
However, this can fail on overflow. I changed this to use
get_addr_from_python.

* Another spot is doing the same but with PyLong_AsUnsignedLongLong; I
changed this as well just for consistency.

* Converting line numbers can print "-1" if conversion from long
fails. This isn't fatal but just a bit ugly.

I've included a test case for the first issue. The line number one
didn't seem important enough to bother with.

2016-11-08 Tom Tromey <tom@tromey.com>

* python/py-framefilter.c (py_print_frame): Use
get_addr_from_python. Check for errors when getting line number.

2016-11-08 Tom Tromey <tom@tromey.com>

* gdb.python/py-framefilter.py (ElidingFrameDecorator.address):
New method.

e8b24d9 2016-11-09 01:02:42 Yao Qi

Remove parameter valaddr from la_val_print

Nowadays, we pass both val and return value of
value_contents_for_printing (val) to la_val_print. The latter is
unnecessary. This patch removes the second parameter of la_val_print,
and get valaddr in each language's implementation by calling
value_contents_for_printing. Since value_contents_for_printing calls
value_fetch_lazy, I also make VAL non-const.

Note that
- I don't clean up the valaddr usages in each language's routines,
- I don't remove valaddr from apply_ext_lang_val_pretty_printer, and
extension language ops apply_val_pretty_printer.

They can be done in followup patches.

gdb:

2016-11-08 Yao Qi <yao.qi@linaro.org>

* ada-lang.h (ada_val_print): Remove second parameter. Remove
const from "struct value *".
* ada-valprint.c (print_field_values): Remove const from
"struct value *".
(val_print_packed_array_elements): Likewise.
(print_variant_part): Likewise.
(ada_val_print_string): Likewise.
(ada_val_print_gnat_array): Likewise.
(ada_val_print_ptr): Likewise.
(ada_val_print_num): Likewise.
(ada_val_print_enum): Likewise.
(ada_val_print_flt): Likewise.
(ada_val_print_union): Likewise.
(ada_val_print_struct_union): Likewise.
(ada_val_print_ref): Likewise.
(ada_val_print_1): Remove second parameter. Remove const from
"struct value *".
(ada_val_print): Likewise.
* c-lang.h (c_val_print): Likewise.
* c-valprint.c (c_val_print_array): Remove const from
"struct value *".
(c_val_print_ptr): Likewise.
(c_val_print_struct): Likewise.
(c_val_print_union): Likewise.
(c_val_print_int): Likewise.
(c_val_print_memberptr): Likewise.
(c_val_print): Remove second parameter. Remove const from
"struct value *". All callers updated.
* cp-valprint.c (cp_print_value): Remove const from
"struct value *".
(cp_print_value_fields): Likewise.
(c_val_print_value): Likewise.
* d-lang.h (d_val_print): Remove second parameter. Remove const
from "struct value *".
* d-valprint.c (dynamic_array_type): Likewise.
(d_val_print): Likewise.
* f-lang.h (f_val_print): Likewise.
* f-valprint.c (f_val_print): Likewise.
* go-lang.h (go_val_print): Likewise.
* go-valprint.c (print_go_string): Likewise.
(go_val_print): Likewise.
* language.c (unk_lang_val_print): Likewise.
* language.h (struct language_defn) <la_val_print>: Likewise.
Update comments.
(LA_VAL_PRINT): Remove.
* m2-lang.h (m2_val_print): Remove const from
"struct value *".
* m2-valprint.c (m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* p-lang.h (pascal_val_print): Remove second parameter. Remove
const from "struct value *".
(pascal_object_print_value_fields): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_value_fields): Likewise.
(pascal_object_print_value): Likewise.
* rust-lang.c (rust_get_disr_info): Likewise.
(val_print_struct): Likewise.
(rust_val_print): Likewise.
* valprint.c (generic_val_print_array): Likewise.
(generic_val_print_ptr): Likewise.
(generic_val_print_memberptr): Likewise.
(generic_val_print_ref): Likewise.
(generic_val_print_enum): Likewise.
(generic_val_print_flags): Likewise.
(generic_val_print_func): Likewise.
(generic_val_print_bool): Likewise.
(generic_val_print_int): Likewise.
(generic_val_print_char): Likewise.
(generic_val_print_float): Likewise.
(generic_val_print_decfloat): Likewise.
(generic_val_print_complex): Likewise.
(generic_val_print): Likewise.
(val_print): Likewise.
(common_val_print): Likewise.
(val_print_type_code_flags): Likewise.
(val_print_scalar_formatted): Likewise.
(val_print_array_elements): Likewise.
* valprint.h (val_print_array_elements): Update declaration.
(val_print_scalar_formatted): Likewise.
(generic_val_print): Likewise.
* value.h (val_print): Likewise.

cc977dc 2016-11-09 00:58:47 Yao Qi

Use get_frame_register_value instead of deprecated_frame_register_read

This patch calls get_frame_register_value instead of
deprecated_frame_register_read, so that we can pass
value_contents_for_printing to val_print. Both
get_frame_register_value and deprecated_frame_register_read call
frame_unwind_register_value indirectly, so no functionality is changed
by this patch.

gdb:

2016-11-08 Yao Qi <yao.qi@linaro.org>

* mt-tdep.c (mt_registers_info): Call
get_frame_register_value instead of
deprecated_frame_register_read.
* sh64-tdep.c (sh64_do_register): Likewise.

3cde5c4 2016-11-09 00:26:47 Pedro Alves

Eliminate agent_expr_p; VEC -> std::vector in struct bp_target_info

After the previous patch, we end up with these two types with quite
similar, and potentially confusing names:

typedef gdb::unique_ptr<agent_expr> agent_expr_up;

/* Pointer to an agent_expr structure. */
typedef struct agent_expr *agent_expr_p;

The latter is only necessary to put agent_expr pointers in VECs. So
just eliminate it and use std::vector instead.

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

* ax.h (agent_expr_p): Delete.
(DEF_VEC_P (agent_expr_p)): Delete.
* breakpoint.c (build_target_condition_list)
(build_target_command_list): Adjust to use of std::vector.
(bp_location_dtor): Remove now unnecessary VEC_free calls.
* breakpoint.h: Include <vector>.
(struct bp_target_info) <conditions, tcommands>: Now
std::vector's.
* remote.c (remote_add_target_side_condition): bp_tgt->conditions
is now a std::vector; adjust.
(remote_add_target_side_commands, remote_insert_breakpoint):
bp_tgt->tcommands is now a std::vector; adjust.

833177a 2016-11-09 00:26:47 Pedro Alves

'struct agent_expr *' -> unique_ptr<agent_expr>

This patch makes the gen_* functions return a unique_ptr instead of
raw pointer:

typedef gdb::unique_ptr<agent_expr> agent_expr_up;

and then adjusts the codebase throughout to stop using
make_cleanup_free_agent_expr.

The cond_bytecode and cmd_bytecode fields of struct bp_location are
owning pointers, so they're changed to be unique_ptr's instead of raw
pointers.

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

* ax-gdb.c (is_nontrivial_conversion): Use agent_expr_up.
(gen_trace_for_var, gen_trace_for_expr, gen_eval_for_expr)
(gen_trace_for_return_address, gen_printf): Use and return an
agent_expr_up. Don't use make_cleanup_free_agent_expr.
(agent_eval_command_one, maint_agent_printf_command): Use
agent_expr_up. Don't use make_cleanup_free_agent_expr.
* ax-gdb.h (gen_trace_for_expr, gen_trace_for_var)
(gen_trace_for_return_address, gen_eval_for_expr, gen_printf): Use
agent_expr_up.
* ax-general.c (new_agent_expr): Rename to ...
(agent_expr::agent_expr): ... this, and now a constructor.
(free_agent_expr): Rename to ...
(agent_expr::~agent_exp): ... this, and now a destructor.
(do_free_agent_expr_cleanup, make_cleanup_free_agent_expr):
Delete.
* ax.h (struct agent_expr): Add ctor/dtor.
(agent_expr_up): New typedef.
(new_agent_expr, free_agent_expr, make_cleanup_free_agent_expr):
Delete declarations.
* breakpoint.c (parse_cond_to_aexpr): Use and return an
agent_expr_up. Don't use make_cleanup_free_agent_expr.
(build_target_condition_list): Adjust to use agent_expr_up.
(parse_cmd_to_aexpr): Use and return an agent_expr_up. Don't use
make_cleanup_free_agent_expr.
(build_target_command_list): Adjust to use agent_expr_up.
(force_breakpoint_reinsertion): Adjust to use agent_expr_up.
(bp_location_dtor): Remove unnecessary free_agent_expr and xfree
calls.
* breakpoint.h (struct bp_target_info) <cond_bytecode,
cmd_bytecode>: Now agent_expr_up's.
* remote.c (remote_download_tracepoint): Adjust to use
agent_expr_up and remove use of make_cleanup_free_agent_expr.
* tracepoint.c (validate_actionline, collect_symbol): Adjust to
use agent_expr_up and remove uses of make_cleanup_free_agent_expr.
(collection_list::~collection_list): Call delete instead of
free_agent_expr.
(encode_actions_1): Adjust to use agent_expr_up and remove uses of
make_cleanup_free_agent_expr.
(add_aexpr): Change parameter type to agent_expr_up; Return a raw
agent_expr pointer.

2f408ec 2016-11-09 00:26:47 Pedro Alves

Use ui_file_as_string throughout more

This replaces most of the remaining ui_file_xstrdup calls with
ui_file_as_string calls. Whenever a call was replaced, that led to a
cascade of other necessary adjustments throughout, to make the code
use std::string instead of raw pointers. And then whenever I added a
std::string as member of a struct, I needed to adjust
allocation/destruction of said struct to use new/delete instead of
xmalloc/xfree.

The stopping point was once gdb built again. These doesn't seem to be
a way to reasonably split this out further.

Maybe-not-obvious changes:

- demangle_for_lookup returns a cleanup today. To get rid of that,
and avoid unnecessary string dupping/copying, this introduces a
demangle_result_storage type that the caller instantiates and
passes to demangle_for_lookup.

- Many methods returned a "char *" to indicate that the caller owns
the memory and must free it. Those are switched to return a
std::string instead. Methods that return a "view" into some
internal string return a "const char *" instead. I.e., we only
copy/allocate when necessary.

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

* ada-lang.c (ada_name_for_lookup, type_as_string): Use and return
std::string.
(type_as_string_and_cleanup): Delete.
(ada_lookup_struct_elt_type): Use type_as_string.
* ada-lang.h (ada_name_for_lookup): Now returns std::string.
* ada-varobj.c (ada_varobj_scalar_image): Return a std::string.
(ada_varobj_describe_child): Make 'child_name' and
'child_path_expr' parameters std::string pointers.
(ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child):
Likewise, and use string_printf.
(ada_varobj_describe_simple_array_child)
(ada_varobj_describe_child): Likewise.
(ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child)
(ada_varobj_get_value_image)
(ada_varobj_get_value_of_array_variable)
(ada_varobj_get_value_of_variable, ada_name_of_variable)
(ada_name_of_child, ada_path_expr_of_child)
(ada_value_of_variable): Now returns std::string. Use
string_printf.
(ada_value_of_child): Adjust.
* break-catch-throw.c (check_status_exception_catchpoint): Adjust
to use std::string.
* breakpoint.c (watch_command_1): Adjust to use std::string.
* c-lang.c (c_get_string): Adjust to use std::string.
* c-typeprint.c (print_name_maybe_canonical): Use std::string.
* c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string
operators.
(c_name_of_variable): Now returns a std::string.
(c_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(c_name_of_child, c_path_expr_of_child, c_value_of_variable)
(cplus_number_of_children): Adjust to use std::string and
string_printf.
(cplus_name_of_variable): Now returns a std::string.
(cplus_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(cplus_name_of_child, cplus_path_expr_of_child)
(cplus_value_of_variable): Now returns a std::string.
* cp-abi.c (cplus_typename_from_type_info): Return std::string.
* cp-abi.h (cplus_typename_from_type_info): Return std::string.
(struct cp_abi_ops) <get_typename_from_type_info>: Return
std::string.
* cp-support.c (inspect_type): Use std::string.
(cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs)
(cp_canonicalize_string): Return std::string and adjust.
* cp-support.h (cp_canonicalize_string)
(cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full):
Return std::string.
* dbxread.c (read_dbx_symtab): Use std::string.
* dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string.
* gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string.
* gnu-v3-abi.c (gnuv3_get_typeid): Use std::string.
(gnuv3_get_typename_from_type_info): Return a std::string and
adjust.
(gnuv3_get_type_from_type_info): Adjust to use std::string.
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
std::string.
* infcmd.c (print_return_value_1): Adjust to use std::string.
* linespec.c (find_linespec_symbols): Adjust to
demangle_for_lookup API change. Use std::string.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format)
(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
(mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, varobj_update_one): Adjust to use std::string.
* minsyms.c (lookup_minimal_symbol): Use std::string.
* python/py-varobj.c (py_varobj_iter_next): Use new instead of
XNEW. vitem->name is a std::string now, adjust.
* rust-exp.y (convert_ast_to_type, convert_name): Adjust to use
std::string.
* stabsread.c (define_symbol): Adjust to use std::string.
* symtab.c (demangle_for_lookup): Now returns 'const char *'. Add
a demangle_result_storage parameter. Use it for storage.
(lookup_symbol_in_language)
(lookup_symbol_in_objfile_from_linkage_name): Adjust to new
demangle_for_lookup API.
* symtab.h (struct demangle_result_storage): New type.
(demangle_for_lookup): Now returns 'const char *'. Add a
demangle_result_storage parameter.
* typeprint.c (type_to_string): Return std::string and use
ui_file_as_string.
* value.h (type_to_string): Change return type to std::string.
* varobj-iter.h (struct varobj_item) <name>: Now a std::string.
(varobj_iter_delete): Use delete instead of xfree.
* varobj.c (create_child): Return std::string instead of char * in
output parameter.
(name_of_variable, name_of_child, my_value_of_variable): Return
std::string instead of char *.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
Adjust to std::string fields.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression): Return a std::string.
(varobj_list_children): Adjust to use std::string.
(varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
Adjust to std::string fields.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Change type of 'expression' parameter to
std::string. Use std::string.
(install_new_value): Use std::string.
(delete_variable_1): Adjust to use std::string.
(create_child): Change the 'name' parameter to a std::string
reference. Swap it into the new item's name.
(create_child_with_value): Swap item's name into the new child's
name. Use string_printf.
(new_variable): Use new instead of XNEW.
(free_variable): Don't xfree fields that are now std::string.
(name_of_variable, name_of_child): Now returns std::string.
(value_of_root): Adjust to use std::string.
(my_value_of_variable, varobj_value_get_print_value): Return
and use std::string.
(varobj_value_get_print_value): Adjust to use ui_file_as_string
and std::string.
* varobj.h (struct varobj) <name, path_expr, obj_name,
print_value>: Now std::string's.
<name_of_variable, name_of_child, path_expr_of_child,
value_of_variable>: Return std::string.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression, varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Constify 'expression' parameter.
(varobj_value_get_print_value): Return a std::string.

d2af899 2016-11-09 00:26:47 Pedro Alves

Use ui_file_as_string in gdb/language.c

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

* language.c (add_language): Use ui_file_as_string and adjust to
use std::string.

5698084 2016-11-09 00:26:46 Pedro Alves

Use ui_file_as_string in gdb/rust-lang.c

gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>

* rust-lang.c (struct disr_info) <name>: Now a std::string.
(rust_get_disr_info): Use ui_file_as_string and adjust to use
std::string.
(rust_val_print): Adjust to use std::string.

af1fe7b 2016-11-09 00:26:46 Pedro Alves

Use ui_file_as_string in gdb/infrun.c

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

* infrun.c (print_target_wait_results): Use ui_file_as_string and
std::string.

3b4de39 2016-11-09 00:26:46 Pedro Alves

Use ui_file_as_string in gdb/ada-lang.c

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

* ada-lang.c (type_as_string): Use ui_file_as_string and return
std::string.
(type_as_string_and_cleanup): Delete.
(ada_lookup_struct_elt_type): Use type_as_string.

6f03024 2016-11-09 00:26:46 Pedro Alves

Use ui_file_as_string in gdbarch.sh/gdbarch.c

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

* gdbarch.sh (verify_gdbarch): Use ui_file_as_string and
std::string.
* gdbarch.c: Regenerate.

66bbce5 2016-11-09 00:26:46 Pedro Alves

Use ui_file_as_string in gdb/c-exp.y

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

* c-exp.y (OPERATOR NEW): Adjust to use ui_file_as_string and
std::string.

aaee65a 2016-11-09 00:26:46 Pedro Alves

Use ui_file_as_string in gdb/compile/

Using ui_file_as_string would imply changing a few prototypes to pass
around source and object file names as std::string. Instead of that,
wrap those two in a new class. This ends up eliminating a small
wrinkle: get_new_file_names and compile_object_load have swapped
parameters. The former takes "source, objfile", while the latter
takes "objfile, source".

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

* c-lang.h (c_compute_program): Now returns std::string.
* compile/compile-internal.h (class compile_file_names): New
class.
* compile/compile-object-load.c (compile_object_load): Replace
object_file and source_file parameters with a compile_file_names
parameter. Adjust.
* compile-object-load.h: Include "compile-internal.h".
(compile_object_load): Replace object_file and source_file
parameters with a compile_file_names parameter.
* compile/compile-c-support.c (c_compute_program): Now returns a
std::string. Use ui_file_as_string.
* compile/compile.c (get_new_file_names): Remove parameters and
return a compile_file_names instead.
(compile_to_object): Now returns a compile_file_names. Use
ui_file_as_string.
(eval_compile_command): Use compile_file_names.
* language.h (struct language_defn) <la_compute_program>: Now
returns std::string.

3d8b0d9 2016-11-09 00:26:45 Pedro Alves

Use ui_file_as_string in gdb/cli/cli-setshow.c

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

* cli/cli-setshow.c (do_show_command): Adjust to use
ui_file_as_string and std::string.

b3ced9b 2016-11-09 00:26:45 Pedro Alves

Use ui_file_as_string in gdb/remote.c

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

* remote.c (escape_buffer): Use ui_file_as_string and return
std::string.
(putpkt_binary, read_frame): Adjust to use std::string.

c92aed1 2016-11-09 00:26:45 Pedro Alves

Use ui_file_as_string in gdb/python/

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

* python/py-arch.c (archpy_disassemble): Use ui_file_as_string and
std::string.
* python/py-breakpoint.c (bppy_get_commands): Use
ui_file_as_string and std::string.
* python/py-frame.c (frapy_str): Likewise.
* python/py-type.c (typy_str): Likewise.
* python/py-unwind.c (unwind_infopy_str): Likewise.
* python/py-value.c (valpy_str): Likewise.

0203064 2016-11-09 00:26:45 Pedro Alves

Use ui_file_as_string in gdb/printcmd.c

Yet another cleanup eliminated.

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

* printcmd.c (eval_command): Use ui_file_as_string and
std::string.

7b01d34 2016-11-09 00:26:45 Pedro Alves

Use ui_file_as_string in gdb/top.c

Yet another cleanup is eliminated.

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

* top.c (quit_confirm): Use ui_file_as_string and std::string.

db1ec11 2016-11-09 00:26:45 Pedro Alves

Use ui_file_as_string in execute_command_to_string

... and then return std::string and adjust all callers.

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

* gdbcmd.h (execute_command_to_string): Now returns std::string.
(lookup_struct_elt_type): Adjust to use std::string.
* top.c (execute_command_to_string): Use ui_file_as_string and
return std::string.
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
std::string.
* python/python.c (execute_gdb_command): Adjust to use
std::string.

3ab692d 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in gdb/guile/

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

* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
ui_file_as_string and adjust to use std::string.
* guile/scm-disasm.c (gdbscm_arch_disassemble): Likewise.
* guile/scm-frame.c (frscm_print_frame_smob): Likewise.
* guile/scm-type.c (tyscm_type_name): Use ui_file_as_string and
adjust to use std::string. Throw exception directly instead of
returning it in EXCP output parameter.
(tyscm_print_type_smob, gdbscm_type_print_name): Adjust to
tyscm_type_name interface change.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use ui_file_as_string and std::string.

09b0e4b 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in gdb/arm-tdep.c

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

* arm-tdep.c (_initialize_arm_tdep): Use ui_file_as_string and
std::string.

d16c547 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in gdb/utils.c

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

* utils.c (error_stream): Use ui_file_as_string and std::string.

56dbf31 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in gdb/ui-out.c

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

* ui-out.c (ui_out_field_stream): Use ui_file_as_string.

77e1c74 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in gdb/ada-valprint.c

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

* ada-valprint.c (ada_print_floating): Use ui_file_as_string and
std::string.

a0f86e7 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in gdb/xtensa-tdep.c

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

* xtensa-tdep.c (xtensa_verify_config): Use ui_file_as_string and
std::string.

322a851 2016-11-09 00:26:44 Pedro Alves

Use ui_file_as_string in dwarf2_compute_name

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

* dwarf2read.c (dwarf2_compute_name): Use ui_file_as_string and
std::string.

1f45808 2016-11-09 00:26:43 Pedro Alves

Clean up tracepoint.h/c:collection_list

Noticed we could do this while working on the expression_up change.

The main goal here was getting rid of the
encode_actions_and_make_cleanup / do_clear_collection_list cleanups.

While at it, uncrustify the code:

- Make collection_list a C++ class, with data members private (and
thus renamed m_...).

- Make related functions be member methods.

- Use std::vector instead of an open coding a vector implementation.

- Use std::sort instead of qsort.

- Rename the "list" member of collection_list, which is an incredibly
obfuscating name.

- Rename a couple other things here and there for clarify.

- Use "bool" more.

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

* mi/mi-main.c (print_variable_or_computed): Constify 'expression'
parameter.
(mi_cmd_trace_frame_collected): Call encode_actions instead of
encode_actions_and_make_cleanup. Adjust to use std::vector.
* tracepoint.c (memrange_cmp): Delete.
(memrange_comp): New.
(memrange_sortmerge): Take a memrange vector as parameter instead
of a collection_list. Use std::sort instead of qsort.
(add_register): Now a method of collection_list. Adjust to m_
prefix of data fields.
(add_memrange): Now a method of collection_list. Adjust to m_
prefix of data fields. Adjust to use std::vector.
(collect_symbol): Now a method of collection_list. Adjust to m_
prefix of data fields.
(do_collect_symbol): Adjust. Call add_wholly_collected instead of
accessing the vector directly.
(collection_list::add_wholly_collected): New.
(add_local_symbols): Now a method of collection_list.
(add_static_trace_data): Now a method of collection_list. Adjust
to use bool.
(clear_collection_list, do_clear_collection_list): Delete.
(init_collection_list): Delete.
(collection_list::collection_list): New.
(collection_list::~collection_list): New.
(stringify_collection_list): Rename to ...
(collection_list::stringify): ... this and adjust to being a
method of collection_list. Adjust to use of std::vector.
(append_exp): Now a method of collection_list. Use
ui_file_as_string. Adjust to std::vector.
(collection_list::finish): New.
(encode_actions_1): Adjust.
(encode_actions_and_make_cleanup): Rename to ...
(encode_actions)... this. No longer returns a cleanup. No longer
call init_collection_list nor install do_clear_collection_list
cleanups. Call collection_list::finish instead of
memrange_sortmerge directly.
(encode_actions_rsp): Adjust to call encode_actions instead of
encode_actions_and_make_cleanup. Adjust to method renames.
(add_aexpr): Now a method of collection_list.
* tracepoint.h: Include <vector> and <string>.
(struct memrange): Add constructors.
(struct collection_list): Now a class.
(class collection_list) <collection_list, ~collection_list,
add_wholly_collected, append_exp, add_aexpr, add_register,
add_memrange, collect_symbol, add_local_symbols,
add_static_trace_data, finish, stringify, wholly_collected, and
computed>: New methods.
<regs_mask>: Rename to ...
<m_regs_mask>: ... this.
<listsize, next_memrange, list>: Delete fields.
<m_memranges>: New field.
<aexpr_listsize, next_aexpr_elt, aexpr_list>: Delete fields.
<m_aexprs>: New field.
<strace_data>: Rename to ...
<m_strace_data>: ... this. Now a bool.
<wholly_collected>: Rename to ...
<m_wholly_collected>: ... this. Now a std::vector<std::string>.
<computed>: Rename to ...
<m_computed>: ... this. Now a std::vector<std::string>.
(encode_actions_and_make_cleanup): Delete declaration.
(encode_actions): New declaration.

8de0063 2016-11-09 00:26:43 Pedro Alves

Introduce ui_file_as_string

ui_file_as_string is a variant of ui_file_xstrdup that returns a
std::string instead of a xmalloc'ed char *. The idea is using the new
function to eliminate "make_cleanup (xfree, ...)" cleanups
throughout.

Following patches will make use of this.

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

* ui-file.c (do_ui_file_as_string, ui_file_as_string): New
functions.
* ui-file.h: Include <string>.
(ui_file_as_string): New declaration.