如何用GDB调试交叉编译的QEMU程序?

2023-12-02

我在使用 GDB 调试 QEMU 中运行的简单程序时遇到问题。 GDB似乎无法找到我在程序中的位置(因为它总是显示??作为我当前的位置),并且它永远不会达到我设置的任何断点。

在一个终端中,我运行 QEMU:

$ cat add.c
int main() {
    int x = 9;
    int v = 1;
    while (1) {
        int q = x + v;
    }
    return 0;
}

$ riscv64-unknown-elf-gcc add.c -g
$ qemu-system-riscv64 -gdb tcp::1234 -drive file=a.out,format=raw

在另一个终端中,我运行 GDB:

$ riscv64-unknown-elf-gdb a.out
GNU gdb (GDB) 8.2.90.20190228-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin17.7.0 --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...
(gdb) target remote :1234
Remote debugging using :1234
0x0000000000000000 in ?? ()
(gdb) list
1       int main() {
2           int x = 9;
3           int v = 1;
4           while (1) {
5               int q = x + v;
6           }
7           return 0;
8       }
(gdb) b main
Breakpoint 1 at 0x1018e: file add.c, line 2.
(gdb) b 5
Breakpoint 2 at 0x1019a: file add.c, line 5.
(gdb) b _start
Breakpoint 3 at 0x10114
(gdb) b 4
Breakpoint 4 at 0x101a8: file add.c, line 4.
(gdb) c
Continuing.

尽管程序应该无限循环,但我从未遇到过断点。它的显示似乎很奇怪0x0000000000000000 in ?? ()......但也许没关系?

我在这里做错了什么?我怎样才能逐步完成这个程序?


我认为您缺少链接器脚本和一些启动代码 - 免责声明:我是 riscv 的新手。

您会在 Internet 上找到有关这两个主题的大量信息,但您基本上需要指定程序在 RAM 中的位置,以建立堆栈并初始化帧指针:
如果您希望能够在程序中调用函数并声明自动 C 变量(例如 a、b、c),则这是必需的。

我用的是Windows工具链出于本示例的目的,来自 Kendryte(Linux 版本可用here),并检索到 Windows 版本的 qemuhere.

1) 链接描述文件:该示例使用 riscv64-unknown-elf-ld 使用的默认链接描述文件的稍微修改的示例:

riscv64-unknown-elf-ld --verbose > riscv64-virt.ld

编辑 riscv64-virt.ld,并仅保留以下分隔的行:

==================================================

添加qemu-system-riscv64虚拟机内存布局的描述:

OUTPUT_ARCH(riscv)
MEMORY
{
/* qemu-system-risc64 virt machine */
   RAM (rwx)  : ORIGIN = 0x80000000, LENGTH = 128M 
}
ENTRY(_start)

Use ORIGIN(RAM) and LENGTH(RAM)而不是硬编码值,并提供__stack_top symbol:

 PROVIDE (__executable_start = SEGMENT_START("text-segment", ORIGIN(RAM))); . = SEGMENT_START("text-segment", ORIGIN(RAM)) + SIZEOF_HEADERS;
 PROVIDE(__stack_top = ORIGIN(RAM) + LENGTH(RAM));

顺便说一句,有多种方法可以了解 qemu 系统目标机的内存布局,但我通常查看其设备树文件:

qemu-system-riscv64 -machine virt -machine dumpdtb=riscv64-virt.dtb
dtc -I dtb -O dts -o riscv-virt.dts riscv-virt.dtb

描述内存的部分告诉我们它从 0x80000000 开始:

memory@80000000 {
    device_type = "memory";
    reg = <0x0 0x80000000 0x0 0x8000000>;
}; 

riscv64-virt.ld:

/* Script for -z combreloc: combine and sort reloc sections */
/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
   Copying and distribution of this script, with or without modification,
   are permitted in any medium without royalty provided the copyright
   notice and this notice are preserved.  */
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv",
          "elf64-littleriscv")
