Coverage Report

Created: 2025-11-06 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libunwind/src/x86_64/Gglobal.c
Line
Count
Source
1
/* libunwind - a platform-independent unwind library
2
   Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
3
        Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
5
   Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
6
7
This file is part of libunwind.
8
9
Permission is hereby granted, free of charge, to any person obtaining
10
a copy of this software and associated documentation files (the
11
"Software"), to deal in the Software without restriction, including
12
without limitation the rights to use, copy, modify, merge, publish,
13
distribute, sublicense, and/or sell copies of the Software, and to
14
permit persons to whom the Software is furnished to do so, subject to
15
the following conditions:
16
17
The above copyright notice and this permission notice shall be
18
included in all copies or substantial portions of the Software.
19
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
27
28
#include "config.h"
29
#include "unwind_i.h"
30
#include "dwarf_i.h"
31
#include <stdatomic.h>
32
33
HIDDEN define_lock (x86_64_lock);
34
HIDDEN atomic_bool tdep_init_done = 0;
35
36
/* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c.  */
37
38
HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_NUM_PRESERVED_REGS] =
39
  {
40
    UNW_X86_64_RAX,
41
    UNW_X86_64_RDX,
42
    UNW_X86_64_RCX,
43
    UNW_X86_64_RBX,
44
    UNW_X86_64_RSI,
45
    UNW_X86_64_RDI,
46
    UNW_X86_64_RBP,
47
    UNW_X86_64_RSP,
48
    UNW_X86_64_R8,
49
    UNW_X86_64_R9,
50
    UNW_X86_64_R10,
51
    UNW_X86_64_R11,
52
    UNW_X86_64_R12,
53
    UNW_X86_64_R13,
54
    UNW_X86_64_R14,
55
    UNW_X86_64_R15,
56
    UNW_X86_64_RIP,
57
#ifdef CONFIG_MSABI_SUPPORT
58
    UNW_X86_64_XMM0,
59
    UNW_X86_64_XMM1,
60
    UNW_X86_64_XMM2,
61
    UNW_X86_64_XMM3,
62
    UNW_X86_64_XMM4,
63
    UNW_X86_64_XMM5,
64
    UNW_X86_64_XMM6,
65
    UNW_X86_64_XMM7,
66
    UNW_X86_64_XMM8,
67
    UNW_X86_64_XMM9,
68
    UNW_X86_64_XMM10,
69
    UNW_X86_64_XMM11,
70
    UNW_X86_64_XMM12,
71
    UNW_X86_64_XMM13,
72
    UNW_X86_64_XMM14,
73
    UNW_X86_64_XMM15
74
#endif
75
  };
76
77
HIDDEN void
78
tdep_init (void)
79
1
{
80
1
  intrmask_t saved_mask;
81
1
  intrmask_t full_mask;
82
1
  sigfillset (&full_mask);
83
84
1
  SIGPROCMASK (SIG_SETMASK, &full_mask, &saved_mask);
85
1
  mutex_lock (&x86_64_lock);
86
1
  {
87
1
    if (atomic_load(&tdep_init_done))
88
      /* another thread else beat us to it... */
89
0
      goto out;
90
91
1
    sigfillset (&unwi_full_mask);
92
1
    mi_init ();
93
94
1
    dwarf_init ();
95
96
1
#ifndef UNW_REMOTE_ONLY
97
1
    x86_64_local_addr_space_init ();
98
1
#endif
99
1
    atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */
100
1
  }
101
1
 out:
102
1
  mutex_unlock(&x86_64_lock);
103
  SIGPROCMASK (SIG_SETMASK, &saved_mask, NULL);
104
1
}