Re: [PATCH] Revised display-linkage-name

Tom Tromey
2013-07-26T18:42:03Z

>>>>> "Michael" == Michael Eager <eager@eagerm.com> writes:

Michael> This is pretty pointless busywork, serving no useful purpose.

It's part of the currently-agreed-upon coding style.
You're always welcome to propose changes.

Michael> +set|show display-linkage-name-len

It's more gdb-ish to spell out "length".

Michael> + /* Print linkage name after source name if requested and different. */
Michael> + if ((display_linkage_name || ui_out_is_mi_like_p (uiout))
Michael> + && linkname != NULL && strcmp (funname, linkname) != 0)
Michael> + {
Michael> + annotate_linkage_name ();

FWIW there isn't much need to add new annotations. Annotations are
officially deprecated. It's fine by me if you want to leave this in for
some reason though.

Michael> + ui_out_text (uiout, " [");
Michael> +
Michael> + if (strlen (linkname) > display_linkage_name_len)
Michael> + {
Michael> + char *lname = alloca (display_linkage_name_len + 4);
Michael> +
Michael> + strncpy (lname, linkname, display_linkage_name_len);
Michael> + lname[display_linkage_name_len] = '\0';
Michael> + strcat (lname, "...");
Michael> + ui_out_text (uiout, lname);
Michael> + }
Michael> + else
Michael> + ui_out_text (uiout, linkname);
Michael> +
Michael> + ui_out_text (uiout, "]");
Michael> + ui_out_field_stream (uiout, "linkage_name", stb);

This is emitting the linkage name using ui_out_text. That is wrong for
MI.

Then this emits the linkage_name field with the contents from "stb" --
which is reusing a result computed previously (look up for the
fprintf_symbol_filtered).

I tend to think that limiting the name length should only be done in the
not-MI case. That is, for MI, it is better to always print the whole
thing.

Tom