static int __init setup_watchpoint(char *str) { char *p; unsigned long va, width; int mode; va = simple_strtoul(str, &p, 0); if (p == str) { pr_err("Unknown 'watch=' numeric value: %s\n", str); return -EINVAL; } str = p; if (*str == '/') { ++str; width = simple_strtoul(str, &p, 0); if (p == str) { pr_err("Unknown 'watch=' width qualifier: %s\n", str); return -EINVAL; } if (__builtin_popcount(width) != 1) { pr_err("'watch=' width value not power of two: %ld\n", width); return -EINVAL; } str = p; } else { width = 1; } if (*str == ',') { mode = string_to_mode(++str); if (mode == -1) { pr_err("Unknown 'watch=' qualifier '%s'\n", str); return -EINVAL; } } else { mode = string_to_mode("default"); } /* FIXME: we only need to reserve PERF_COUNT_0. */ if (reserve_pmc_hardware(handle_watch_interrupt)) return -EINVAL; pr_notice("Watching VAs %#lx..%#lx,%s\n", va, va + width - 1, mode_to_string(mode)); __insn_mtspr(SPR_WATCH_VAL, va); #ifdef __tilegx__ /* Watch only the VA bits, not the high bits. */ __insn_mtspr(SPR_WATCH_MASK, (-1ULL << 42) | (width - 1)); /* * We assume SPR_DIAG_MUX_CTL is set for Mbox output in the hv. * Select "special" for perf counter zero, using "watch SPR" output. */ __insn_mtspr(SPR_PERF_COUNT_CTL, (7 << 6) | 0); #else /* Watch requested VA bits. */ __insn_mtspr(SPR_WATCH_MASK, width - 1); /* Choose watching the appropriate type of access. */ __insn_mtspr(SPR_WATCH_CTL, mode); /* Select DIAG_SPCL_EVENT_WATCH for performance counter 0. */ __insn_mtspr(SPR_PERF_COUNT_CTL, 106); #endif __insn_mtspr(SPR_PERF_COUNT_0, -1); unmask_pmc_interrupts(); return 0; }
static void load_library_settings(HWND dialog) { char **overrides = enumerate_values(config_key, keypath("DllOverrides")); char **p; int sel, count = 0; sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0); WINE_TRACE("sel=%d\n", sel); clear_settings(dialog); if (!overrides || *overrides == NULL) { set_controls_from_selection(dialog); disable(IDC_DLLS_EDITDLL); disable(IDC_DLLS_REMOVEDLL); HeapFree(GetProcessHeap(), 0, overrides); return; } enable(IDC_DLLS_EDITDLL); enable(IDC_DLLS_REMOVEDLL); for (p = overrides; *p != NULL; p++) { int index; char *str, *value; const char *label; struct dll *dll; value = get_reg_key(config_key, keypath("DllOverrides"), *p, NULL); label = mode_to_label(string_to_mode(value)); str = HeapAlloc(GetProcessHeap(), 0, strlen(*p) + 2 + strlen(label) + 2); strcpy(str, *p); strcat(str, " ("); strcat(str, label); strcat(str, ")"); dll = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dll)); dll->name = *p; dll->mode = string_to_mode(value); index = SendDlgItemMessageA(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll); HeapFree(GetProcessHeap(), 0, str); count++; } HeapFree(GetProcessHeap(), 0, overrides); /* restore the previous selection, if possible */ if (sel >= count - 1) sel = count - 1; else if (sel == -1) sel = 0; SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, sel, 0); set_controls_from_selection(dialog); }
static int process_file(struct saved_data *data, const char *filename) { struct spec *spec; unsigned int line_num; char *line_buf = NULL; size_t line_len; ssize_t len; FILE *context_file; context_file = fopen(filename, "r"); if (!context_file) { fprintf(stderr, "Error opening %s: %s\n", filename, strerror(errno)); return -1; } line_num = 0; while ((len = getline(&line_buf, &line_len, context_file)) != -1) { char *context; char *mode; char *regex; char *cp, *anchored_regex; char *buf_p; pcre *re; pcre_extra *sd; const char *err; int items, erroff, rc; size_t regex_len; int32_t stem_id; len = strlen(line_buf); if (line_buf[len - 1] == '\n') line_buf[len - 1] = 0; buf_p = line_buf; while (isspace(*buf_p)) buf_p++; /* Skip comment lines and empty lines. */ if (*buf_p == '#' || *buf_p == 0) continue; items = sscanf(line_buf, "%ms %ms %ms", ®ex, &mode, &context); if (items < 2 || items > 3) { fprintf(stderr, "invalid entry, skipping:%s", line_buf); continue; } if (items == 2) { context = mode; mode = NULL; } rc = grow_specs(data); if (rc) { fprintf(stderr, "grow_specs failed: %s\n", strerror(errno)); return rc; } spec = &data->spec_arr[data->nspec]; spec->lr.ctx_raw = context; spec->mode = string_to_mode(mode); if (spec->mode == -1) { fprintf(stderr, "%s: line %d has invalid file type %s\n", regex, line_num + 1, mode); spec->mode = 0; } free(mode); spec->regex_str = regex; stem_id = find_stem_from_spec(data, regex); spec->stem_id = stem_id; /* skip past the fixed stem part */ if (stem_id != -1) regex += data->stem_arr[stem_id].len; regex_len = strlen(regex); cp = anchored_regex = malloc(regex_len + 3); if (!cp) { fprintf(stderr, "Malloc Failed: %s\n", strerror(errno)); return -1; } *cp++ = '^'; memcpy(cp, regex, regex_len); cp += regex_len; *cp++ = '$'; *cp = '\0'; spec_hasMetaChars(spec); re = pcre_compile(anchored_regex, 0, &err, &erroff, NULL); if (!re) { fprintf(stderr, "PCRE compilation failed for %s at offset %d: %s\n", anchored_regex, erroff, err); return -1; } spec->regex = re; sd = pcre_study(re, 0, &err); if (!sd) { fprintf(stderr, "PCRE study failed for %s: %s\n", anchored_regex, err); return -1; } free(anchored_regex); spec->sd = sd; line_num++; data->nspec++; } free(line_buf); fclose(context_file); return 0; }