OUTPUT_ARCH(riscv)
MEMORY
{
/* qemu-system-risc64 virt machine */
   RAM (rwx)  : ORIGIN = 0x80000000, LENGTH = 128M 
}
ENTRY(_start)
SECTIONS
{
  /* Read-only sections, merged into text segment: */
  PROVIDE (__executable_start = SEGMENT_START("text-segment", ORIGIN(RAM))); . = SEGMENT_START("text-segment", ORIGIN(RAM)) + SIZEOF_HEADERS;
  PROVIDE(__stack_top = ORIGIN(RAM) + LENGTH(RAM));
  .interp         : { *(.interp) }
  .note.gnu.build-id : { *(.note.gnu.build-id) }
  .hash           : { *(.hash) }
  .gnu.hash       : { *(.gnu.hash) }
  .dynsym         : { *(.dynsym) }
  .dynstr         : { *(.dynstr) }
  .gnu.version    : { *(.gnu.version) }
  .gnu.version_d  : { *(.gnu.version_d) }
  .gnu.version_r  : { *(.gnu.version_r) }
  .rela.dyn       :
    {
      *(.rela.init)
      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
      *(.rela.fini)
      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
      *(.rela.ctors)
      *(.rela.dtors)
      *(.rela.got)
      *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
      *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
      *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
      *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
      PROVIDE_HIDDEN (__rela_iplt_start = .);
      *(.rela.iplt)
      PROVIDE_HIDDEN (__rela_iplt_end = .);
    }
  .rela.plt       :
    {
      *(.rela.plt)
    }
  .init           :
  {
    KEEP (*(SORT_NONE(.init)))
  }
  .plt            : { *(.plt) }
  .iplt           : { *(.iplt) }
  .text           :
  {
    *(.text.unlikely .text.*_unlikely .text.unlikely.*)
    *(.text.exit .text.exit.*)
    *(.text.startup .text.startup.*)
    *(.text.hot .text.hot.*)
    *(.text .stub .text.* .gnu.linkonce.t.*)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
  }
  .fini           :
  {
    KEEP (*(SORT_NONE(.fini)))
  }
  PROVIDE (__etext = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  .rodata1        : { *(.rodata1) }
  .sdata2         :
  {
    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
  }
  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
  .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
  .gcc_except_table.*) }
  .gnu_extab   : ONLY_IF_RO { *(.gnu_extab*) }
  /* These sections are generated by the Sun/Oracle C++ compiler.  */
  .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
  .exception_ranges*) }
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  */
  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  /* Exception handling  */
  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
  .gnu_extab      : ONLY_IF_RW { *(.gnu_extab) }
  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
  /* Thread Local Storage sections  */
  .tdata      :
   {
     PROVIDE_HIDDEN (__tdata_start = .);
     *(.tdata .tdata.* .gnu.linkonce.td.*)
   }
  .tbss       : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  .preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  }
  .init_array     :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
    PROVIDE_HIDDEN (__init_array_end = .);
  }
  .fini_array     :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
    KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
    PROVIDE_HIDDEN (__fini_array_end = .);
  }
  .ctors          :
  {
    /* gcc uses crtbegin.o to find the start of
       the constructors, so we make sure it is
       first.  Because this is a wildcard, it
       doesn't matter if the user does not
       actually link against crtbegin.o; the
       linker won't look for a file to match a
       wildcard.  The wildcard also means that it
       doesn't matter which directory crtbegin.o
       is in.  */
    KEEP (*crtbegin.o(.ctors))
    KEEP (*crtbegin?.o(.ctors))
    /* We don't want to include the .ctor section from
       the crtend.o file until after the sorted ctors.
       The .ctor section from the crtend file contains the
       end of ctors marker and it must be last */
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  }
  .dtors          :
  {
    KEEP (*crtbegin.o(.dtors))
    KEEP (*crtbegin?.o(.dtors))
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
    KEEP (*(SORT(.dtors.*)))
    KEEP (*(.dtors))
  }
  .jcr            : { KEEP (*(.jcr)) }
  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
  .dynamic        : { *(.dynamic) }
  . = DATA_SEGMENT_RELRO_END (0, .);
  .data           :
  {
    *(.data .data.* .gnu.linkonce.d.*)
    SORT(CONSTRUCTORS)
  }
  .data1          : { *(.data1) }
  .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
  /* We want the small data sections together, so single-instruction offsets
     can access them all, and initialized data all before uninitialized, so
     we can shorten the on-disk segment size.  */
  .sdata          :
  {
    __global_pointer$ = . + 0x800;
    *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
    *(.sdata .sdata.* .gnu.linkonce.s.*)
  }
  _edata = .; PROVIDE (edata = .);
  . = .;
  __bss_start = .;
  .sbss           :
  {
    *(.dynsbss)
    *(.sbss .sbss.* .gnu.linkonce.sb.*)
    *(.scommon)
  }
  .bss            :
  {
   *(.dynbss)
   *(.bss .bss.* .gnu.linkonce.b.*)
   *(COMMON)
   /* Align here to ensure that the .bss section occupies space up to
      _end.  Align after .bss to ensure correct alignment even if the
      .bss section disappears because there are no input sections.
      FIXME: Why do we need it? When there is no .bss section, we don't
      pad the .data section.  */
   . = ALIGN(. != 0 ? 64 / 8 : 1);
  }
  . = ALIGN(64 / 8);
  . = SEGMENT_START("ldata-segment", .);
  . = ALIGN(64 / 8);
  _end = .; PROVIDE (end = .);
  . = DATA_SEGMENT_END (.);
  /* Stabs debugging sections.  */
  .stab          0 : { *(.stab) }
  .stabstr       0 : { *(.stabstr) }
  .stab.excl     0 : { *(.stab.excl) }
  .stab.exclstr  0 : { *(.stab.exclstr) }
  .stab.index    0 : { *(.stab.index) }
  .stab.indexstr 0 : { *(.stab.indexstr) }
  .comment       0 : { *(.comment) }
  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
  /* DWARF 3 */
  .debug_pubtypes 0 : { *(.debug_pubtypes) }
  .debug_ranges   0 : { *(.debug_ranges) }
  /* DWARF Extension.  */
  .debug_macro    0 : { *(.debug_macro) }
  .debug_addr     0 : { *(.debug_addr) }
  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}

