MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / read_v2_paths

Function read_v2_paths

Dependencies/tracy/libbacktrace/dwarf.cpp:2680–2807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2678 2, setting fields in HDR. Return 1 on success, 0 on failure. */
2679
2680static int
2681read_v2_paths (struct backtrace_state *state, struct unit *u,
2682 struct dwarf_buf *hdr_buf, struct line_header *hdr)
2683{
2684 const unsigned char *p;
2685 const unsigned char *pend;
2686 size_t i;
2687
2688 /* Count the number of directory entries. */
2689 hdr->dirs_count = 0;
2690 p = hdr_buf->buf;
2691 pend = p + hdr_buf->left;
2692 while (p < pend && *p != '\0')
2693 {
2694 p += strnlen((const char *) p, pend - p) + 1;
2695 ++hdr->dirs_count;
2696 }
2697
2698 /* The index of the first entry in the list of directories is 1. Index 0 is
2699 used for the current directory of the compilation. To simplify index
2700 handling, we set entry 0 to the compilation unit directory. */
2701 ++hdr->dirs_count;
2702 hdr->dirs = ((const char **)
2703 backtrace_alloc (state,
2704 hdr->dirs_count * sizeof (const char *),
2705 hdr_buf->error_callback,
2706 hdr_buf->data));
2707 if (hdr->dirs == NULL)
2708 return 0;
2709
2710 hdr->dirs[0] = u->comp_dir;
2711 i = 1;
2712 while (*hdr_buf->buf != '\0')
2713 {
2714 if (hdr_buf->reported_underflow)
2715 return 0;
2716
2717 hdr->dirs[i] = read_string (hdr_buf);
2718 if (hdr->dirs[i] == NULL)
2719 return 0;
2720 ++i;
2721 }
2722 if (!advance (hdr_buf, 1))
2723 return 0;
2724
2725 /* Count the number of file entries. */
2726 hdr->filenames_count = 0;
2727 p = hdr_buf->buf;
2728 pend = p + hdr_buf->left;
2729 while (p < pend && *p != '\0')
2730 {
2731 p += strnlen ((const char *) p, pend - p) + 1;
2732 p += leb128_len (p);
2733 p += leb128_len (p);
2734 p += leb128_len (p);
2735 ++hdr->filenames_count;
2736 }
2737

Callers 1

read_line_headerFunction · 0.85

Calls 6

backtrace_allocFunction · 0.85
leb128_lenFunction · 0.85
read_uleb128Function · 0.85
dwarf_buf_errorFunction · 0.85
read_stringFunction · 0.70
advanceFunction · 0.70

Tested by

no test coverage detected