如何用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 中当前的汇编指令

    我正在 GDB 中进行一些汇编级调试 有没有办法让 GDB 以与显示当前源代码行相同的方式显示当前的汇编指令 每个命令后的默认输出如下所示 0x0001433f 990 Foo bar p 这给了我当前指令的地址 但我必须继续参考disas
  • 零/符号扩展是无操作的,为什么要为每种大小类型提供指令呢?

    对于 x86 和 x64 编译器生成类似的零 符号扩展 MOVSX 和 MOVZX 扩展本身并不是免费的 但允许处理器执行无序魔法加速 但在 RISC V 上 因此 无符号和有符号 32 位整数之间的转换是无操作 从有符号 32 位整数到有
  • 记录内存访问足迹

    I found mtrace https github com aclements mtrace克莱门茨博士 虽然很有用 但是在我需要的情况下却不能正常工作 我打算使用该记录来了解不同场景下的内存访问模式 有人可以分享相关经验吗 任何建议将
  • 如何在 Xcode 4 中从断点操作打印字符串值?

    我有一个断点操作 并且正在使用下拉列表中的 日志 选项 我想打印出字符串 摘要 值 我正在这样做 the person name is p name 但这会打印内存地址 我可以切换到调试器命令选项并执行以下操作 po f name 但后来我
  • OSX Lion 上的 GDB 7.3.1

    我正在尝试使用 macports 中的 GDB v 7 3 1 来调试用以下命令编译的可执行文件 g 4 7 也来自 macports 但是 我启动调试器 得到以下输出 GNU gdb GDB 7 3 1 版权所有 C 2011 自由软件基
  • 在 Linux 上以编程方式为 gdb 在 C 或 C++ 代码中设置断点

    如何以编程方式在 C 或 C 代码中设置适用于 Linux 上的 gdb 的断点 I e int main int argc char argv set breakpoint here int a 3 a In gdb gt print a
  • C++ 程序在执行 std::string 分配时总是崩溃

    我一直在尝试调试崩溃的应用程序中的崩溃 即断言 检测到 glibc free 无效指针 0x000000000070f0c0 当我尝试对字符串进行简单分配时 请注意 我正在使用 gcc 4 2 4 的 Linux 系统上进行编译 优化级别设
  • 警告:可加载部分“my_section”位于 ELF 段之外

    我使用 Cortex R4 的 Arm Compiler v6 9 构建了一个 axf elf 文件 但是 当我使用 Arm MCU Eclipse J link GDB 插件将其加载到目标时 它无法加载我的段的初始化数据 如果我使用 Se
  • RISC-V 调用约定的 ABI 寄存器名称

    我对 RISC V ABI 寄存器名称感到困惑 例如 第 85 页的 RISC V 指令集手册 第一卷 用户级 ISA 版本 2 0 中的表 18 2 指定堆栈指针sp正在注册x14 然而 指令 addi sp zero 0 由 riscv
  • 在不附加 GDB 的情况下获取所有线程的堆栈跟踪

    有没有一种方法可以在不附加 GDB 的情况下打印所有线程的堆栈跟踪 或者是否有一个命令可以用作 gdb 批处理模式来打印所有线程的堆栈跟踪 elfutils https sourceware org elfutils 除其他实用程序外 还包
  • 将大核心文件转换为“minicore”文件

    如何将核心文件减少到仅线程堆栈 我希望能够运行 gdbthread apply all bt在迷你核心上 仅此而已 我正在处理大型 gt 4GB 多线程 Linux ELF 核心文件 这些文件太大而无法返回进行分析 我见过谷歌断点器 htt
  • 使用 gdb 在指定的可执行文件之外单步执行汇编代码会导致错误“无法找到当前函数的边界”

    我在 gdb 的目标可执行文件之外 甚至没有与该目标对应的堆栈 无论如何 我想单步执行 以便我可以验证汇编代码中发生了什么 因为我不是 x86 汇编方面的专家 不幸的是 gdb 拒绝进行这种简单的汇编级调试 它允许我设置并停止在适当的断点上
  • 如何知道gdb附加了哪个进程(stat: T)?

    当 gdb 附加进程时 该进程的 stat 为 T 例如 root 6507 0 0 0 0 67896 952 Ss 12 01 0 00 mytest root 6508 0 0 0 0 156472 7120 Sl 12 01 0 0
  • 如何让 gdb 保存命令历史记录?

    我该如何设置gdb这样它就可以保存命令历史记录 当开始新的gdb会话 我想使用向上箭头键来访问之前会话的命令 简短回答 mkdir p config gdb echo set history save on gt gt config gdb
  • 有什么方法可以判断我的 iPhone 应用程序在运行时是否在调试器下运行?

    如果我的错误处理代码在调试器下运行 我希望它的行为有所不同 具体来说 如果我在手机上运行 未连接到调试器并且断言失败 我想将错误发送到我的服务器 当我在gdb下时 我想闯入调试器 虽然我可以想象苹果将如何编写代码 但我找不到任何关于测试调试
  • 如何在 gdb 中禁用“键入 继续,或 q 退出”?

    我想要自动化gdb 并且等待用户输入是不可取的 如何禁用消息 Type
  • 专门逐行调试

    我有一个用 Pascal 编写的脚本 我会以这种方式调试它 在每一行停止 转储内存中所有变量的值 然后转到下一行 是否可以使用 gdb 或其他 Linux 开源工具来完成此操作 使用选项编译文件 g fpc gpc g file pas R
  • 防止GDB中的PLT(过程链接表)断点

    在最新版本的 GDB 中 在库函数调用上设置断点会导致多个实际断点 调用过程链接表 PLT 实际的函数调用 这意味着当调用库函数时 我们每次都会经历两次中断 在以前的 GDB 版本中 只会创建 2 因此您只能得到一次中断 那么问题来了 是否
  • gdb 不会从外部架构读取核心文件

    我正在尝试在 Linux 桌面上读取 ARM 核心文件 但似乎无法找出我的核心文件 有什么方法可以指示 gdb 我的核心文件是什么类型吗 file daemon daemon ELF 32 bit LSB executable ARM ve
  • Qemu flash 启动不起作用

    我有一本相当旧的 2009 年出版 嵌入式 ARM Linux 书 其中使用u boot and qemu 的用法qemu与u boot书中对二进制的解释如下 qemu system arm M connex pflash u boot b

随机推荐

  • 为什么多个类选择器不能与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