• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

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


Commit MetaInfo

修訂cb2b796c8599a961f0104900e1902026b393de3d (tree)
時間2019-09-24 22:06:32
作者Nick Alcock <nick.alcock@orac...>
CommiterNick Alcock

Log Message

libctf: get the encoding of non-ints/fps in the dynamic space right

If you call ctf_type_encoding() on a slice, you are meant to get the
encoding of the slice with the format of the underlying type. If
you call it on a non-int, non-fp, non-slice, you're meant to get the
error ECTF_INTNOTFP.

None of this was implemented for types in the dynamic space (which, now,
is *all* types in writable containers). Instead, we were always
returning the encoding as if it were a float, which for all other types
consulted the wrong part of a discriminated union and returned garbage.
(Curiously, existing users were more disturbed by the lack of an error
in the non-int/fp/slice case than they were about getting garbage back.)

libctf/
* ctf-types.c (ctf_type_encoding): Fix the dynamic case to
work right for non-int/fps.

Change Summary

差異

--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,8 @@
1+2019-08-09 Nick Alcock <nick.alcock@oracle.com>
2+
3+ * ctf-types.c (ctf_type_encoding): Fix the dynamic case to
4+ work right for non-int/fps.
5+
16 2019-08-08 Nick Alcock <nick.alcock@oracle.com>
27
38 * ctf-types.c (ctf_type_name): Don't strlen a potentially-
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -739,7 +739,27 @@ ctf_type_encoding (ctf_file_t *fp, ctf_id_t type, ctf_encoding_t *ep)
739739
740740 if ((dtd = ctf_dynamic_type (ofp, type)) != NULL)
741741 {
742- *ep = dtd->dtd_u.dtu_enc;
742+ switch (LCTF_INFO_KIND (fp, tp->ctt_info))
743+ {
744+ case CTF_K_INTEGER:
745+ case CTF_K_FLOAT:
746+ *ep = dtd->dtd_u.dtu_enc;
747+ break;
748+ case CTF_K_SLICE:
749+ {
750+ const ctf_slice_t *slice;
751+ ctf_encoding_t underlying_en;
752+ slice = &dtd->dtd_u.dtu_slice;
753+
754+ data = ctf_type_encoding (fp, slice->cts_type, &underlying_en);
755+ ep->cte_format = underlying_en.cte_format;
756+ ep->cte_offset = slice->cts_offset;
757+ ep->cte_bits = slice->cts_bits;
758+ break;
759+ }
760+ default:
761+ return (ctf_set_errno (ofp, ECTF_NOTINTFP));
762+ }
743763 return 0;
744764 }
745765