svn commit: r354238 - head/contrib/netbsd-tests/lib/libexecinfo
Author: lwhsu Date: Fri Nov 1 09:16:58 2019 New Revision: 354238 URL: https://svnweb.freebsd.org/changeset/base/354238 Log: Temporarily skip lib.libexecinfo.backtrace_test.backtrace_fmt_basic on i386 PR: 241562 Sponsored by: The FreeBSD Foundation Modified: head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Modified: head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c == --- head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Fri Nov 1 06:54:07 2019(r354237) +++ head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c Fri Nov 1 09:16:58 2019(r354238) @@ -151,6 +151,11 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc) ATF_TC_BODY(backtrace_fmt_basic, tc) { +#if defined(__i386__) + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/241562";); +#endif + myfunc(12); if (prevent_inline) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354239 - head/contrib/gdb/gdb
Author: luporl Date: Fri Nov 1 11:28:43 2019 New Revision: 354239 URL: https://svnweb.freebsd.org/changeset/base/354239 Log: [PPC64] Fix GDB sigtramp detection Current implementation of ppcfbsd_pc_in_sigtramp() seems to take only 32-bit PowerPC in account, as on 64-bit PowerPC most kernel instruction addresses will be wrongly reported as in sigtramp. This change adds proper sigtramp detection for PPC64. Reviewed by: jhibbits Differential Revision:https://reviews.freebsd.org/D22199 Modified: head/contrib/gdb/gdb/ppcfbsd-tdep.c Modified: head/contrib/gdb/gdb/ppcfbsd-tdep.c == --- head/contrib/gdb/gdb/ppcfbsd-tdep.c Fri Nov 1 09:16:58 2019 (r354238) +++ head/contrib/gdb/gdb/ppcfbsd-tdep.c Fri Nov 1 11:28:43 2019 (r354239) @@ -487,6 +487,12 @@ ppcfbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name) return (pc >= 0x7fffef00U) ? 1 : 0; } +static int +ppc64_fbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name) +{ + return (pc >= 0x3fffe000U && pc <= 0x3fffefffU) ? 1 : 0; +} + /* NetBSD is confused. It appears that 1.5 was using the correct SVr4 convention but, 1.6 switched to the below broken convention. For the moment use the broken convention. Ulgh!. */ @@ -518,10 +524,9 @@ ppcfbsd_init_abi (struct gdbarch_info info, /* FreeBSD doesn't support the 128-bit `long double' from the psABI. */ set_gdbarch_long_double_bit (gdbarch, 64); - set_gdbarch_pc_in_sigtramp (gdbarch, ppcfbsd_pc_in_sigtramp); - if (tdep->wordsize == 4) { + set_gdbarch_pc_in_sigtramp (gdbarch, ppcfbsd_pc_in_sigtramp); set_gdbarch_return_value (gdbarch, ppcfbsd_return_value); set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); @@ -529,6 +534,7 @@ ppcfbsd_init_abi (struct gdbarch_info info, if (tdep->wordsize == 8) { + set_gdbarch_pc_in_sigtramp (gdbarch, ppc64_fbsd_pc_in_sigtramp); set_gdbarch_convert_from_func_ptr_addr (gdbarch, ppc64_fbsd_convert_from_func_ptr_addr); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r354239 - head/contrib/gdb/gdb
On 11/1/19 4:28 AM, Leandro Lupori wrote: > Author: luporl > Date: Fri Nov 1 11:28:43 2019 > New Revision: 354239 > URL: https://svnweb.freebsd.org/changeset/base/354239 > > Log: > [PPC64] Fix GDB sigtramp detection > > Current implementation of ppcfbsd_pc_in_sigtramp() seems to take only 32-bit > PowerPC in account, as on 64-bit PowerPC most kernel instruction addresses > will > be wrongly reported as in sigtramp. > > This change adds proper sigtramp detection for PPC64. It's probably not worth fixing this in /usr/bin/gdb? At this point gdb is only installed for the kgdb in /usr/libexec on all platforms but sparc64 to serve as a fall-back for the crashinfo script in case the ports gdb isn't installed. The ports gdb should handle signal trampolines fine on ppc. It uses instruction matching patterns to detect trampolines on all supported platforms instead of static sigtramp locations. -- John Baldwin ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r354239 - head/contrib/gdb/gdb
Well, after evaluating remote kernel debugging through serial port, on amd64, I've run into several issues while using latest ports gdb/kgdb. I don't remember all of them, but were things like step/next not always working, connection being lost, and similar things. OTOH, /usr/libexec/kgdb worked fine and reliably, although older and more limited. This is probably due to some incompatibility in GDB Remote Serial Protocol, between the kernel backend and newer GDB from ports. So, that's why I chose to use /usr/libexec/kgdb while fixing/enabling remote debugging on PPC64, because it works reasonably well, and I could focus on testing/fixing other parts first. With only this change on gdb, it is now possible to use it to test some basic functionality, like remote debugger attach, backtrace and data inspection. My goal is not to fix every issue in /usr/libexec/kgdb, but just to get the basics working, to then move on and switch to ports' GDB. - Leandro On Fri, Nov 1, 2019 at 1:06 PM John Baldwin wrote: > On 11/1/19 4:28 AM, Leandro Lupori wrote: > > Author: luporl > > Date: Fri Nov 1 11:28:43 2019 > > New Revision: 354239 > > URL: https://svnweb.freebsd.org/changeset/base/354239 > > > > Log: > > [PPC64] Fix GDB sigtramp detection > > > > Current implementation of ppcfbsd_pc_in_sigtramp() seems to take only > 32-bit > > PowerPC in account, as on 64-bit PowerPC most kernel instruction > addresses will > > be wrongly reported as in sigtramp. > > > > This change adds proper sigtramp detection for PPC64. > > It's probably not worth fixing this in /usr/bin/gdb? At this point gdb is > only > installed for the kgdb in /usr/libexec on all platforms but sparc64 to > serve as > a fall-back for the crashinfo script in case the ports gdb isn't > installed. The > ports gdb should handle signal trampolines fine on ppc. It uses > instruction > matching patterns to detect trampolines on all supported platforms instead > of > static sigtramp locations. > > -- > John Baldwin > ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r354239 - head/contrib/gdb/gdb
On 11/1/19 12:26 PM, luporl wrote: > Well, after evaluating remote kernel debugging through serial port, on > amd64, I've run into several issues while using latest ports gdb/kgdb. > I don't remember all of them, but were things like step/next not always > working, connection being lost, and similar things. > OTOH, /usr/libexec/kgdb worked fine and reliably, although older and more > limited. > This is probably due to some incompatibility in GDB Remote Serial Protocol, > between the kernel backend and newer GDB from ports. > > So, that's why I chose to use /usr/libexec/kgdb while fixing/enabling > remote debugging on PPC64, because it works reasonably well, and I could > focus on testing/fixing other parts first. > With only this change on gdb, it is now possible to use it to test some > basic functionality, like remote debugger attach, backtrace and data > inspection. > > My goal is not to fix every issue in /usr/libexec/kgdb, but just to get the > basics working, to then move on and switch to ports' GDB. What's odd about this commit is it only affects userland binaries, not the kernel, so a bit odd for kgdb, especially since the old kgdb in the tree doesn't include user support IIRC, only kernel bits (in modern gdb, kgdb is just a wrapper, and you can use 'target vmcore' from within gdb itself against a crash dump, etc.) -- John Baldwin ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r354239 - head/contrib/gdb/gdb
The kernel parts were fixed by r354213 and r354214. I've used old kgdb to test remote debugging through serial only, not for inspecting crash dumps. On Fri, Nov 1, 2019 at 4:34 PM John Baldwin wrote: > On 11/1/19 12:26 PM, luporl wrote: > > Well, after evaluating remote kernel debugging through serial port, on > > amd64, I've run into several issues while using latest ports gdb/kgdb. > > I don't remember all of them, but were things like step/next not always > > working, connection being lost, and similar things. > > OTOH, /usr/libexec/kgdb worked fine and reliably, although older and more > > limited. > > This is probably due to some incompatibility in GDB Remote Serial > Protocol, > > between the kernel backend and newer GDB from ports. > > > > So, that's why I chose to use /usr/libexec/kgdb while fixing/enabling > > remote debugging on PPC64, because it works reasonably well, and I could > > focus on testing/fixing other parts first. > > With only this change on gdb, it is now possible to use it to test some > > basic functionality, like remote debugger attach, backtrace and data > > inspection. > > > > My goal is not to fix every issue in /usr/libexec/kgdb, but just to get > the > > basics working, to then move on and switch to ports' GDB. > > What's odd about this commit is it only affects userland binaries, not the > kernel, so a bit odd for kgdb, especially since the old kgdb in the tree > doesn't include user support IIRC, only kernel bits (in modern gdb, kgdb > is just a wrapper, and you can use 'target vmcore' from within gdb itself > against a crash dump, etc.) > > -- > John Baldwin > ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r354206 - head/sys/arm/allwinner
The first part (cam_sim_alloc -> cam_sim_alloc_dev) is necessary to properly fill cam_sim structure so that sdiob(4) can attach to the SDIO card. See https://svnweb.freebsd.org/base?view=revision&revision=r348800 for the details. The second part (new DEVMETHOD) is needed because now MMC adapter becomes a bus (like, something that has children) and without this change the kernel panics when trying to attach sdiob(4). On Thu, Oct 31, 2019 at 1:51 PM Emmanuel Vadot wrote: > On Wed, 30 Oct 2019 20:43:27 + (UTC) > Ilya Bakulin wrote: > > > Author: kibab > > Date: Wed Oct 30 20:43:27 2019 > > New Revision: 354206 > > URL: https://svnweb.freebsd.org/changeset/base/354206 > > > > Log: > > Use the new cam_sim_alloc_dev function to properly initialize SIM > > > > Using cam_sim_alloc_dev() allows to properly set sim_dev field so that > > sdiob(4) can attach to the CAM device that represents SDIO card. > > The same change for SDHCI driver happened in r348800. > > > > Approved by:imp (mentor) > > Differential Revision: https://reviews.freebsd.org/D22192 > > > > Modified: > > head/sys/arm/allwinner/aw_mmc.c > > > > Modified: head/sys/arm/allwinner/aw_mmc.c > > > == > > --- head/sys/arm/allwinner/aw_mmc.c Wed Oct 30 20:08:10 2019 > (r354205) > > +++ head/sys/arm/allwinner/aw_mmc.c Wed Oct 30 20:43:27 2019 > (r354206) > > @@ -526,8 +526,8 @@ aw_mmc_attach(device_t dev) > > } > > > > mtx_init(&sc->sim_mtx, "awmmcsim", NULL, MTX_DEF); > > - sc->sim = cam_sim_alloc(aw_mmc_cam_action, aw_mmc_cam_poll, > > - "aw_mmc_sim", sc, device_get_unit(dev), > > + sc->sim = cam_sim_alloc_dev(aw_mmc_cam_action, aw_mmc_cam_poll, > > + "aw_mmc_sim", sc, dev, > > &sc->sim_mtx, 1, 1, sc->devq); > > > > if (sc->sim == NULL) { > > @@ -1514,6 +1514,7 @@ static device_method_t aw_mmc_methods[] = { > > /* Bus interface */ > > DEVMETHOD(bus_read_ivar,aw_mmc_read_ivar), > > DEVMETHOD(bus_write_ivar, aw_mmc_write_ivar), > > + DEVMETHOD(bus_add_child,bus_generic_add_child), > > Why is this change needed ? > > > > > /* MMC bridge interface */ > > DEVMETHOD(mmcbr_update_ios, aw_mmc_update_ios), > > > -- > Emmanuel Vadot > ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354240 - in head/stand: efi/loader i386/libi386
Author: imp Date: Fri Nov 1 21:26:43 2019 New Revision: 354240 URL: https://svnweb.freebsd.org/changeset/base/354240 Log: We don't support configuring serial PCI cards in EFI. Make this clearer in the source rather than obfuscaring it behind NO_PCI (nothing else declares that, so it's not making the ifdefs clearer). Modified: head/stand/efi/loader/Makefile head/stand/i386/libi386/comconsole.c Modified: head/stand/efi/loader/Makefile == --- head/stand/efi/loader/Makefile Fri Nov 1 11:28:43 2019 (r354239) +++ head/stand/efi/loader/Makefile Fri Nov 1 21:26:43 2019 (r354240) @@ -55,7 +55,7 @@ CFLAGS+= -I${EFISRC}/include CFLAGS+= -I${EFISRC}/include/${MACHINE} CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include CFLAGS+= -I${BOOTSRC}/i386/libi386 -CFLAGS+= -DNO_PCI -DEFI +CFLAGS+= -DEFI .if !defined(BOOT_HIDE_SERIAL_NUMBERS) # Export serial numbers, UUID, and asset tag from loader. Modified: head/stand/i386/libi386/comconsole.c == --- head/stand/i386/libi386/comconsole.cFri Nov 1 11:28:43 2019 (r354239) +++ head/stand/i386/libi386/comconsole.cFri Nov 1 21:26:43 2019 (r354240) @@ -214,7 +214,8 @@ comc_port_set(struct env_var *ev, int flags, const voi static uint32_t comc_parse_pcidev(const char *string) { -#ifdef NO_PCI +#ifdef EFI + /* We don't support PCI in EFI yet */ return (0); #else char *p, *p1; @@ -256,7 +257,8 @@ comc_parse_pcidev(const char *string) static int comc_pcidev_handle(uint32_t locator) { -#ifdef NO_PCI +#ifdef EFI + /* We don't support PCI in EFI yet */ return (CMD_ERROR); #else char intbuf[64]; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354241 - head/sys/kern
Author: mav Date: Fri Nov 1 22:49:44 2019 New Revision: 354241 URL: https://svnweb.freebsd.org/changeset/base/354241 Log: Some more taskqueue optimizations. - Optimize enqueue for two task priority values by adding new tq_hint field, pointing to the last task inserted into the middle of the list. In case of more then two priority values it should halve average search. - Move tq_active insert/remove out of the taskqueue_run_locked loop. Instead of dirtying few shared cache lines per task introduce different mechanism to drain active tasks, based on task sequence number counter, that uses only cache lines already present in cache. Since the new mechanism does not need ordering, switch tq_active from TAILQ to LIST. - Move static and dynamic struct taskqueue fields into different cache lines. Move lock into its own cache line, so that heavy lock spinning by multiple waiting threads would not affect the running thread. - While there, correct some TQ_SLEEP() wait messages. This change fixes certain ZFS write workloads, causing huge congestion on taskqueue lock. Those workloads combine some large block writes to saturate the pool and trigger allocation throttling, which uses higher priority tasks to requeue the delayed I/Os, with many small blocks to generate deep queue of small tasks for taskqueue to sort. MFC after:1 week Sponsored by: iXsystems, Inc. Modified: head/sys/kern/subr_gtaskqueue.c head/sys/kern/subr_taskqueue.c Modified: head/sys/kern/subr_gtaskqueue.c == --- head/sys/kern/subr_gtaskqueue.c Fri Nov 1 21:26:43 2019 (r354240) +++ head/sys/kern/subr_gtaskqueue.c Fri Nov 1 22:49:44 2019 (r354241) @@ -57,26 +57,26 @@ TASKQGROUP_DEFINE(softirq, mp_ncpus, 1); TASKQGROUP_DEFINE(config, 1, 1); struct gtaskqueue_busy { - struct gtask*tb_running; - TAILQ_ENTRY(gtaskqueue_busy) tb_link; + struct gtask*tb_running; + u_inttb_seq; + LIST_ENTRY(gtaskqueue_busy) tb_link; }; -static struct gtask * const TB_DRAIN_WAITER = (struct gtask *)0x1; - typedef void (*gtaskqueue_enqueue_fn)(void *context); struct gtaskqueue { STAILQ_HEAD(, gtask)tq_queue; + LIST_HEAD(, gtaskqueue_busy) tq_active; + u_int tq_seq; + int tq_callouts; + struct mtx_padalign tq_mutex; gtaskqueue_enqueue_fn tq_enqueue; void*tq_context; char*tq_name; - TAILQ_HEAD(, gtaskqueue_busy) tq_active; - struct mtx tq_mutex; struct thread **tq_threads; int tq_tcount; int tq_spin; int tq_flags; - int tq_callouts; taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS]; void*tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS]; }; @@ -115,12 +115,11 @@ gtask_dump(struct gtask *gtask) #endif static __inline int -TQ_SLEEP(struct gtaskqueue *tq, void *p, struct mtx *m, int pri, const char *wm, -int t) +TQ_SLEEP(struct gtaskqueue *tq, void *p, const char *wm) { if (tq->tq_spin) - return (msleep_spin(p, m, wm, t)); - return (msleep(p, m, pri, wm, t)); + return (msleep_spin(p, (struct mtx *)&tq->tq_mutex, wm, 0)); + return (msleep(p, &tq->tq_mutex, 0, wm, 0)); } static struct gtaskqueue * @@ -144,7 +143,7 @@ _gtaskqueue_create(const char *name, int mflags, } STAILQ_INIT(&queue->tq_queue); - TAILQ_INIT(&queue->tq_active); + LIST_INIT(&queue->tq_active); queue->tq_enqueue = enqueue; queue->tq_context = context; queue->tq_name = tq_name; @@ -167,7 +166,7 @@ gtaskqueue_terminate(struct thread **pp, struct gtaskq while (tq->tq_tcount > 0 || tq->tq_callouts > 0) { wakeup(tq); - TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); + TQ_SLEEP(tq, pp, "gtq_destroy"); } } @@ -178,7 +177,7 @@ gtaskqueue_free(struct gtaskqueue *queue) TQ_LOCK(queue); queue->tq_flags &= ~TQ_FLAGS_ACTIVE; gtaskqueue_terminate(queue->tq_threads, queue); - KASSERT(TAILQ_EMPTY(&queue->tq_active), ("Tasks still running?")); + KASSERT(LIST_EMPTY(&queue->tq_active), ("Tasks still running?")); KASSERT(queue->tq_callouts == 0, ("Armed timeout tasks")); mtx_destroy(&queue->tq_mutex); free(queue->tq_threads, M_GTASKQUEUE); @@ -285,7 +284,7 @@ gtaskqueue_drain_tq_queue(struct gtaskqueue *queue) * have completed or are currently executing. */ while (t_barrier.ta_flags & TASK_ENQUEUED) - TQ_SLEEP(queue, &t_barrier, &queue->tq_mutex, PWAIT, "-", 0); +
svn commit: r354242 - head/sys/dev/ena
Author: imp Date: Sat Nov 2 02:05:09 2019 New Revision: 354242 URL: https://svnweb.freebsd.org/changeset/base/354242 Log: Make valdiate_rx_req_id static inline because it uses other static inline functions. gcc complains about this, most likely due to the subtle differences between inline and static inline functions defined in headers. Modified: head/sys/dev/ena/ena.h Modified: head/sys/dev/ena/ena.h == --- head/sys/dev/ena/ena.h Fri Nov 1 22:49:44 2019(r354241) +++ head/sys/dev/ena/ena.h Sat Nov 2 02:05:09 2019(r354242) @@ -489,9 +489,8 @@ voidena_down(struct ena_adapter *); intena_restore_device(struct ena_adapter *); void ena_destroy_device(struct ena_adapter *, bool); intena_refill_rx_bufs(struct ena_ring *, uint32_t); -inline int validate_rx_req_id(struct ena_ring *, uint16_t); -inline int +static inline int validate_rx_req_id(struct ena_ring *rx_ring, uint16_t req_id) { if (likely(req_id < rx_ring->ring_size)) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354243 - head/sys/powerpc/mpc85xx
Author: jhibbits Date: Sat Nov 2 02:24:53 2019 New Revision: 354243 URL: https://svnweb.freebsd.org/changeset/base/354243 Log: powerpc/mpc85xx: Set description for the MPC85xx RC bridge Modified: head/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c Modified: head/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c == --- head/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c Sat Nov 2 02:05:09 2019 (r354242) +++ head/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c Sat Nov 2 02:24:53 2019 (r354243) @@ -92,6 +92,8 @@ fsl_pcib_rc_probe(device_t dev) if (pci_get_subclass(dev) != PCIS_PROCESSOR_POWERPC) return (ENXIO); + device_set_desc(dev, "MPC85xx Root Complex bridge"); + return (BUS_PROBE_DEFAULT); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354244 - head/sys/netgraph
Author: glebius Date: Sat Nov 2 03:09:17 2019 New Revision: 354244 URL: https://svnweb.freebsd.org/changeset/base/354244 Log: Fix regression from r353026. Pointer was increased instead of value pointed to. PR: 241646 Submitted by: Aleksandr Fedorov Modified: head/sys/netgraph/ng_bridge.c Modified: head/sys/netgraph/ng_bridge.c == --- head/sys/netgraph/ng_bridge.c Sat Nov 2 02:24:53 2019 (r354243) +++ head/sys/netgraph/ng_bridge.c Sat Nov 2 03:09:17 2019 (r354244) @@ -977,7 +977,7 @@ ng_bridge_unmute(hook_p hook, void *arg) ng_bridge_nodename(node), NG_HOOK_NAME(hook)); } } - counter++; + (*counter)++; return (1); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354245 - in head/stand: . common liblua lua
Author: kevans Date: Sat Nov 2 03:37:58 2019 New Revision: 354245 URL: https://svnweb.freebsd.org/changeset/base/354245 Log: stand: consolidate knowledge of lua path Multiple places coordinate to 'know' where lua scripts are installed. Knock this down to being formally defined (and overridable) in exactly one spot, defs.mk, and spread the knowledge to loaders and liblua alike. A future commit will expose this to lua as loader.lua_path, so it can build absolute paths to lua scripts as needed. MFC after:1 week Modified: head/stand/common/interp_lua.c head/stand/defs.mk head/stand/liblua/Makefile head/stand/liblua/luaconf.h head/stand/loader.mk head/stand/lua/Makefile Modified: head/stand/common/interp_lua.c == --- head/stand/common/interp_lua.c Sat Nov 2 03:09:17 2019 (r354244) +++ head/stand/common/interp_lua.c Sat Nov 2 03:37:58 2019 (r354245) @@ -60,6 +60,8 @@ static struct interp_lua_softc lua_softc; #defineLDBG(...) #endif +#defineLOADER_LUA LUA_PATH "/loader.lua" + INTERP_DEFINE("lua"); static void * @@ -120,7 +122,7 @@ interp_init(void) lua_pop(luap, 1); /* remove lib */ } - filename = "/boot/lua/loader.lua"; + filename = LOADER_LUA; if (interp_include(filename) != 0) { const char *errstr = lua_tostring(luap, -1); errstr = errstr == NULL ? "unknown" : errstr; Modified: head/stand/defs.mk == --- head/stand/defs.mk Sat Nov 2 03:09:17 2019(r354244) +++ head/stand/defs.mk Sat Nov 2 03:37:58 2019(r354245) @@ -40,6 +40,9 @@ BOOTOBJ= ${OBJTOP}/stand # BINDIR is where we install BINDIR?= /boot +# LUAPATH is where we search for and install lua scripts. +LUAPATH?= /boot/lua + LIBSA= ${BOOTOBJ}/libsa/libsa.a .if ${MACHINE} == "i386" LIBSA32= ${LIBSA} Modified: head/stand/liblua/Makefile == --- head/stand/liblua/Makefile Sat Nov 2 03:09:17 2019(r354244) +++ head/stand/liblua/Makefile Sat Nov 2 03:37:58 2019(r354245) @@ -27,7 +27,7 @@ SRCS+=lerrno.c lfs.c lstd.c lutils.c WARNS= 3 -CFLAGS+= -DLUA_PATH_DEFAULT=\"/boot/lua/\?.lua\" +CFLAGS+= -DLUA_PATH=\"${LUAPATH}\" -DLUA_PATH_DEFAULT=\"${LUAPATH}/\?.lua\" CFLAGS+= -ffreestanding -nostdlib -DLUA_USE_POSIX CFLAGS+= -fno-stack-protector -D__BSD_VISIBLE CFLAGS+= -I${BOOTSRC}/include -I${LIBLUASRC} -I${LUASRC} -I${LDRSRC} Modified: head/stand/liblua/luaconf.h == --- head/stand/liblua/luaconf.h Sat Nov 2 03:09:17 2019(r354244) +++ head/stand/liblua/luaconf.h Sat Nov 2 03:37:58 2019(r354245) @@ -202,7 +202,7 @@ #else /* }{ */ -#define LUA_ROOT "/boot/lua/" LUA_VDIR "/" +#define LUA_ROOT LUA_PATH "/" LUA_VDIR "/" #define LUA_LDIR LUA_ROOT "share/" #define LUA_CDIR LUA_ROOT "lib/" #ifndef LUA_PATH_DEFAULT Modified: head/stand/loader.mk == --- head/stand/loader.mkSat Nov 2 03:09:17 2019(r354244) +++ head/stand/loader.mkSat Nov 2 03:37:58 2019(r354245) @@ -62,6 +62,7 @@ SRCS+=interp_lua.c .include "${BOOTSRC}/lua.mk" LDR_INTERP=${LIBLUA} LDR_INTERP32= ${LIBLUA32} +CFLAGS+= -DLUA_PATH=\"${LUAPATH}\" .elif ${LOADER_INTERP} == "4th" SRCS+= interp_forth.c .include "${BOOTSRC}/ficl.mk" Modified: head/stand/lua/Makefile == --- head/stand/lua/Makefile Sat Nov 2 03:09:17 2019(r354244) +++ head/stand/lua/Makefile Sat Nov 2 03:37:58 2019(r354245) @@ -12,7 +12,7 @@ MAN= cli.lua.8 \ password.lua.8 \ screen.lua.8 -FILESDIR= /boot/lua +FILESDIR= ${LUAPATH} FILES= cli.lua \ color.lua \ config.lua \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354246 - head/stand/liblua
Author: kevans Date: Sat Nov 2 03:41:30 2019 New Revision: 354246 URL: https://svnweb.freebsd.org/changeset/base/354246 Log: liblua: add loader.lua_path As described previously, loader.lua_path is absolute path where scripts are installed. A future commit will use this to build paths for dofile in try_include, rather than the current pcall/require setup that makes it more difficult to coordinate loader aborts from local.lua -- we do not need the flexibility of require(), and local.lua is in-fact not a 'module-like' file as we will not be referencing anything from it. Modified: head/stand/liblua/lutils.c Modified: head/stand/liblua/lutils.c == --- head/stand/liblua/lutils.c Sat Nov 2 03:37:58 2019(r354245) +++ head/stand/liblua/lutils.c Sat Nov 2 03:41:30 2019(r354246) @@ -384,6 +384,8 @@ luaopen_loader(lua_State *L) lua_setfield(L, -2, "machine"); lua_pushstring(L, MACHINE_ARCH); lua_setfield(L, -2, "machine_arch"); + lua_pushstring(L, LUA_PATH); + lua_setfield(L, -2, "lua_path"); /* Set global printc to loader.printc */ lua_register(L, "printc", lua_printc); return 1; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354247 - head/stand/lua
Author: kevans Date: Sat Nov 2 04:01:39 2019 New Revision: 354247 URL: https://svnweb.freebsd.org/changeset/base/354247 Log: lualoader: rewrite try_include using lfs + dofile Actual modules get require()'d in, rather than try_include(). All instances of try_include should be provided with proper hooks/API in the rest of loader to do the work they need to do, since we can't rely on them to exist. Convert this now to lfs + dofile since we won't really be treating them as modules. lfs is required because dofile will properly throw an error if the file doesn't exist, which is not in the spirit of 'optionally included'. Getting out of the pcall game allows us to provide a loader.exit() style call that backs out to the common bits of loader (autoboot sequence unless disabled with a loader.setenv("autoboot_delay", "NO")). The most ideal way identified so far to implement loader.exit() is to throw a special abort-style error that indicates to the caller in interp_lua that we've not actually errored out, just continue execution. Otherwise, we have to hack in logic to bubble up and return from loader.lua without continuing further, which gets kind of ugly depending on the context in which we're aborting. A compat shim is provided temporarily in case the executing loader doesn't yet have loader.lua_path, which was just added in r354246. Modified: head/stand/lua/core.lua Modified: head/stand/lua/core.lua == --- head/stand/lua/core.lua Sat Nov 2 03:41:30 2019(r354246) +++ head/stand/lua/core.lua Sat Nov 2 04:01:39 2019(r354247) @@ -69,12 +69,28 @@ end -- try_include will return the loaded module on success, or false and the error -- message on failure. function try_include(module) - local status, ret = pcall(require, module) - -- ret is the module if we succeeded. - if status then - return ret + if module:sub(1, 1) ~= "/" then + local lua_path = loader.lua_paths + -- XXX Temporary compat shim; this should be removed once the + -- loader.lua_path export has sufficiently spread. + if lua_path == nil then + lua_path = "/boot/lua" + end + module = lua_path .. "/" .. module + -- We only attempt to append an extension if an absolute path + -- wasn't specified. This assumes that the caller either wants + -- to treat this like it would require() and specify just the + -- base filename, or they know what they're doing as they've + -- specified an absolute path and we shouldn't impede. + if module:match(".lua$") == nil then + module = module .. ".lua" + end end - return false, ret + if lfs.attributes(module, "mode") ~= "file" then + return + end + + return dofile(module) end -- Module exports ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"