1edb47ec4SLluís /* 2edb47ec4SLluís * Simple trace backend 3edb47ec4SLluís * 4edb47ec4SLluís * Copyright IBM, Corp. 2010 5edb47ec4SLluís * 6edb47ec4SLluís * This work is licensed under the terms of the GNU GPL, version 2. See 7edb47ec4SLluís * the COPYING file in the top-level directory. 8edb47ec4SLluís * 9edb47ec4SLluís */ 10edb47ec4SLluís 11*d38ea87aSPeter Maydell #include "qemu/osdep.h" 1285aff158SStefan Hajnoczi #ifndef _WIN32 13edb47ec4SLluís #include <pthread.h> 1485aff158SStefan Hajnoczi #endif 151de7afc9SPaolo Bonzini #include "qemu/timer.h" 16edb47ec4SLluís #include "trace.h" 17e4858974SLluís #include "trace/control.h" 18b618c288SLluís Vilanova #include "trace/simple.h" 19edb47ec4SLluís 20edb47ec4SLluís /** Trace file header event ID */ 21edb47ec4SLluís #define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with TraceEventIDs */ 22edb47ec4SLluís 23edb47ec4SLluís /** Trace file magic number */ 24edb47ec4SLluís #define HEADER_MAGIC 0xf2b177cb0aa429b4ULL 25edb47ec4SLluís 26edb47ec4SLluís /** Trace file version number, bump if format changes */ 27ef0bd3bbSLluís Vilanova #define HEADER_VERSION 3 28edb47ec4SLluís 29edb47ec4SLluís /** Records were dropped event ID */ 30edb47ec4SLluís #define DROPPED_EVENT_ID (~(uint64_t)0 - 1) 31edb47ec4SLluís 32edb47ec4SLluís /** Trace record is valid */ 33edb47ec4SLluís #define TRACE_RECORD_VALID ((uint64_t)1 << 63) 34edb47ec4SLluís 35edb47ec4SLluís /* 36edb47ec4SLluís * Trace records are written out by a dedicated thread. The thread waits for 37edb47ec4SLluís * records to become available, writes them out, and then waits again. 38edb47ec4SLluís */ 3986946a2dSMichael Tokarev static CompatGMutex trace_lock; 4086946a2dSMichael Tokarev static CompatGCond trace_available_cond; 4186946a2dSMichael Tokarev static CompatGCond trace_empty_cond; 424a0e6714SStefan Hajnoczi 43edb47ec4SLluís static bool trace_available; 44edb47ec4SLluís static bool trace_writeout_enabled; 45edb47ec4SLluís 4662bab732SHarsh Prateek Bora enum { 4762bab732SHarsh Prateek Bora TRACE_BUF_LEN = 4096 * 64, 4862bab732SHarsh Prateek Bora TRACE_BUF_FLUSH_THRESHOLD = TRACE_BUF_LEN / 4, 4962bab732SHarsh Prateek Bora }; 5062bab732SHarsh Prateek Bora 5162bab732SHarsh Prateek Bora uint8_t trace_buf[TRACE_BUF_LEN]; 5230d94087SStefan Hajnoczi static volatile gint trace_idx; 5362bab732SHarsh Prateek Bora static unsigned int writeout_idx; 5430d94087SStefan Hajnoczi static volatile gint dropped_events; 5526896cbfSStefan Hajnoczi static uint32_t trace_pid; 56edb47ec4SLluís static FILE *trace_fp; 574552e410SStefan Weil static char *trace_file_name; 58edb47ec4SLluís 5962bab732SHarsh Prateek Bora /* * Trace buffer entry */ 6062bab732SHarsh Prateek Bora typedef struct { 6162bab732SHarsh Prateek Bora uint64_t event; /* TraceEventID */ 6262bab732SHarsh Prateek Bora uint64_t timestamp_ns; 6362bab732SHarsh Prateek Bora uint32_t length; /* in bytes */ 6426896cbfSStefan Hajnoczi uint32_t pid; 65fb3a5085SMarkus Armbruster uint64_t arguments[]; 6662bab732SHarsh Prateek Bora } TraceRecord; 6762bab732SHarsh Prateek Bora 6862bab732SHarsh Prateek Bora typedef struct { 6962bab732SHarsh Prateek Bora uint64_t header_event_id; /* HEADER_EVENT_ID */ 7062bab732SHarsh Prateek Bora uint64_t header_magic; /* HEADER_MAGIC */ 7162bab732SHarsh Prateek Bora uint64_t header_version; /* HEADER_VERSION */ 728ae601e8SHarsh Prateek Bora } TraceLogHeader; 7362bab732SHarsh Prateek Bora 7462bab732SHarsh Prateek Bora 7562bab732SHarsh Prateek Bora static void read_from_buffer(unsigned int idx, void *dataptr, size_t size); 7662bab732SHarsh Prateek Bora static unsigned int write_to_buffer(unsigned int idx, void *dataptr, size_t size); 7762bab732SHarsh Prateek Bora 7862bab732SHarsh Prateek Bora static void clear_buffer_range(unsigned int idx, size_t len) 7962bab732SHarsh Prateek Bora { 8062bab732SHarsh Prateek Bora uint32_t num = 0; 8162bab732SHarsh Prateek Bora while (num < len) { 8262bab732SHarsh Prateek Bora if (idx >= TRACE_BUF_LEN) { 8362bab732SHarsh Prateek Bora idx = idx % TRACE_BUF_LEN; 8462bab732SHarsh Prateek Bora } 8562bab732SHarsh Prateek Bora trace_buf[idx++] = 0; 8662bab732SHarsh Prateek Bora num++; 8762bab732SHarsh Prateek Bora } 8862bab732SHarsh Prateek Bora } 89edb47ec4SLluís /** 90edb47ec4SLluís * Read a trace record from the trace buffer 91edb47ec4SLluís * 92edb47ec4SLluís * @idx Trace buffer index 93edb47ec4SLluís * @record Trace record to fill 94edb47ec4SLluís * 95edb47ec4SLluís * Returns false if the record is not valid. 96edb47ec4SLluís */ 9762bab732SHarsh Prateek Bora static bool get_trace_record(unsigned int idx, TraceRecord **recordptr) 98edb47ec4SLluís { 9962bab732SHarsh Prateek Bora uint64_t event_flag = 0; 10062bab732SHarsh Prateek Bora TraceRecord record; 10162bab732SHarsh Prateek Bora /* read the event flag to see if its a valid record */ 10262bab732SHarsh Prateek Bora read_from_buffer(idx, &record, sizeof(event_flag)); 10362bab732SHarsh Prateek Bora 10462bab732SHarsh Prateek Bora if (!(record.event & TRACE_RECORD_VALID)) { 105edb47ec4SLluís return false; 106edb47ec4SLluís } 107edb47ec4SLluís 10862bab732SHarsh Prateek Bora smp_rmb(); /* read memory barrier before accessing record */ 10962bab732SHarsh Prateek Bora /* read the record header to know record length */ 11062bab732SHarsh Prateek Bora read_from_buffer(idx, &record, sizeof(TraceRecord)); 11162bab732SHarsh Prateek Bora *recordptr = malloc(record.length); /* dont use g_malloc, can deadlock when traced */ 11262bab732SHarsh Prateek Bora /* make a copy of record to avoid being overwritten */ 11362bab732SHarsh Prateek Bora read_from_buffer(idx, *recordptr, record.length); 11462bab732SHarsh Prateek Bora smp_rmb(); /* memory barrier before clearing valid flag */ 11562bab732SHarsh Prateek Bora (*recordptr)->event &= ~TRACE_RECORD_VALID; 11662bab732SHarsh Prateek Bora /* clear the trace buffer range for consumed record otherwise any byte 11762bab732SHarsh Prateek Bora * with its MSB set may be considered as a valid event id when the writer 11862bab732SHarsh Prateek Bora * thread crosses this range of buffer again. 11962bab732SHarsh Prateek Bora */ 12062bab732SHarsh Prateek Bora clear_buffer_range(idx, record.length); 121edb47ec4SLluís return true; 122edb47ec4SLluís } 123edb47ec4SLluís 124edb47ec4SLluís /** 125edb47ec4SLluís * Kick writeout thread 126edb47ec4SLluís * 127edb47ec4SLluís * @wait Whether to wait for writeout thread to complete 128edb47ec4SLluís */ 129edb47ec4SLluís static void flush_trace_file(bool wait) 130edb47ec4SLluís { 13186946a2dSMichael Tokarev g_mutex_lock(&trace_lock); 132edb47ec4SLluís trace_available = true; 13386946a2dSMichael Tokarev g_cond_signal(&trace_available_cond); 134edb47ec4SLluís 135edb47ec4SLluís if (wait) { 13686946a2dSMichael Tokarev g_cond_wait(&trace_empty_cond, &trace_lock); 137edb47ec4SLluís } 138edb47ec4SLluís 13986946a2dSMichael Tokarev g_mutex_unlock(&trace_lock); 140edb47ec4SLluís } 141edb47ec4SLluís 142edb47ec4SLluís static void wait_for_trace_records_available(void) 143edb47ec4SLluís { 14486946a2dSMichael Tokarev g_mutex_lock(&trace_lock); 145edb47ec4SLluís while (!(trace_available && trace_writeout_enabled)) { 14686946a2dSMichael Tokarev g_cond_signal(&trace_empty_cond); 14786946a2dSMichael Tokarev g_cond_wait(&trace_available_cond, &trace_lock); 148edb47ec4SLluís } 149edb47ec4SLluís trace_available = false; 15086946a2dSMichael Tokarev g_mutex_unlock(&trace_lock); 151edb47ec4SLluís } 152edb47ec4SLluís 15385aff158SStefan Hajnoczi static gpointer writeout_thread(gpointer opaque) 154edb47ec4SLluís { 15562bab732SHarsh Prateek Bora TraceRecord *recordptr; 15662bab732SHarsh Prateek Bora union { 15762bab732SHarsh Prateek Bora TraceRecord rec; 15862bab732SHarsh Prateek Bora uint8_t bytes[sizeof(TraceRecord) + sizeof(uint64_t)]; 15962bab732SHarsh Prateek Bora } dropped; 16062bab732SHarsh Prateek Bora unsigned int idx = 0; 161fb3a5085SMarkus Armbruster int dropped_count; 162edb47ec4SLluís size_t unused __attribute__ ((unused)); 163edb47ec4SLluís 164edb47ec4SLluís for (;;) { 165edb47ec4SLluís wait_for_trace_records_available(); 166edb47ec4SLluís 167e722d705SMarkus Armbruster if (g_atomic_int_get(&dropped_events)) { 16862bab732SHarsh Prateek Bora dropped.rec.event = DROPPED_EVENT_ID, 16962bab732SHarsh Prateek Bora dropped.rec.timestamp_ns = get_clock(); 170fb3a5085SMarkus Armbruster dropped.rec.length = sizeof(TraceRecord) + sizeof(uint64_t), 17126896cbfSStefan Hajnoczi dropped.rec.pid = trace_pid; 172b6b2c962SMarkus Armbruster do { 173e722d705SMarkus Armbruster dropped_count = g_atomic_int_get(&dropped_events); 174b6b2c962SMarkus Armbruster } while (!g_atomic_int_compare_and_exchange(&dropped_events, 175b6b2c962SMarkus Armbruster dropped_count, 0)); 176fb3a5085SMarkus Armbruster dropped.rec.arguments[0] = dropped_count; 17762bab732SHarsh Prateek Bora unused = fwrite(&dropped.rec, dropped.rec.length, 1, trace_fp); 178edb47ec4SLluís } 179edb47ec4SLluís 18062bab732SHarsh Prateek Bora while (get_trace_record(idx, &recordptr)) { 18162bab732SHarsh Prateek Bora unused = fwrite(recordptr, recordptr->length, 1, trace_fp); 18262bab732SHarsh Prateek Bora writeout_idx += recordptr->length; 18362bab732SHarsh Prateek Bora free(recordptr); /* dont use g_free, can deadlock when traced */ 184edb47ec4SLluís idx = writeout_idx % TRACE_BUF_LEN; 185edb47ec4SLluís } 186edb47ec4SLluís 187edb47ec4SLluís fflush(trace_fp); 188edb47ec4SLluís } 189edb47ec4SLluís return NULL; 190edb47ec4SLluís } 191edb47ec4SLluís 19262bab732SHarsh Prateek Bora void trace_record_write_u64(TraceBufferRecord *rec, uint64_t val) 193edb47ec4SLluís { 19462bab732SHarsh Prateek Bora rec->rec_off = write_to_buffer(rec->rec_off, &val, sizeof(uint64_t)); 195edb47ec4SLluís } 196edb47ec4SLluís 19762bab732SHarsh Prateek Bora void trace_record_write_str(TraceBufferRecord *rec, const char *s, uint32_t slen) 19862bab732SHarsh Prateek Bora { 19962bab732SHarsh Prateek Bora /* Write string length first */ 20062bab732SHarsh Prateek Bora rec->rec_off = write_to_buffer(rec->rec_off, &slen, sizeof(slen)); 20162bab732SHarsh Prateek Bora /* Write actual string now */ 20262bab732SHarsh Prateek Bora rec->rec_off = write_to_buffer(rec->rec_off, (void*)s, slen); 20362bab732SHarsh Prateek Bora } 204edb47ec4SLluís 20562bab732SHarsh Prateek Bora int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasize) 20662bab732SHarsh Prateek Bora { 20762bab732SHarsh Prateek Bora unsigned int idx, rec_off, old_idx, new_idx; 20862bab732SHarsh Prateek Bora uint32_t rec_len = sizeof(TraceRecord) + datasize; 20960481e21SLluís Vilanova uint64_t event_u64 = event; 21062bab732SHarsh Prateek Bora uint64_t timestamp_ns = get_clock(); 21162bab732SHarsh Prateek Bora 212b6b2c962SMarkus Armbruster do { 213e722d705SMarkus Armbruster old_idx = g_atomic_int_get(&trace_idx); 21462bab732SHarsh Prateek Bora smp_rmb(); 21562bab732SHarsh Prateek Bora new_idx = old_idx + rec_len; 21662bab732SHarsh Prateek Bora 21762bab732SHarsh Prateek Bora if (new_idx - writeout_idx > TRACE_BUF_LEN) { 21862bab732SHarsh Prateek Bora /* Trace Buffer Full, Event dropped ! */ 219fb3a5085SMarkus Armbruster g_atomic_int_inc(&dropped_events); 22062bab732SHarsh Prateek Bora return -ENOSPC; 22162bab732SHarsh Prateek Bora } 222b6b2c962SMarkus Armbruster } while (!g_atomic_int_compare_and_exchange(&trace_idx, old_idx, new_idx)); 22362bab732SHarsh Prateek Bora 22462bab732SHarsh Prateek Bora idx = old_idx % TRACE_BUF_LEN; 22562bab732SHarsh Prateek Bora 22662bab732SHarsh Prateek Bora rec_off = idx; 22760481e21SLluís Vilanova rec_off = write_to_buffer(rec_off, &event_u64, sizeof(event_u64)); 22883d35d3eSHarsh Prateek Bora rec_off = write_to_buffer(rec_off, ×tamp_ns, sizeof(timestamp_ns)); 22983d35d3eSHarsh Prateek Bora rec_off = write_to_buffer(rec_off, &rec_len, sizeof(rec_len)); 23026896cbfSStefan Hajnoczi rec_off = write_to_buffer(rec_off, &trace_pid, sizeof(trace_pid)); 23162bab732SHarsh Prateek Bora 23262bab732SHarsh Prateek Bora rec->tbuf_idx = idx; 23362bab732SHarsh Prateek Bora rec->rec_off = (idx + sizeof(TraceRecord)) % TRACE_BUF_LEN; 23462bab732SHarsh Prateek Bora return 0; 23562bab732SHarsh Prateek Bora } 23662bab732SHarsh Prateek Bora 23762bab732SHarsh Prateek Bora static void read_from_buffer(unsigned int idx, void *dataptr, size_t size) 23862bab732SHarsh Prateek Bora { 23962bab732SHarsh Prateek Bora uint8_t *data_ptr = dataptr; 24062bab732SHarsh Prateek Bora uint32_t x = 0; 24162bab732SHarsh Prateek Bora while (x < size) { 24262bab732SHarsh Prateek Bora if (idx >= TRACE_BUF_LEN) { 24362bab732SHarsh Prateek Bora idx = idx % TRACE_BUF_LEN; 24462bab732SHarsh Prateek Bora } 24562bab732SHarsh Prateek Bora data_ptr[x++] = trace_buf[idx++]; 24662bab732SHarsh Prateek Bora } 24762bab732SHarsh Prateek Bora } 24862bab732SHarsh Prateek Bora 24962bab732SHarsh Prateek Bora static unsigned int write_to_buffer(unsigned int idx, void *dataptr, size_t size) 25062bab732SHarsh Prateek Bora { 25162bab732SHarsh Prateek Bora uint8_t *data_ptr = dataptr; 25262bab732SHarsh Prateek Bora uint32_t x = 0; 25362bab732SHarsh Prateek Bora while (x < size) { 25462bab732SHarsh Prateek Bora if (idx >= TRACE_BUF_LEN) { 25562bab732SHarsh Prateek Bora idx = idx % TRACE_BUF_LEN; 25662bab732SHarsh Prateek Bora } 25762bab732SHarsh Prateek Bora trace_buf[idx++] = data_ptr[x++]; 25862bab732SHarsh Prateek Bora } 25962bab732SHarsh Prateek Bora return idx; /* most callers wants to know where to write next */ 26062bab732SHarsh Prateek Bora } 26162bab732SHarsh Prateek Bora 26262bab732SHarsh Prateek Bora void trace_record_finish(TraceBufferRecord *rec) 26362bab732SHarsh Prateek Bora { 264db8894f2SHarsh Prateek Bora TraceRecord record; 265db8894f2SHarsh Prateek Bora read_from_buffer(rec->tbuf_idx, &record, sizeof(TraceRecord)); 26662bab732SHarsh Prateek Bora smp_wmb(); /* write barrier before marking as valid */ 267db8894f2SHarsh Prateek Bora record.event |= TRACE_RECORD_VALID; 268db8894f2SHarsh Prateek Bora write_to_buffer(rec->tbuf_idx, &record, sizeof(TraceRecord)); 26962bab732SHarsh Prateek Bora 27030d94087SStefan Hajnoczi if (((unsigned int)g_atomic_int_get(&trace_idx) - writeout_idx) 271e722d705SMarkus Armbruster > TRACE_BUF_FLUSH_THRESHOLD) { 272edb47ec4SLluís flush_trace_file(false); 273edb47ec4SLluís } 274edb47ec4SLluís } 275edb47ec4SLluís 276edb47ec4SLluís void st_set_trace_file_enabled(bool enable) 277edb47ec4SLluís { 278edb47ec4SLluís if (enable == !!trace_fp) { 279edb47ec4SLluís return; /* no change */ 280edb47ec4SLluís } 281edb47ec4SLluís 282edb47ec4SLluís /* Halt trace writeout */ 283edb47ec4SLluís flush_trace_file(true); 284edb47ec4SLluís trace_writeout_enabled = false; 285edb47ec4SLluís flush_trace_file(true); 286edb47ec4SLluís 287edb47ec4SLluís if (enable) { 2888ae601e8SHarsh Prateek Bora static const TraceLogHeader header = { 28962bab732SHarsh Prateek Bora .header_event_id = HEADER_EVENT_ID, 29062bab732SHarsh Prateek Bora .header_magic = HEADER_MAGIC, 29162bab732SHarsh Prateek Bora /* Older log readers will check for version at next location */ 29262bab732SHarsh Prateek Bora .header_version = HEADER_VERSION, 293edb47ec4SLluís }; 294edb47ec4SLluís 2956c2a4074SStefan Hajnoczi trace_fp = fopen(trace_file_name, "wb"); 296edb47ec4SLluís if (!trace_fp) { 297edb47ec4SLluís return; 298edb47ec4SLluís } 299edb47ec4SLluís 300edb47ec4SLluís if (fwrite(&header, sizeof header, 1, trace_fp) != 1) { 301edb47ec4SLluís fclose(trace_fp); 302edb47ec4SLluís trace_fp = NULL; 303edb47ec4SLluís return; 304edb47ec4SLluís } 305edb47ec4SLluís 306edb47ec4SLluís /* Resume trace writeout */ 307edb47ec4SLluís trace_writeout_enabled = true; 308edb47ec4SLluís flush_trace_file(false); 309edb47ec4SLluís } else { 310edb47ec4SLluís fclose(trace_fp); 311edb47ec4SLluís trace_fp = NULL; 312edb47ec4SLluís } 313edb47ec4SLluís } 314edb47ec4SLluís 315edb47ec4SLluís /** 316edb47ec4SLluís * Set the name of a trace file 317edb47ec4SLluís * 318edb47ec4SLluís * @file The trace file name or NULL for the default name-<pid> set at 319edb47ec4SLluís * config time 320edb47ec4SLluís */ 32141fc57e4SPaolo Bonzini void st_set_trace_file(const char *file) 322edb47ec4SLluís { 323edb47ec4SLluís st_set_trace_file_enabled(false); 324edb47ec4SLluís 3254552e410SStefan Weil g_free(trace_file_name); 326edb47ec4SLluís 327edb47ec4SLluís if (!file) { 328857a0e38SStefan Weil /* Type cast needed for Windows where getpid() returns an int. */ 329857a0e38SStefan Weil trace_file_name = g_strdup_printf(CONFIG_TRACE_FILE, (pid_t)getpid()); 330edb47ec4SLluís } else { 3314552e410SStefan Weil trace_file_name = g_strdup_printf("%s", file); 332edb47ec4SLluís } 333edb47ec4SLluís 334edb47ec4SLluís st_set_trace_file_enabled(true); 335edb47ec4SLluís } 336edb47ec4SLluís 337edb47ec4SLluís void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)) 338edb47ec4SLluís { 339edb47ec4SLluís stream_printf(stream, "Trace file \"%s\" %s.\n", 340edb47ec4SLluís trace_file_name, trace_fp ? "on" : "off"); 341edb47ec4SLluís } 342edb47ec4SLluís 343fc764105SLluís void st_flush_trace_buffer(void) 344fc764105SLluís { 345fc764105SLluís flush_trace_file(true); 346fc764105SLluís } 347fc764105SLluís 34885aff158SStefan Hajnoczi /* Helper function to create a thread with signals blocked. Use glib's 34985aff158SStefan Hajnoczi * portable threads since QEMU abstractions cannot be used due to reentrancy in 35085aff158SStefan Hajnoczi * the tracer. Also note the signal masking on POSIX hosts so that the thread 35185aff158SStefan Hajnoczi * does not steal signals when the rest of the program wants them blocked. 35285aff158SStefan Hajnoczi */ 35385aff158SStefan Hajnoczi static GThread *trace_thread_create(GThreadFunc fn) 354edb47ec4SLluís { 35585aff158SStefan Hajnoczi GThread *thread; 35685aff158SStefan Hajnoczi #ifndef _WIN32 357edb47ec4SLluís sigset_t set, oldset; 358edb47ec4SLluís 359edb47ec4SLluís sigfillset(&set); 360edb47ec4SLluís pthread_sigmask(SIG_SETMASK, &set, &oldset); 36185aff158SStefan Hajnoczi #endif 3624a0e6714SStefan Hajnoczi 3634a0e6714SStefan Hajnoczi thread = g_thread_new("trace-thread", fn, NULL); 3644a0e6714SStefan Hajnoczi 36585aff158SStefan Hajnoczi #ifndef _WIN32 366edb47ec4SLluís pthread_sigmask(SIG_SETMASK, &oldset, NULL); 36785aff158SStefan Hajnoczi #endif 368edb47ec4SLluís 36985aff158SStefan Hajnoczi return thread; 37085aff158SStefan Hajnoczi } 37185aff158SStefan Hajnoczi 37241fc57e4SPaolo Bonzini bool st_init(void) 37385aff158SStefan Hajnoczi { 37485aff158SStefan Hajnoczi GThread *thread; 37585aff158SStefan Hajnoczi 37626896cbfSStefan Hajnoczi trace_pid = getpid(); 37726896cbfSStefan Hajnoczi 37885aff158SStefan Hajnoczi thread = trace_thread_create(writeout_thread); 37985aff158SStefan Hajnoczi if (!thread) { 380e4858974SLluís fprintf(stderr, "warning: unable to initialize simple trace backend\n"); 38185aff158SStefan Hajnoczi return false; 38285aff158SStefan Hajnoczi } 38385aff158SStefan Hajnoczi 384edb47ec4SLluís atexit(st_flush_trace_buffer); 385edb47ec4SLluís return true; 386edb47ec4SLluís } 387