Why %DebugPrint doesn't print all information about my object? - v8

node --allow-natives-syntax test.js
var obj = {a: 1};
%DebugPrint(obj);
It will output:
0x053bedbc1399 <Object map = 0x53b630d1d51>
But in earlier versions of v8 it prints full information about object, something like:
0x337ab90027d9: [Map]
- type: JS_ARRAY_TYPE
- instance size: 32
- inobject properties: 0
- elements kind: PACKED_SMI_ELEMENTS
- unused property fields: 0
- enum length: invalid
- back pointer: 0x337a1f6822e1 <undefined>
- instance descriptors (own) #1: 0x337a3c307a69 <FixedArray[5]>
- layout descriptor: 0x0
- transitions #1: 0x337a3c307979 <TransitionArray[4]>Transition array #1:
0x337a1f684631 <Symbol: (elements_transition_symbol)>: (transition to HOLEY_SMI_ELEMENTS) -> 0x337ab9002889 <Map(HOLEY_SMI_ELEMENTS)>
- prototype: 0x337a3c307809 <JSArray[0]>
- constructor: 0x337a3c304f21 <JSFunction Array (sfi = 0x337a1f6a9cb1)>
- code cache: 0x337a1f682251 <FixedArray[0]>
- dependent code: 0x337a1f682251 <FixedArray[0]>
- construction counter: 0

This is a difference between Release and Debug builds, not between versions. In Release mode, most of the implementation of debug-printing is skipped (for binary-size reasons), so you'll only get one line of output. In Debug builds, you'll get the full details. This has not changed recently.

Related

How is $id and $ref values are used in device tree yaml binding file? and can I see it?

This has been a question I had for a long time.
I started to read https://docs.kernel.org/devicetree/bindings/writing-schema.html but it's hard to understand.
For example in linux-5.15.68, the file Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml starts like this.
# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/pci/snps,dw-pcie.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Synopsys DesignWare PCIe interface
maintainers:
- Jingoo Han <jingoohan1#gmail.com>
- Gustavo Pimentel <gustavo.pimentel#synopsys.com>
description: |
Synopsys DesignWare PCIe host controller
allOf:
- $ref: /schemas/pci/pci-bus.yaml#
properties:
compatible:
anyOf:
- {}
- const: snps,dw-pcie
How is the URI $id and $scmema used? and if I want to browse the file, how can I do it?
When I put http://devicetree.org/schemas/pci/snps,dw-pcie.yaml the browser says 'These are not the schemas you are looking for.'.

replace yaml array with json format using bash, yq, jq

For readability purpose when displaying informations using yaml format, I'd like to be able to replace a yaml array with its json equivalent
The thing is that I may have several instances to replace in the yaml file/output with different paths
Example:
objects:
- object:
name: objA
inputs:
- dims:
- 1
- 3
- object:
name: objB
outputs:
- dims:
- 5
but I'd like the output to be json format for dims arrays, like
objects:
- object:
name: objA
inputs:
- dims: [1,3]
- object:
name: objB
outputs:
- dims: [5]
converting the value from yaml to json is easy, modifying the value of the yaml nodes is easy, but I don't see how I can get the value for a "dims" node, convert it to a json value string, a put it back in the node (I mean without searching explicitly all instances)
in general, I'm looking for a way to replace the value of a node, with the result of a process on the value of the node (other example, replacing an id with the name of the corresponding object retrieved through a REST api request)
objects:
- object:
name: objA
dependency: 3fc4bd5b-a6ee-4469-946d-5f780476784e
would be displayed as
objects:
- object:
name: objA
dependency: name-of-dependency
where the id is replaced by the friendly name of the dependency
thanks
With mikefarah's yq
yq e '.objects[].object["inputs","outputs"][].dims? |= "["+join(",")+"]"' data.yml
You could use tojson and the update operator |=. This will encode your arrays as JSON, which is a string and therefore itself enclosed in quotes:
yq -y '(.. | .dims? | arrays) |= tojson'
objects:
- object:
name: objA
inputs:
- dims: '[1,3]'
- object:
name: objB
outputs:
- dims: '[5]'
Run with Python yq

How can I fix yaml error: Block mapping value not allowed here

