When compiling a program with clang I observe the following in the LLVM IR:
Given the following function declaration:
declare i32 #atoi(i8*) #2
Which has the following attributes:
attributes #2 = { nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
I can see that when the function is called:
%26 = call i32 #atoi(i8* %25) #5
More attributes get defined/re-defined for it:
attributes #5 = { nounwind readonly }
I know that the #2 attribute group contains "Function attributes" that can be added to a Function with the addFnAttr(Attribute Attr) method. I also know that there are "Return attributes" that I can add to a CallInst with addAttribute(0, Attribute Attr) as well as "Parameter attributes" that I can add with the same method or with an AttributeList/Set. This gives me, for example, %26 = call nounwind i32 #atoi(i8* nounwind %25).
But how are the attributes in the #5 attribute group added? What are they called? Are they different from the other kinds of attributes? Are they redundant in this case?
Related
I have a simple data:
{
"name" : "example task",
"description":"example description",
"type" : "task",
"details" : {
"__type__":"task",
"amount":20.00,
},
"publish" : true
}
When I test my API with postman, everything works. But when I write a unit test for controller, I got this error:
1) test create_task: assign task (OkBackendWeb.TaskControllerTest)
test/ok_backend_web/controllers/task_controller_test.exs:87
** (Protocol.UndefinedError) protocol Phoenix.Param not implemented for 20.0 of type Float. This protocol is implemented for the following type(s): Any, Atom, BitString, Integer, Map
code: conn = post(conn, Routes.item_path(conn, :create_all, #create_attrs))
stacktrace:
(phoenix 1.5.13) lib/phoenix/param.ex:121: Phoenix.Param.Any.to_param/1
(plug 1.12.1) lib/plug/conn/query.ex:275: Plug.Conn.Query.encode_value/2
(plug 1.12.1) lib/plug/conn/query.ex:246: Plug.Conn.Query.encode_pair/3
(plug 1.12.1) lib/plug/conn/query.ex:262: anonymous fn/3 in Plug.Conn.Query.encode_kv/3
(elixir 1.13.1) lib/enum.ex:1213: anonymous fn/3 in Enum.flat_map/2
(stdlib 3.14) maps.erl:233: :maps.fold_1/3
(elixir 1.13.1) lib/enum.ex:2408: Enum.flat_map/2
(plug 1.12.1) lib/plug/conn/query.ex:266: Plug.Conn.Query.encode_kv/3
(plug 1.12.1) lib/plug/conn/query.ex:262: anonymous fn/3 in Plug.Conn.Query.encode_kv/3
(elixir 1.13.1) lib/enum.ex:4086: Enum.flat_map_list/2
(elixir 1.13.1) lib/enum.ex:4087: Enum.flat_map_list/2
(plug 1.12.1) lib/plug/conn/query.ex:266: Plug.Conn.Query.encode_kv/3
(plug 1.12.1) lib/plug/conn/query.ex:204: Plug.Conn.Query.encode/2
(ok_backend 0.1.0) lib/ok_backend_web/router.ex:1: OkBackendWeb.Router.Helpers.segments/5
(ok_backend 0.1.0) lib/ok_backend_web/router.ex:1: OkBackendWeb.Router.Helpers.item_path/3
test/ok_backend_web/controllers/task_controller_test.exs:91: (test)
this is my test exs:
defmodule ExampleWeb.TaskControllerTest do
use ExampleWeb.ConnCase
alias Example.Users
alias Example.Items
#create_attrs %{
"name" => "milk with cow",
"description"=> "cow are cute.",
"type" => "task",
"details" => %{
"amount"=> 20.00,
},
"publish" => true
}
setup %{conn: conn} do
{:ok, conn: put_req_header(conn, "accept", "application/json")}
end
describe "create_task:" do
test "create task", %{conn: conn} do
%{ token: [ token ] } = get_poster_token(conn)
conn = post(conn, Routes.item_path(conn, :create_all, #create_attrs))
assert json_response(conn, 200)["status"] == 1
end
end
defp get_poster_token(conn) do
conn = post(conn, Routes.passwordless_path(conn, :user_auth, #user_poster))
token = get_resp_header(conn, "authorization")
%{token: token}
end
How can I resolve this?
You're passing the POST data as an argument to the routes function. It should be a separate argument to post/3:
post(conn, Routes.item_path(conn, :create_all), item: #create_attrs)
When I try to load the query below with the entire data set (ie, around 100,000 rows in total) it errors with:
"Expression.Error column "Column1" not found" (Column1 refers to a column which I expanded in a function and then call in the query)
When I limit the dataset to call only ~900 rows, I do NOT get the error and the dataset loads perfectly.
My conclusion is that there is NOT ACTUALLY an error in my query, but somehow the size of the dataset is causing this.
QUESTION: How can I prevent this error and get my whole dataset to
load?
*********QUERY THAT DOES NOT LOAD:
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Invoked Custom Function" = Table.AddColumn(Source, "FnGet", each FnGet([companyID])),
#"Expanded FnGet" = Table.ExpandTableColumn(#"Invoked Custom Function", "FnGet", {"date", "articleUrl", "title", "summary", "reads"}, {"date", "articleUrl", "title", "summary", "reads"}) in
#"Expanded FnGet"
***QUERY THAT HAS NO ERROR ON LOAD:
NOTE STEP 1 "Kept First Rows" which reduces the dataset to approx 1000 rows
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Kept First Rows" = Table.FirstN(Source,10),
#"Invoked Custom Function" = Table.AddColumn(#"Kept First Rows", "FnGet", each FnGet([companyID])),
#"Expanded FnGet" = Table.ExpandTableColumn(#"Invoked Custom Function", "FnGet", {"date", "articleUrl", "title", "summary", "reads"}, {"date", "articleUrl", "title", "summary", "reads"}) in
#"Expanded FnGet"
*************** ADDITIONAL INFORMATION ******************
The query references a function "FnGet" which references Column1 in step 3:
let
Source = (companyID as any) => let
Source = Json.Document(Web.Contents("https://www.lexology.com/api/v1/track/clients/articles?companyId=" & Number.ToText(companyID)&"&limit=100" , [Headers=[ApiKey="ABCD12345"]])),
#"Converted to Table" = Record.ToTable(Source),
Value = #"Converted to Table"{7}[Value],
#"Converted to Table1" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"date", "articleUrl", "title", "summary", "reads"}, {"date", "articleUrl", "title", "summary", "reads"})
in
#"Expanded Column1"
in
Source
How to find out type for the global variables. For example:
C code
int bar; // global variable -> int type
int *ptr; // global variable -> int type
void foo() {} // some function
LLVM IR
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(name: "bar", scope: !2, file: !8, line: 1, type: !10, isLocal: false, isDefinition: true)
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
!3 = !DIFile(filename: "example.cpp", directory: "/sample/")
!4 = !{}
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
!7 = distinct !DIGlobalVariable(name: "ptr", scope: !2, file: !8, line: 2, type: !9, isLocal: false, isDefinition: true)
!8 = !DIFile(filename: "./example.cpp", directory: "/sample/")
!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
I am trying follow the Flutter pub.dev documentation for Cognito and AWS User Authentication. I am building a Flutter mobile app, and was able to successfully register users into my AWS user pool. I am trying to code the login functionality however it will not register any of the parameters that I am trying to give it. i.e password and username (email)
I have tried restarting the computer, Android Studios, tried following all AWS documentation, and re-writing the code on https://pub.dev/packages/amazon_cognito_identity_dart
AttributeArg ar1 = AttributeArg(name: 'USERNAME', value: userEmail);
AttributeArg ar2 = AttributeArg(name: 'PASSWORD', value: userPassword);
final List<AttributeArg> authParams = [
ar1,
ar2,
];
AuthenticationDetails authDetails2 = AuthenticationDetails();
authDetails2.authParameters = authParams;
//final authDetails = new AuthenticationDetails(
//authParameters: authDetails2.getAuthParameters());
final authDetails =
new AuthenticationDetails(authParameters: authDetails2.authParameters);
setCognitoUser();
CognitoUserSession session;
cognitoUser.setAuthenticationFlowType('USER_PASSWORD_AUTH');
try {
//session = await cognitoUser.initiateAuth(authDetails);
session = await cognitoUser.authenticateUser(authDetails);
// username: userEmail, password: userPassword));
} catch (e) {
print(e);
}
print(session.getAccessToken().getJwtToken());
I/flutter ( 4963): Invalid argument(s): PASSWORD parameter is required
E/flutter ( 4963): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'getAccessToken' was called on null.
E/flutter ( 4963): Receiver: null
E/flutter ( 4963): Tried calling: getAccessToken()
E/flutter ( 4963): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
E/flutter ( 4963): #1 Globals.logInUser (package:neurominer_app/globals.dart:76:19)
E/flutter ( 4963):
E/flutter ( 4963): #2 _LoginScreenState.build. (package:neurominer_app/screens/login_screen.dart:155:34)
E/flutter ( 4963): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:635:14)
E/flutter ( 4963): #4 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:711:32)
E/flutter ( 4963): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 4963): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
E/flutter ( 4963): #7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:275:7)
E/flutter ( 4963): #8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:455:9)
E/flutter ( 4963): #9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:75:13)
E/flutter ( 4963): #10 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:102:11)
E/flutter ( 4963): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 4963): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 4963): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 4963): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 4963): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 4963): #16 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter ( 4963): #17 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 4963): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter ( 4963): #19 _invoke1 (dart:ui/hooks.dart:250:10)
E/flutter ( 4963): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:159:5)
E/flutter ( 4963):
Correct code from https://pub.dev/packages/amazon_cognito_identity_dart
Just needed to make sure that since I was splitting up my code between multiple screens (importing classes and calling methods to do user authentication) that valid username and password (non-null) values were being used to authenticate.
final userPool = new CognitoUserPool(
'ap-southeast-1_xxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
final cognitoUser = new CognitoUser(
'email#inspire.my', userPool);
final authDetails = new AuthenticationDetails(
username: 'email#inspire.my', password: 'Password001');
CognitoUserSession session;
try {
session = await cognitoUser.authenticateUser(authDetails);
} catch(e){
print(e);
}
Have an error as follows:
Terminating app due to uncaught exception 'NameError', reason: 'weather_controller.rb:3:in `viewDidLoad': uninitialized constant WeatherController::Name (NameError)
AppDelegate:
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
puts "Hello! You just launched: #{App.name}, \n location: (#{App.documents_path})"
#window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
#window.backgroundColor = UIColor.lightGrayColor
#window.rootViewController = MyController.alloc.init
#window.makeKeyAndVisible
true
end
end
my_controller.rb:
class MyController < UIViewController
def viewDidLoad
#name_label = setup_label [[10, 10], [300, 50]], UIColor.orangeColor, Name
#place_label = setup_label [[10, 80], [300, 50]], UIColor.yellowColor, Place
#temp_label = setup_label [[10, 150], [300, 50]], UIColor.greenColor, Temperature
end
def setup_label frame, bgcolor, text
label = UILabel.alloc.initWithFrame(frame)
label.textColor = UIColor.darkGrayColor
label.backgroundColor = bgcolor
label.textAlignment = UITextAlignmentCenter
label.text = text.to_s
view.addSubview label
label
end
end
Any ideas? Thanks in advance
In your setup_label method, you're accepting the following arguments, frame, bgcolor and text where your text argument suppose to be a String object.
Therefore, your viewDidLoad method should be the following
def viewDidLoad
#name_label = setup_label [[10, 10], [300, 50]], UIColor.orangeColor, "Name"
#place_label = setup_label [[10, 80], [300, 50]], UIColor.yellowColor, "Place"
#temp_label = setup_label [[10, 150], [300, 50]], UIColor.greenColor, "Temperature"
end