2)startup.s:(学分:here and here).

.section .init, "ax"
.global _start
_start:
    .cfi_startproc
    .cfi_undefined ra
    .option push
    .option norelax
    la gp, __global_pointer$
    .option pop
    la sp, __stack_top
    add s0, sp, zero
    jal zero, main
    .cfi_endproc
    .end

add.c:(您的代码)

int main() {
    int a = 4;
    int b = 12;
    while (1) {
        int c = a + b;
    }
    return 0;
}

3) 编译/链接,并创建列表:

riscv64-unknown-elf-gcc -g -ffreestanding -O0 -Wl,--gc-sections -nostartfiles -nostdlib -nodefaultlibs -Wl,-T,riscv64-virt.ld -o add.elf startup.s add.c
riscv64-unknown-elf-objdump -D  add.elf > add.objdump

4)在控制台中启动qemu:

qemu-system-riscv64 -machine virt -m 128M -gdb tcp::1234,ipv4  -kernel add.elf

我不确定您使用的 qemu 选项:-drive file=a.out,format=raw是正确的,我认为它们不是,但我没有花时间检查,并使用了我通常使用的选项:-kernel add.elf

4)在另一个控制台中启动gdb(为了方便起见,我在这里使用了我用TUI支持mingw64编译的GDB)。

riscv64-elf-gdb --tui  add.elf

enter image description here

(gdb) target remote localhost:1234
Remote debugging using localhost:1234
main () at add.c:5
(gdb) p a
$1 = 4
(gdb) p b
$2 = 12
(gdb) p c
$3 = 16
(gdb)