I copied Semaphore's config of GoReleaser and saved it as .semaphore/semaphore.yml but when I run it on Semaphore, I can see:
Unprocessable YAML file.
Error: {{:throw, {:yamerl_exception, [{:yamerl_parsing_error, :error, 'Block mapping value not allowed here', 30, 20, :block_mapping_value_not_allowed, :undefined, []}]}}, "# .semaphore/semaphore.yml.\nversion: v1.0\nname: Build\nagent:\n machine:\n type: e1-standard-2\n os_image: ubuntu1804\n\nblocks:\n - name: \"Test\"\n task:\n prologue:\n commands:\n # set go version\n - sem-version go 1.11\n - \"export GOPATH=~/go\"\n - \"export PATH=/home/semaphore/go/bin:$PATH\"\n - checkout\n\n jobs:\n - name: \"Lint\"\n commands:\n - go get ./...\n - go test ./...\n\n# On Semaphore 2.0 deployment and delivery is managed with promotions,\n# which may be automatic or manual and optionally depend on conditions.\npromotions:\n - name: Release\n pipeline_file: goreleaser.yml\n auto_promote_on:\n - result: passed\n branch:\n - \"^refs/tags/v*\"\n"}
How can I fix it?
In this last part:
promotions:
- name: Release
pipeline_file: goreleaser.yml
auto_promote_on:
- result: passed
branch:
- "^refs/tags/v*"
The indentation of pipeline_file and auto_promote_on is wrong – both need to be at the same level as name.

YAML Can local variables be mixed with group-variables AND have their naming simplified?

This is my first time working with YAML, but I am running into an issue where it seems like if I want to include a variable-group (i.e., signing certificate password) with local pipeline-related variables then I cannot use the simplified naming convention where the variable's name and value can both be defined and set on the same line.
For example, wat I want is something similar to this (I made sure spacing is correct in the YAML):
variables:
solutionName: Foo.sln
projectName: Bar
buildPlatform: x64
buildConfiguration: development
major: '1'
minor: '0'
build: '0'
revision: $[counter('rev', 0)]
vhdxSize: '200'
- group: legacy-pipeline
signingCertPwd: $[variables.SigningCertificatePassword]
But, this results in a parsing error. As a result, I have to use a denser, but more bloated looking, format of:
variables:
- name: solutionName
value: Foo.sln
- name: projectName
value: Bar
- name: buildPlatform
value: x64
- name: buildConfiguration
value: development
- name: major
value: '1'
- name: minor
value: '0'
- name: build
value: '0'
- name: revision
value: $[counter('rev', 0)]
- name: vhdxSize
value: '200'
- group: legacy-pipeline
- name: signingCertPwd
value: $[variables.SigningCertificatePassword]
It seems like the simplified naming format is only available if I use it for local variables, but if I add a variable-group then the simplified format goes away. I have tried searching the web for a solution for this, but I am not able find anything useful for this. Is what I am trying to achieve possible or no? If yes, how can it be done?
Unfortunately mixing the styles is not possible, but you can work around that using templates:
# pipeline.yaml
stages:
- stage: declare_vars
variables:
- template: templates/vars.yaml
- group: my-group
- template: templates/inline-vars.yaml
parameters:
vars:
inline_var: yes!
and_more: why not
jobs:
- job:
steps:
- pwsh: |
echo 'foo=$(foo)'
echo 'bar=$(bar)'
echo 'var1=$(var1)'
echo 'inline_var=$(inline_var)'
# templates/vars.yaml
variables:
foo: bar
bar: something else
# templates/inline-vars.yaml
parameters:
- name: vars
type: object
default: {}
variables:
${{ each var in parameters.vars}}:
${{var.key}}: ${{var.value}}
templates/vars.yaml is just simply moving variables to another file.
templates/inline-vars.yaml lets you define inline variables using the denser syntax together with referencing groups, but there's additional ceremony of writing template:, parameters:, vars:.

Getting exception while running SaltStack module.run function with name dsc.apply_config

I'm getting the following error while trying to state.apply sls on windows machine.
ID: ProvisionADDC
Function: module.run
Name: dsc.apply_config
Result: False
Comment: Module function dsc.apply_config threw an exception. Exception: No JSON results from powershell. Additional info follows:
retcode:
0
stderr:
stdout:
Started: 12:06:08.044000
Duration: 2684.0 ms
Changes:
Since win_dsc is execution module, then I'm forced to use state.module module to run this function on minion:
C:\DSC:
file.directory:
- makedirs: True
allprofiles:
win_firewall.disabled
CopyDSCModules:
file.recurse:
- name: 'C:\Program Files\WindowsPowerShell\Modules'
- source: salt://windows/dsc/
InstallADDomainServices:
win_servermanager.installed:
- name: AD-Domain-Services
- restart: True
- require:
- file: CopyDSCModules
ProvisionADDC:
module.run:
- name: dsc.apply_config
- path: C:\DSC\
- source: salt://windows/mof
- require:
- file: 'C:\DSC'
- file: CopyDSCModules
- win_servermanager: InstallADDomainServices
Anybody have experience with win_dsc and SaltStack ?
I think it's a case of the documentation lacking a bit, but you need to actually run the configuration in the same ps1 file, eg.
Configuration myconfig {
Node 'localhost' {
WindowsFeature 'DNS' {
Name = 'DNS'
Ensure = Present
}
}
}
myconfig
I'm playing with this a litle at the moment and hopefully I can come up with a helpful issue/PR because it is lacking a bit (even if just for better error logging).
I'm not sure how this works in terms of determining a specific config as I'e not tested that yet (using the config_name param).

Resources