1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate /* 30*0Sstevel@tonic-gate * Routines used to read stabs data from a file, and to build a tdata structure 31*0Sstevel@tonic-gate * based on the interesting parts of that data. 32*0Sstevel@tonic-gate */ 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #include <stdio.h> 35*0Sstevel@tonic-gate #include <stdlib.h> 36*0Sstevel@tonic-gate #include <fcntl.h> 37*0Sstevel@tonic-gate #include <unistd.h> 38*0Sstevel@tonic-gate #include <assert.h> 39*0Sstevel@tonic-gate #include <string.h> 40*0Sstevel@tonic-gate #include <libgen.h> 41*0Sstevel@tonic-gate #include <errno.h> 42*0Sstevel@tonic-gate #include <sys/types.h> 43*0Sstevel@tonic-gate #include <sys/param.h> 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #include "ctftools.h" 46*0Sstevel@tonic-gate #include "list.h" 47*0Sstevel@tonic-gate #include "stack.h" 48*0Sstevel@tonic-gate #include "memory.h" 49*0Sstevel@tonic-gate #include "traverse.h" 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate const char *curhdr; 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* 54*0Sstevel@tonic-gate * The stabs generator will sometimes reference types before they've been 55*0Sstevel@tonic-gate * defined. If this is the case, a TYPEDEF_UNRES tdesc will be generated. 56*0Sstevel@tonic-gate * Note that this is different from a forward declaration, in which the 57*0Sstevel@tonic-gate * stab is defined, but is defined as something that doesn't exist yet. 58*0Sstevel@tonic-gate * When we have read all of the stabs from the file, we can go back and 59*0Sstevel@tonic-gate * fix up all of the unresolved types. We should be able to fix all of them. 60*0Sstevel@tonic-gate */ 61*0Sstevel@tonic-gate /*ARGSUSED2*/ 62*0Sstevel@tonic-gate static int 63*0Sstevel@tonic-gate resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private) 64*0Sstevel@tonic-gate { 65*0Sstevel@tonic-gate tdesc_t *new; 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate debug(3, "Trying to resolve %s (%d)\n", 68*0Sstevel@tonic-gate (node->t_name ? node->t_name : "(anon)"), node->t_id); 69*0Sstevel@tonic-gate new = lookup(node->t_id); 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate if (new == NULL) { 72*0Sstevel@tonic-gate terminate("Couldn't resolve type %d\n", node->t_id); 73*0Sstevel@tonic-gate } 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate debug(3, " Resolving to %d\n", new->t_id); 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate *nodep = new; 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate return (1); 80*0Sstevel@tonic-gate } 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate /*ARGSUSED*/ 83*0Sstevel@tonic-gate static int 84*0Sstevel@tonic-gate resolve_fwd_node(tdesc_t *node, tdesc_t **nodep, void *private) 85*0Sstevel@tonic-gate { 86*0Sstevel@tonic-gate tdesc_t *new = lookupname(node->t_name); 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate debug(3, "Trying to unforward %s (%d)\n", 89*0Sstevel@tonic-gate (node->t_name ? node->t_name : "(anon)"), node->t_id); 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate if (!new || (new->t_type != STRUCT && new->t_type != UNION)) 92*0Sstevel@tonic-gate return (0); 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate debug(3, " Unforwarded to %d\n", new->t_id); 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate *nodep = new; 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate return (1); 99*0Sstevel@tonic-gate } 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate static tdtrav_cb_f resolve_cbs[] = { 102*0Sstevel@tonic-gate NULL, 103*0Sstevel@tonic-gate NULL, /* intrinsic */ 104*0Sstevel@tonic-gate NULL, /* pointer */ 105*0Sstevel@tonic-gate NULL, /* array */ 106*0Sstevel@tonic-gate NULL, /* function */ 107*0Sstevel@tonic-gate NULL, /* struct */ 108*0Sstevel@tonic-gate NULL, /* union */ 109*0Sstevel@tonic-gate NULL, /* enum */ 110*0Sstevel@tonic-gate resolve_fwd_node, /* forward */ 111*0Sstevel@tonic-gate NULL, /* typedef */ 112*0Sstevel@tonic-gate resolve_tou_node, /* typedef unres */ 113*0Sstevel@tonic-gate NULL, /* volatile */ 114*0Sstevel@tonic-gate NULL, /* const */ 115*0Sstevel@tonic-gate NULL, /* restrict */ 116*0Sstevel@tonic-gate }; 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate static void 119*0Sstevel@tonic-gate resolve_nodes(tdata_t *td) 120*0Sstevel@tonic-gate { 121*0Sstevel@tonic-gate debug(2, "Resolving unresolved stabs\n"); 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate (void) iitraverse_hash(td->td_iihash, &td->td_curvgen, resolve_cbs, 124*0Sstevel@tonic-gate NULL, NULL, td); 125*0Sstevel@tonic-gate } 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate static char * 128*0Sstevel@tonic-gate concat(char *s1, char *s2, int s2strip) 129*0Sstevel@tonic-gate { 130*0Sstevel@tonic-gate int savelen = strlen(s2) - s2strip; 131*0Sstevel@tonic-gate int newlen = (s1 ? strlen(s1) : 0) + savelen + 1; 132*0Sstevel@tonic-gate char *out; 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate out = xrealloc(s1, newlen); 135*0Sstevel@tonic-gate if (s1) 136*0Sstevel@tonic-gate strncpy(out + strlen(out), s2, savelen); 137*0Sstevel@tonic-gate else 138*0Sstevel@tonic-gate strncpy(out, s2, savelen); 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate out[newlen - 1] = '\0'; 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate return (out); 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate /* 146*0Sstevel@tonic-gate * N_FUN stabs come with their arguments in promoted form. In order to get the 147*0Sstevel@tonic-gate * actual arguments, we need to wait for the N_PSYM stabs that will come towards 148*0Sstevel@tonic-gate * the end of the function. These routines free the arguments (fnarg_free) we 149*0Sstevel@tonic-gate * got from the N_FUN stab and add (fnarg_add) the ones from the N_PSYM stabs. 150*0Sstevel@tonic-gate */ 151*0Sstevel@tonic-gate static void 152*0Sstevel@tonic-gate fnarg_add(iidesc_t *curfun, iidesc_t *arg) 153*0Sstevel@tonic-gate { 154*0Sstevel@tonic-gate curfun->ii_nargs++; 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate if (curfun->ii_nargs == 1) 157*0Sstevel@tonic-gate curfun->ii_args = xmalloc(sizeof (tdesc_t *) * FUNCARG_DEF); 158*0Sstevel@tonic-gate else if (curfun->ii_nargs > FUNCARG_DEF) { 159*0Sstevel@tonic-gate curfun->ii_args = xrealloc(curfun->ii_args, 160*0Sstevel@tonic-gate sizeof (tdesc_t *) * curfun->ii_nargs); 161*0Sstevel@tonic-gate } 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate curfun->ii_args[curfun->ii_nargs - 1] = arg->ii_dtype; 164*0Sstevel@tonic-gate arg->ii_dtype = NULL; 165*0Sstevel@tonic-gate } 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate static void 168*0Sstevel@tonic-gate fnarg_free(iidesc_t *ii) 169*0Sstevel@tonic-gate { 170*0Sstevel@tonic-gate ii->ii_nargs = 0; 171*0Sstevel@tonic-gate free(ii->ii_args); 172*0Sstevel@tonic-gate ii->ii_args = NULL; 173*0Sstevel@tonic-gate } 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate /* 176*0Sstevel@tonic-gate * Read the stabs from the stab ELF section, and turn them into a tdesc tree, 177*0Sstevel@tonic-gate * assembled under an iidesc list. 178*0Sstevel@tonic-gate */ 179*0Sstevel@tonic-gate int 180*0Sstevel@tonic-gate stabs_read(tdata_t *td, Elf *elf, const char *filename) 181*0Sstevel@tonic-gate { 182*0Sstevel@tonic-gate Elf_Scn *scn; 183*0Sstevel@tonic-gate Elf_Data *data; 184*0Sstevel@tonic-gate stab_t *stab; 185*0Sstevel@tonic-gate stk_t *file_stack; 186*0Sstevel@tonic-gate iidesc_t *iidescp; 187*0Sstevel@tonic-gate iidesc_t *curfun = NULL; 188*0Sstevel@tonic-gate char curpath[MAXPATHLEN]; 189*0Sstevel@tonic-gate char *curfile = NULL; 190*0Sstevel@tonic-gate char *str; 191*0Sstevel@tonic-gate char *fstr = NULL, *ofstr = NULL; 192*0Sstevel@tonic-gate int stabidx, stabstridx; 193*0Sstevel@tonic-gate int nstabs, rc, i; 194*0Sstevel@tonic-gate int scope = 0; 195*0Sstevel@tonic-gate 196*0Sstevel@tonic-gate if (!((stabidx = findelfsecidx(elf, ".stab.excl")) >= 0 && 197*0Sstevel@tonic-gate (stabstridx = findelfsecidx(elf, ".stab.exclstr")) >= 0) && 198*0Sstevel@tonic-gate !((stabidx = findelfsecidx(elf, ".stab")) >= 0 && 199*0Sstevel@tonic-gate (stabstridx = findelfsecidx(elf, ".stabstr")) >= 0)) { 200*0Sstevel@tonic-gate errno = ENOENT; 201*0Sstevel@tonic-gate return (-1); 202*0Sstevel@tonic-gate } 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate file_stack = stack_new(free); 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate stack_push(file_stack, (void *)filename); 207*0Sstevel@tonic-gate curhdr = filename; 208*0Sstevel@tonic-gate 209*0Sstevel@tonic-gate debug(3, "Found stabs in %d, strings in %d\n", stabidx, stabstridx); 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate scn = elf_getscn(elf, stabidx); 212*0Sstevel@tonic-gate data = elf_rawdata(scn, NULL); 213*0Sstevel@tonic-gate nstabs = data->d_size / sizeof (stab_t); 214*0Sstevel@tonic-gate 215*0Sstevel@tonic-gate parse_init(td); 216*0Sstevel@tonic-gate for (i = 0; i < nstabs; i++) { 217*0Sstevel@tonic-gate stab = &((stab_t *)data->d_buf)[i]; 218*0Sstevel@tonic-gate 219*0Sstevel@tonic-gate /* We don't want any local definitions */ 220*0Sstevel@tonic-gate if (stab->n_type == N_LBRAC) { 221*0Sstevel@tonic-gate scope++; 222*0Sstevel@tonic-gate debug(3, "stab %d: opening scope (%d)\n", i + 1, scope); 223*0Sstevel@tonic-gate continue; 224*0Sstevel@tonic-gate } else if (stab->n_type == N_RBRAC) { 225*0Sstevel@tonic-gate scope--; 226*0Sstevel@tonic-gate debug(3, "stab %d: closing scope (%d)\n", i + 1, scope); 227*0Sstevel@tonic-gate continue; 228*0Sstevel@tonic-gate } else if (stab->n_type == N_EINCL) { 229*0Sstevel@tonic-gate /* 230*0Sstevel@tonic-gate * There's a bug in the 5.2 (Taz) compilers that causes 231*0Sstevel@tonic-gate * them to emit an extra N_EINCL if there's no actual 232*0Sstevel@tonic-gate * text in the file being compiled. To work around this 233*0Sstevel@tonic-gate * bug, we explicitly check to make sure we're not 234*0Sstevel@tonic-gate * trying to pop a stack that only has the outer scope 235*0Sstevel@tonic-gate * on it. 236*0Sstevel@tonic-gate */ 237*0Sstevel@tonic-gate if (stack_level(file_stack) != 1) { 238*0Sstevel@tonic-gate str = (char *)stack_pop(file_stack); 239*0Sstevel@tonic-gate free(str); 240*0Sstevel@tonic-gate curhdr = (char *)stack_peek(file_stack); 241*0Sstevel@tonic-gate } 242*0Sstevel@tonic-gate } 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate /* We only care about a subset of the stabs */ 245*0Sstevel@tonic-gate if (!(stab->n_type == N_FUN || stab->n_type == N_GSYM || 246*0Sstevel@tonic-gate stab->n_type == N_LCSYM || stab->n_type == N_LSYM || 247*0Sstevel@tonic-gate stab->n_type == N_PSYM || stab->n_type == N_ROSYM || 248*0Sstevel@tonic-gate stab->n_type == N_RSYM || 249*0Sstevel@tonic-gate stab->n_type == N_STSYM || stab->n_type == N_BINCL || 250*0Sstevel@tonic-gate stab->n_type == N_SO || stab->n_type == N_OPT)) 251*0Sstevel@tonic-gate continue; 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gate if ((str = elf_strptr(elf, stabstridx, 254*0Sstevel@tonic-gate (size_t)stab->n_strx)) == NULL) { 255*0Sstevel@tonic-gate terminate("Can't find string at %u for stab %d\n", 256*0Sstevel@tonic-gate stab->n_strx, i); 257*0Sstevel@tonic-gate } 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate if (stab->n_type == N_BINCL) { 260*0Sstevel@tonic-gate curhdr = xstrdup(str); 261*0Sstevel@tonic-gate stack_push(file_stack, (void *)curhdr); 262*0Sstevel@tonic-gate continue; 263*0Sstevel@tonic-gate } else if (stab->n_type == N_SO) { 264*0Sstevel@tonic-gate if (str[strlen(str) - 1] != '/') { 265*0Sstevel@tonic-gate strcpy(curpath, str); 266*0Sstevel@tonic-gate curfile = basename(curpath); 267*0Sstevel@tonic-gate } 268*0Sstevel@tonic-gate continue; 269*0Sstevel@tonic-gate } else if (stab->n_type == N_OPT) { 270*0Sstevel@tonic-gate if (strcmp(str, "gcc2_compiled.") == 0) { 271*0Sstevel@tonic-gate terminate("GCC-generated stabs are " 272*0Sstevel@tonic-gate "unsupported. Use DWARF instead.\n"); 273*0Sstevel@tonic-gate } 274*0Sstevel@tonic-gate continue; 275*0Sstevel@tonic-gate } 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate if (str[strlen(str) - 1] == '\\') { 278*0Sstevel@tonic-gate int offset = 1; 279*0Sstevel@tonic-gate /* 280*0Sstevel@tonic-gate * There's a bug in the compilers that causes them to 281*0Sstevel@tonic-gate * generate \ for continuations with just -g (this is 282*0Sstevel@tonic-gate * ok), and \\ for continuations with -g -O (this is 283*0Sstevel@tonic-gate * broken). This bug is "fixed" in the 6.2 compilers 284*0Sstevel@tonic-gate * via the elimination of continuation stabs. 285*0Sstevel@tonic-gate */ 286*0Sstevel@tonic-gate if (str[strlen(str) - 2] == '\\') 287*0Sstevel@tonic-gate offset = 2; 288*0Sstevel@tonic-gate fstr = concat(fstr, str, offset); 289*0Sstevel@tonic-gate continue; 290*0Sstevel@tonic-gate } else 291*0Sstevel@tonic-gate fstr = concat(fstr, str, 0); 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate debug(3, "%4d: .stabs \"%s\", %#x, %d, %hd, %d (from %s)\n", i, 294*0Sstevel@tonic-gate fstr, stab->n_type, 0, stab->n_desc, 295*0Sstevel@tonic-gate stab->n_value, curhdr); 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate if (debug_level >= 3) 298*0Sstevel@tonic-gate check_hash(); 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate /* 301*0Sstevel@tonic-gate * Sometimes the compiler stutters, and emits the same stab 302*0Sstevel@tonic-gate * twice. This is bad for the parser, which will attempt to 303*0Sstevel@tonic-gate * redefine the type IDs indicated in the stabs. This is 304*0Sstevel@tonic-gate * compiler bug 4433511. 305*0Sstevel@tonic-gate */ 306*0Sstevel@tonic-gate if (ofstr && strcmp(fstr, ofstr) == 0) { 307*0Sstevel@tonic-gate debug(3, "Stutter stab\n"); 308*0Sstevel@tonic-gate free(fstr); 309*0Sstevel@tonic-gate fstr = NULL; 310*0Sstevel@tonic-gate continue; 311*0Sstevel@tonic-gate } 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate if (ofstr) 314*0Sstevel@tonic-gate free(ofstr); 315*0Sstevel@tonic-gate ofstr = fstr; 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gate iidescp = NULL; 318*0Sstevel@tonic-gate if ((rc = parse_stab(stab, fstr, &iidescp)) < 0) 319*0Sstevel@tonic-gate terminate("Couldn't parse stab \"%s\" (file %s)\n", 320*0Sstevel@tonic-gate str, curhdr); 321*0Sstevel@tonic-gate if (rc == 0) 322*0Sstevel@tonic-gate goto parse_loop_end; 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate /* Make sure the scope tracking is working correctly */ 325*0Sstevel@tonic-gate assert(stab->n_type != N_FUN || (iidescp->ii_type != II_GFUN && 326*0Sstevel@tonic-gate iidescp->ii_type != II_SFUN) || scope == 0); 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate /* 329*0Sstevel@tonic-gate * The only things we care about that are in local scope are 330*0Sstevel@tonic-gate * the N_PSYM stabs. 331*0Sstevel@tonic-gate */ 332*0Sstevel@tonic-gate if (scope && stab->n_type != N_PSYM) { 333*0Sstevel@tonic-gate if (iidescp) 334*0Sstevel@tonic-gate iidesc_free(iidescp, NULL); 335*0Sstevel@tonic-gate goto parse_loop_end; 336*0Sstevel@tonic-gate } 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate switch (iidescp->ii_type) { 339*0Sstevel@tonic-gate case II_SFUN: 340*0Sstevel@tonic-gate iidescp->ii_owner = xstrdup(curfile); 341*0Sstevel@tonic-gate /*FALLTHROUGH*/ 342*0Sstevel@tonic-gate case II_GFUN: 343*0Sstevel@tonic-gate curfun = iidescp; 344*0Sstevel@tonic-gate fnarg_free(iidescp); 345*0Sstevel@tonic-gate iidesc_add(td->td_iihash, iidescp); 346*0Sstevel@tonic-gate break; 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate case II_SVAR: 349*0Sstevel@tonic-gate iidescp->ii_owner = xstrdup(curfile); 350*0Sstevel@tonic-gate /*FALLTHROUGH*/ 351*0Sstevel@tonic-gate case II_GVAR: 352*0Sstevel@tonic-gate case II_TYPE: 353*0Sstevel@tonic-gate case II_SOU: 354*0Sstevel@tonic-gate iidesc_add(td->td_iihash, iidescp); 355*0Sstevel@tonic-gate break; 356*0Sstevel@tonic-gate 357*0Sstevel@tonic-gate case II_PSYM: 358*0Sstevel@tonic-gate fnarg_add(curfun, iidescp); 359*0Sstevel@tonic-gate iidesc_free(iidescp, NULL); 360*0Sstevel@tonic-gate break; 361*0Sstevel@tonic-gate default: 362*0Sstevel@tonic-gate terminate("Unknown iidesc type %d\n", iidescp->ii_type); 363*0Sstevel@tonic-gate } 364*0Sstevel@tonic-gate 365*0Sstevel@tonic-gate parse_loop_end: 366*0Sstevel@tonic-gate fstr = NULL; 367*0Sstevel@tonic-gate } 368*0Sstevel@tonic-gate 369*0Sstevel@tonic-gate if (ofstr) 370*0Sstevel@tonic-gate free(ofstr); 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate resolve_nodes(td); 373*0Sstevel@tonic-gate resolve_typed_bitfields(); 374*0Sstevel@tonic-gate parse_finish(td); 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate cvt_fixbugs(td); 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gate return (0); 379*0Sstevel@tonic-gate } 380