这可能有点长,但我希望这会有所帮助。 请注意,启动代码对于您的代码来说已经足够好了,但是缺少一些重要的初始化,例如将数据部分从闪存复制到 RAM(此处不相关),以及清除 .bss 部分。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何用GDB调试交叉编译的QEMU程序? 的相关文章

  • GDB 函数参数上的条件中断

    我想在函数参数大于某个值时设置断点 下面的虚拟代码 int main void uint64 t num 123456 uint64 t x 847534 uint64 t other num x x num other stuff her
  • 有没有办法在 gdb 中设置一个以调用堆栈为条件的断点?

    我正在 Linux 上的 gdb 7 1 中调试 C 我有一个函数a 代码中很多地方都会调用它 我想在其中设置一个断点 但前提是它是从b 有什么办法可以做到吗 有没有办法做到这一点 只有当b 被叫自c 等等无穷无尽 Update 现在有一个
  • 在 GDB 中显示结构体值

    在 GDB 中 给定一个指向结构体的变量 print将显示原始指针值并x将显示指向的原始字节 有什么方法可以显示指向该结构的数据 即字段及其值的列表 print variable 如果这样做 它将在 GDB 中显示该变量的值 您还可以选择显
  • gdb 通过指向错误的代码行显示不正确的回溯

    我们可以通过在源代码中包含多个中止调用 用非常简单的示例重现此问题 在下面的示例代码中 我们在不同条件下总共有四个中止调用 但是当我们使用优化标志 O3 进行编译时 我们只能看到一个中止调用的调试信息 因此 在这四个中止调用中发生崩溃时 g
  • 使用 libtool 和 gdb

    我正在开发一个使用 GNU 自动工具的项目 因此为了使用 gdb 调试代码 我从 libtool 中运行 gdb libtool mode execute gdbtui foobar 是否可以重新加载项目的修改版本 而不必退出 gdb li
  • Eclipse 调试模式下的 GDB 找不到 stdlib/rand.c

    我试图让 gdb 在 ubuntu 上与 eclipse cdt 一起运行 以开始调试一些简单的程序 所以我做了我认为必要的步骤来让它运行 1 创建可执行项目 2 Compile 3 Run 4 创建文件 gdbinit 并将其放在主项目文
  • gdb 中的 是什么意思?

    gdb n 134 a b c 0xdeadbeef uint32 t length initval gdb n gdb p a 30
  • gdb 错误 - 文件不是可执行格式:无法识别文件格式

    我正在尝试使用 gdb 调试某个名为 xdf 的程序 但是当我运行 gdb xdf 时 出现以下错误 home nealtitusthomas X ray astronomy heasoft 6 24 x86 64 pc linux gnu
  • Fortran 在 gdb 中打印可分配数组

    我正在向开源科学代码添加一些功能 我使用很多可分配项 但在正确打印它们时遇到一些问题 例如 我声明并分配 然后使用 real dp allocatable psi n phi some other stuff here allocate p
  • 如何使用GDB修改内存内容?

    我知道我们可以使用几个命令来访问和读取内存 例如 print p x 但是如何更改任何特定位置的内存内容 在 GDB 中调试时 最简单的是设置程序变量 参见GDB 分配 http sourceware org gdb current onl
  • 如何在 LLVM IR 中使用 RISC-V Vector (RVV) 指令?

    In 这个演示文稿 https llvm org devmtg 2019 04 slides TechTalk Kruppe Espasa RISC V Vectors and LLVM pdfKruppe 和 Espasa 概述了 RIS
  • 如何替换`qemu-system -redir`命令参数?

    我有一个使用以下选项启动 qemu 的脚本 qemu system x86 64 net nic model rtl8139 net user hostfwd tcp 5555 1522 net dump file tmp vm0 pcap
  • gdb 声称它不知道如何运行

    我在 Mac Pro 上的 Mac OS X 10 6 6 上使用 Xcode 3 2 3 来构建 GrowlTunes 的修订版 5fd480ef577f咆哮开发存储库 http growl info hg growl developme
  • gdb 脚本:在选定的断点处执行命令

    我想在 gdb 脚本中预定义一些断点 并在这些断点处调用一些特殊命令 然后自动继续程序执行 因此 理想情况下 我想要一个如下所示的 gdb 脚本 b someFunction if breakpoint from above reached
  • 如何与 QEMU 映像共享主机的本地主机?

    想知道这样的事情是否可能 我有一个服务器在监听localhost 1889我的本地 PC 和 QEMU 映像能够使用相同的端口和 IP 访问服务器 localhost 1889 确实正在寻找以下解决方案之一 用于启用此功能的 QEMU 标志
  • 该程序链接到哪个库来提供给定的功能?

    我有一个程序调用函数foo这是在库中定义的 我如何知道该库在文件系统中的位置 比如它是静态库还是动态链接库 更新 使用ldd 程序有很多依赖库 如何判断哪个库包含函数foo 您没有说您所在的操作系统 答案取决于系统 在 Linux 和大多数
  • GDB命令了解程序是否正在运行或停止

    我正在尝试自动化 GDB 调试会话 我想知道 GDB 中是否有任何命令或任何其他方式可以帮助我知道程序是否正在运行或停止 Use gdb selected inferior threads 0 is running 来自 GDB Pytho
  • 从 gdb 设置 std::string 变量值?

    是否有可能 当调试器在断点处停止时 修改 std string 变量的值 而不需要采取诸如调整当前缓冲区的内存映像之类的黑客手段 例如类似于 set var mystring hello world 试试这个 经过测试并且对我有用 call
  • Qemu源代码流程[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我正在构建一个项目 其中我必须提取在 qemu kvm 之上运行的虚拟机的脏页面 我下载了 qemu 源代码 但无法正确理解它 因为源
  • 如何将 CLI 参数传递给 GDB 中“定义”内的“命令”?

    E g define mycmd break arg0 commands print arg0 end end mycmd myfunc continue Prints 1 void 而不是预期的myfunc 因为 arg0当命令被点击时被

随机推荐

  • 为什么多个类选择器不能与removeClass一起使用

    如何在一个声明中使用多个类来完成这项工作 div class ddd back7 d div div class fff back7 f div div class ggg back7 g div ddd fff ggg removeCla
  • 返回重复字母最多的第一个单词

    这是 coderbyte 的 Easy Set 中的一个问题 很多人已经问过这个问题 但我真的很好奇我的特定解决方案出了什么问题 我知道这是一个非常愚蠢且低效的解决方案 原问题 让函数 LetterCountI str 接受传递的 str
  • 从多个接口继承的方法上的 List 返回类型中的 Java 泛型

    我目前在一家拥有多种模块的公司工作 在该公司中 如果您想提供模块内部结构 您可以通过 java 接口提供它 该接口隐藏实际的实现类型并为请求模块提供接口 现在我希望有一个提供程序能够为多个模块提供数据 这些模块公开实际内部数据的不同字段或方
  • 逐行乘以数据框

    输入文件 df1 lt data frame row names c w x y z A c 0 0 0 0 B c 0 1 0 0 C c 1 0 1 0 D c 1 1 1 1 A B C D w 0 0 1 1 x 0 1 0 1 y
  • MVC 失去焦点时需要进行字段验证

    ASP NET MVC 必需 验证仅在以下条件之一触发 1 表格提交2 按 Tab 键进入字段 gt 输入一些文本 gt Tab 退出 gt Tab 返回字段 gt 删除文本 gt Tab 退出 我想以这种方式触发 if 按 T ab 键进
  • 温斯顿记录器不写入文件

    我想用winston登录node用于将错误记录到文件的应用程序 但winston不写入文件 var logger new winston Logger transports new winston transports Console ne
  • 有界通配符和类型参数有什么区别?

    之间有区别吗
  • 使用 JavaScript/ES6 的 for 循环创建可通过 Promise.all 读取的 fetch Promise 数组?

    因此 为了不让任何人对背景故事感到厌烦 我需要从许多 API 访问数据才能运行我的脚本 在执行脚本之前需要加载所有数据 我通常很乐意这样做 我只需声明一些获取请求 编写 Promise all 然后继续执行该函数 然而 我遇到了某个 API
  • 如何使用网站和php运行Docker容器?

    我有一个登陆页面和一个用于发送电子邮件 反馈表 的 PHP 文件 我想使用 Docker 测试这个表单 我写了这个 Dockerfile FROM php 7 4 cli COPY usr src app CMD php mail cont
  • 使用 get() 从卸载的包中调用函数而不使用库

    我想通过将函数名称存储在列表中来从卸载的包中调用函数 通常我只会使用 library shiny pagelist lt list type p object with the function name will be loaded fr
  • jQuery 中滚动条聚焦时如何禁用可拖动 div

    我有一个带有侧滚动条的 jQuery 可拖动容器 div 当我上下滚动时 该滚动条不应该是可拖动的 infotext 是包含文本的内部 div 包含在 infobody 中 设置为 Overflow auto 我需要一种方法来在选择滚动条时
  • MySQL 在逗号列表中搜索[重复]

    这个问题在这里已经有答案了 我有一个 MySQL 字段 其中引用了另一个表 其中 id 保存为逗号分隔列表 例如 12 13 14 16 代表另一个表中的值 我知道这是非常糟糕和错误的 但这来自上面 我对此无能为力 现在的问题是我想使用如下
  • 与其他浏览器相比,IE 中的页面加载速度非常慢

    当我加载我工作的网站的首页在 IE 中 完全加载大约需要 7 或 8 秒 也就是说 Waiting for and x items remaining 消失并变为 Done 完全相同的页面在 Firefox 和 Google Chrome
  • C++ 类参考

    来自 Delphi 我习惯于使用类引用 元类 如下所示 type TClass class of TForm var x TClass f TForm begin x TForm f x Create f ShowModal f Free
  • 如何注入“Broken pipeline”错误?

    我正在运行一个使用 TCP 套接字的网络程序测试 为了验证错误修复 我需要在套接字层重现 损坏的管道 错误 但我不知道如何实现 任何想法 多谢 管道损坏 意味着您已写入已被对等方关闭的连接 因此 让对等方关闭连接
  • 如何将 Shadertoy 代码实现到 Three.js 中 - 澄清细节

    所以这是之前的一个问题 如何在 Three js 中实现 ShaderToy 着色器 尝试将上面链接中的步骤实施到此代码中 但未成功 三 js blob master examples webgl shader html 所以我替换了原始的
  • 目录属性和子目录

    The CMake 手册set directory properties claims 设置当前目录和子目录的属性 对我来说 这表明父目录中设置的属性也应该继承到所有子目录 但事实似乎并非如此 考虑 CMakeLists txt cmake
  • 如何使用lodash将两个数组合并为一个对象

    我正在寻找做到这一点的最佳方法 我有两个数组 key 1 2 3 value value1 value2 value3 我想要的最终结果是一个地图数组 key 1 value value1 key 2 value value2 key 3
  • 如何将捕获的图片作为 blob 保存到 SQLite 中并在 Phonegap 中检索回来?

    我创建了一个 Phonegap 项目 按照教程使用相机捕获图片http mobile tutsplus com tutorials phonegap phonegap from scratch camera exporting 现在我想将图
  • 如何用GDB调试交叉编译的QEMU程序?

    我在使用 GDB 调试 QEMU 中运行的简单程序时遇到问题 GDB似乎无法找到我在程序中的位置 因为它总是显示 作为我当前的位置 并且它永远不会达到我设置的任何断点 在一个终端中 我运行 QEMU cat add c int main i